713 lines
43 KiB
XML
713 lines
43 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<panel-form xmlns="http://www.davinti.com.br/vitruvio/form/panel"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.davinti.com.br/vitruvio/form/panel https://bitbucket.org/davinTI/vitruvio-xds/raw/master/vitruvio-panel-form.xsd">
|
|
<form formKey="formCadastroJogos" width="100%" height="100%">
|
|
<name>Cadastro de jogos</name>
|
|
<description>Painel para cadastro de jogos</description>
|
|
|
|
<initScript language="JavaScript">
|
|
<![CDATA[
|
|
|
|
var lib_cadastro_padrao = libService.loadScript("lib_cadastro_padrao");
|
|
|
|
var config_jogos = {
|
|
tabela:
|
|
{
|
|
conexao : 'vitruvio',
|
|
nome : 'TB_MATHEUS_MEDEIROS_JOGOS',
|
|
sequence : 'TB_MATHEUS_MEDEIROS_JOGOS_SEQ',
|
|
idTabela : 'CODIGO',
|
|
campos: [
|
|
'CODIGO',
|
|
'TITULO',
|
|
'GENERO',
|
|
'ANO_LANCAMENTO',
|
|
'PRODUTORA',
|
|
'NOTA_MEDIA',
|
|
'DESCRICAO'
|
|
],
|
|
camposTable: [
|
|
'CODIGO',
|
|
'TITULO',
|
|
'GENERO',
|
|
'ANO_LANCAMENTO',
|
|
'PRODUTORA',
|
|
'NOTA_MEDIA',
|
|
'DESCRICAO'
|
|
],
|
|
},
|
|
relaciona: [
|
|
['CODIGO', 'txfCodigo', 'Number'],
|
|
['TITULO', 'txfTitulo', 'String'],
|
|
['GENERO', 'cbbGenero', 'String'],
|
|
['ANO_LANCAMENTO', 'txfAnoLancamento', 'Number'],
|
|
['PRODUTORA', 'txfProdutora', 'String'],
|
|
['NOTA_MEDIA', 'txfNotaMedia', 'Number'],
|
|
['DESCRICAO', 'txaDescricao', 'String']
|
|
],
|
|
validacaoExclusao: [],
|
|
painel: {
|
|
'titulo' : 'Exemplo de exibição de dados do DB em tabela',
|
|
}
|
|
};
|
|
|
|
var config_avaliacoes = {
|
|
tabela: {
|
|
conexao : 'vitruvio',
|
|
nome : 'TB_MATHEUS_MEDEIROS_AVALIACOES',
|
|
sequence : 'TB_MATHEUS_MEDEIROS_AVALIACOES_SEQ',
|
|
idTabela : 'CODIGO',
|
|
campos: [
|
|
'CODIGO',
|
|
'NOME',
|
|
'EMAIL',
|
|
'COMENTARIO',
|
|
'NOTA',
|
|
'DATA_AVALIACAO',
|
|
'ID_JOGO'
|
|
],
|
|
camposTable: [
|
|
'CODIGO',
|
|
'NOME',
|
|
'EMAIL',
|
|
'COMENTARIO',
|
|
'NOTA',
|
|
'DATA_AVALIACAO',
|
|
'ID_JOGO'
|
|
],
|
|
},
|
|
relaciona: [
|
|
['CODIGO', 'txfCodigoAvaliacao', 'Number'],
|
|
['NOME', 'txfNome', 'String'],
|
|
['EMAIL', 'txfEmail', 'String'],
|
|
['COMENTARIO', 'txfComentario', 'String'],
|
|
['NOTA', 'dcfNota', 'Number'],
|
|
['DATA_AVALIACAO', 'dtfDataAvaliacao', 'Date' ],
|
|
['ID_JOGO', 'txfCodigoJogo', 'Number']
|
|
],
|
|
validacaoExclusao: [],
|
|
painel: {
|
|
'titulo' : 'Exemplo de exibição de dados do DB em tabela',
|
|
}
|
|
};
|
|
|
|
function changeCrudPanel(NewScreenName){
|
|
if(NewScreenName === "cadastroJogo"){
|
|
engine.getLayout("pnlListaJogos").getRootComposition().setVisible(false);
|
|
engine.getLayout("pnlCadastroJogo").getRootComposition().setVisible(true);
|
|
} else {
|
|
engine.getField("dbtJogos").refresh();
|
|
engine.getLayout("pnlListaJogos").getRootComposition().setVisible(true);
|
|
engine.getLayout("pnlCadastroJogo").getRootComposition().setVisible(false);
|
|
}
|
|
}
|
|
|
|
function resetPanelReviews(){
|
|
engine.getField("txfCodigoAvaliacao").setValue("");
|
|
engine.getField("txfCodigoJogo").setValue("");
|
|
engine.getField("txfNome").setValue("");
|
|
engine.getField("txfEmail").setValue("");
|
|
engine.getField("txfComentario").setValue("");
|
|
engine.getField("dcfNota").setValue("");
|
|
|
|
}
|
|
|
|
function resetPanelGames(){
|
|
engine.getField("txfCodigo").setValue("");
|
|
engine.getField("txfTitulo").setValue("");
|
|
engine.getField("cbbGenero").setValue("");
|
|
engine.getField("txfAnoLancamento").setValue("");
|
|
engine.getField("txfProdutora").setValue("");
|
|
engine.getField("txaDescricao").setValue("");
|
|
engine.getField("txfNotaMedia").setValue("");
|
|
}
|
|
|
|
function organizeRequiredFields(whichForm, isToRequest) {
|
|
var fields = [];
|
|
if(whichForm === "jogos"){
|
|
fields = ["txfCodigo", "txfTitulo", "cbbGenero", "txfAnoLancamento", "txfProdutora", "txaDescricao"];
|
|
} else if(whichForm === "avaliacoes") {
|
|
fields = ["txfCodigoAvaliacao", "txfCodigoJogo", "txfNome", "txfEmail", "txfComentario", "dcfNota"];
|
|
}
|
|
|
|
if(isToRequest) {
|
|
fields.forEach(function(fieldId) {
|
|
var field = engine.getField(fieldId);
|
|
if (field) {
|
|
field.setRequired(true);
|
|
}
|
|
});
|
|
} else {
|
|
fields.forEach(function(fieldId) {
|
|
var field = engine.getField(fieldId);
|
|
if (field) {
|
|
field.setRequired(false);
|
|
}
|
|
});
|
|
}};
|
|
|
|
function showTableReviews(gameId) {
|
|
if(!gameId) {
|
|
var lib_msg = libService.loadScript("messages");
|
|
lib_msg.showNotification({
|
|
type: lib_msg.notificationType.tray,
|
|
caption: "Erro!",
|
|
msg: "Selecione um jogo para ver as avaliações.",
|
|
position: lib_msg.notificationPosition.bottom_right,
|
|
});
|
|
return;
|
|
} else {
|
|
engine.getLayout("wltListaAvaliacoes").showWindow();
|
|
}
|
|
}
|
|
|
|
function run() {
|
|
engine.setGlobalVariable('config_jogos', config_jogos);
|
|
engine.setGlobalVariable('config_avaliacoes', config_avaliacoes);
|
|
engine.setGlobalVariable("lib_cadastro_padrao", lib_cadastro_padrao);
|
|
engine.setGlobalVariable("changeCrudPanel", changeCrudPanel);
|
|
engine.setGlobalVariable("showTableReviews", showTableReviews);
|
|
engine.setGlobalVariable("organizeRequiredFields", organizeRequiredFields);
|
|
engine.setGlobalVariable("resetPanelReviews", resetPanelReviews);
|
|
engine.setGlobalVariable("resetPanelGames", resetPanelGames);
|
|
}
|
|
]]>
|
|
</initScript>
|
|
|
|
<components>
|
|
<VerticalLayout width="100%" height="100%" align="MIDDLE_RIGHT">
|
|
|
|
<WindowLayout id="wltCriarAvaliacoes" windowModal="true" windowHeight="70%"
|
|
windowWidth="80%" windowTitle="Nova avaliação">
|
|
<VerticalLayout width="100%" height="100%" spacing="true" margin="true">
|
|
<TextField width="100%" id="txfCodigoAvaliacao" type="number"
|
|
caption="Código"
|
|
required="false" enabled="false" visible="false" />
|
|
<DateField caption="Data da avaliação"
|
|
required="false" enabled="false" width="100%" visible="false"
|
|
id="dtfDataAvaliacao" format="dd/MM/yyyy"
|
|
type="date" />
|
|
<TextField width="100%" id="txfCodigoJogo" type="number"
|
|
caption="Código do jogo"
|
|
required="true" enabled="false" visible="false" />
|
|
<TextField width="100%" id="txfNome" type="string" caption="Nome"
|
|
required="true" />
|
|
<TextField width="100%" id="txfEmail" type="email" caption="E-mail"
|
|
required="true" />
|
|
<TextField width="100%" id="txfComentario" type="string"
|
|
caption="Comentário" required="true" />
|
|
<DecimalField width="100%" id="dcfNota" type="decimal"
|
|
caption="Nota (0 a 10)"
|
|
required="true" />
|
|
<ButtonWidget id="btnSalvarAvaliacao" caption="Salvar" defaultIcon="SAVE"
|
|
style="BLUE">
|
|
<onClickScript language="JavaScript">
|
|
<![CDATA[
|
|
function run() {
|
|
engine.getGlobalVariable("organizeRequiredFields")("jogos", false);
|
|
engine.getField("txfCodigoJogo").setValue(engine.getField("dbtJogos").getValue());
|
|
|
|
var hoje = new Date();
|
|
var javaDate = new java.util.Date(hoje.getTime());
|
|
engine.getField("dtfDataAvaliacao").setValue(javaDate);
|
|
|
|
if(engine.isValid()){
|
|
|
|
engine.getField("txfCodigo").setValue(engine.getField("dbtJogos").getValue());
|
|
var config_avaliacoes = engine.getGlobalVariable("config_avaliacoes");
|
|
var lib = libService.loadScript("lib_cadastro_padrao");
|
|
var id = engine.getField("txfCodigoAvaliacao").getValue();
|
|
var retorno = lib.fncGravarRegistro(config_avaliacoes, id);
|
|
engine.getField("dbtJogos").refresh();
|
|
|
|
if (retorno) {
|
|
var lib_msg = libService.loadScript("messages");
|
|
engine.getField("txfCodigoAvaliacao").setValue(retorno);
|
|
engine.getField("dbtAvaliacoes").refresh();
|
|
lib_msg.showNotification({
|
|
type: lib_msg.notificationType.tray,
|
|
caption: "Sucesso!",
|
|
msg: "Avaliação foi salva com sucesso!",
|
|
position: lib_msg.notificationPosition.bottom_right,
|
|
});
|
|
}
|
|
engine.getLayout("wltCriarAvaliacoes").closeWindow();
|
|
engine.getLayout("wltListaAvaliacoes").showWindow();
|
|
engine.getGlobalVariable("organizeRequiredFields")("jogos", true);
|
|
|
|
}
|
|
}
|
|
]]>
|
|
</onClickScript>
|
|
</ButtonWidget>
|
|
</VerticalLayout>
|
|
</WindowLayout>
|
|
|
|
<WindowLayout id="wltListaAvaliacoes" windowModal="true" windowHeight="80%"
|
|
windowWidth="80%">
|
|
|
|
<VerticalLayout spacing="true" margin="true" height="100%">
|
|
<Label id="lblTitle">
|
|
<value>Avaliações</value>
|
|
</Label>
|
|
<DBTable id="dbtAvaliacoes" type="string" width="100%"
|
|
gridSelectable="true" selectable="false" height="100%"
|
|
expandRatio="0.2" showRowCount="true">
|
|
<datasource>
|
|
<sqlBuilderDataSource connection-key="vitruvio"
|
|
language="JavaScript">
|
|
<![CDATA[
|
|
function buildSQL(_){
|
|
var txfPesquisa = engine.getField("txfPesquisaJogo").getValue();
|
|
var sqlBase = "SELECT * FROM TB_MATHEUS_MEDEIROS_AVALIACOES ORDER BY CODIGO";
|
|
var id_jogo = engine.getField("dbtJogos").getValue();
|
|
if(id_jogo != null){
|
|
sqlBase = "SELECT * FROM TB_MATHEUS_MEDEIROS_AVALIACOES WHERE ID_JOGO = " + id_jogo + " ORDER BY CODIGO";
|
|
}
|
|
return sqlBase;
|
|
}
|
|
]]>
|
|
</sqlBuilderDataSource>
|
|
</datasource>
|
|
<key-field>CODIGO</key-field>
|
|
<columns>
|
|
|
|
<column name="CODIGO" caption="ID" />
|
|
<column name="NOME" caption="NOME" />
|
|
<column name="EMAIL" caption="E-MAIL" />
|
|
<column name="COMENTARIO" caption="COMENTÁRIO" />
|
|
<column name="NOTA" caption="NOTA" />
|
|
<column name="DATA_AVALIACAO" caption="DATA DE AVALIAÇÃO" />
|
|
|
|
<generated name="EDITAR" caption="EDITAR" align="CENTER">
|
|
<scriptColumnGenerator language="JavaScript">
|
|
<![CDATA[
|
|
function Generator() {
|
|
var comp = libService.loadScript("vaadinComponents");
|
|
this.generate = function (itemId, columnId, item, container) {
|
|
var btn = comp.buttonIcon("Editar", function () {
|
|
var id = itemId;
|
|
engine.getField("txfCodigoAvaliacao").setValue(id);
|
|
if (id != null) {
|
|
engine.getLayout("wltCriarAvaliacoes").showWindow();
|
|
engine.getLayout("wltListaAvaliacoes").closeWindow();
|
|
var config_avaliacoes = engine.getGlobalVariable('config_avaliacoes');
|
|
var lib = libService.loadScript('lib_cadastro_padrao');
|
|
var sql = lib.fncCarregarCampos(config_avaliacoes, id);
|
|
}
|
|
}, "pencil");
|
|
|
|
return btn;
|
|
}
|
|
}
|
|
var script = new Generator();
|
|
]]>
|
|
</scriptColumnGenerator>
|
|
</generated>
|
|
<generated name="EXCLUIR" caption="EXCLUIR" align="CENTER">
|
|
<scriptColumnGenerator language="JavaScript">
|
|
<![CDATA[
|
|
function Generator() {
|
|
var comp = libService.loadScript("vaadinComponents");
|
|
this.generate = function (itemId, columnId, item, container) {
|
|
var btn = comp.buttonIcon(
|
|
"Excluir",
|
|
function () {
|
|
var lib = engine.getGlobalVariable("lib_cadastro_padrao");
|
|
var config_avaliacoes = engine.getGlobalVariable("config_avaliacoes");
|
|
var registro = itemId + " - " + item.getItemProperty("nome");
|
|
var msg = "Tem certeza de que deseja excluir o comentário " + registro + "?";
|
|
var lib_msg = libService.loadScript("messages");
|
|
lib_msg.confirmationBox(
|
|
{
|
|
icon: lib_msg.confirmationIcon.question,
|
|
caption: "Confirmar operação",
|
|
msg: msg,
|
|
actions: lib_msg.confirmationControls.yes_no,
|
|
},
|
|
function(action) {
|
|
if(action.yes()) {
|
|
try{
|
|
lib.fncDeletarRegistro(config_avaliacoes, itemId);
|
|
engine.getField("dbtAvaliacoes").refresh();
|
|
} catch (error) {
|
|
engine.getField("dbtAvaliacoes").refresh();
|
|
lib_msg.showNotification({
|
|
type: lib_msg.notificationType.tray,
|
|
caption: "Avaliação apagada!",
|
|
msg: "A avaliação foi apagada com sucesso.",
|
|
position: lib_msg.notificationPosition.bottom_right,
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
);
|
|
},
|
|
"trash",
|
|
);
|
|
return btn;
|
|
}
|
|
}
|
|
var script = new Generator();
|
|
]]>
|
|
</scriptColumnGenerator>
|
|
</generated>
|
|
</columns>
|
|
</DBTable>
|
|
<HorizontalLayout spacing="true" align="MIDDLE_RIGHT">
|
|
<ButtonWidget id="btnVoltarAvaliacoes" style="BLACK" caption="Voltar"
|
|
width="20%" align="MIDDLE_RIGHT" defaultIcon="BACK">
|
|
<onClickScript language="JavaScript">
|
|
<![CDATA[
|
|
function run() {
|
|
engine.getLayout("wltListaAvaliacoes").closeWindow();
|
|
}
|
|
]]>
|
|
</onClickScript>
|
|
</ButtonWidget>
|
|
<ButtonWidget id="btnAdicionarAvaliacoes" style="GREEN"
|
|
caption="Nova Avaliação"
|
|
width="20%" align="MIDDLE_RIGHT" defaultIcon="ADD">
|
|
<onClickScript language="JavaScript">
|
|
<![CDATA[
|
|
function run (){
|
|
engine.getGlobalVariable("resetPanelReviews")();
|
|
engine.getLayout("wltCriarAvaliacoes").showWindow();
|
|
engine.getLayout("wltListaAvaliacoes").closeWindow();
|
|
}
|
|
]]>
|
|
</onClickScript>
|
|
</ButtonWidget>
|
|
</HorizontalLayout>
|
|
</VerticalLayout>
|
|
</WindowLayout>
|
|
|
|
<CrudPanel id="pnlListaJogos" width="100%" height="100%" visible="true">
|
|
<Header backgroundColor="ORANGE">
|
|
<Caption>Avaliações dos jogos</Caption>
|
|
<SubCaption>Os melhores jogos já feitos</SubCaption>
|
|
</Header>
|
|
<Section height="100%" caption="Jogos" subCaption="Veja todos os jogos"
|
|
id="secDadosJogo">
|
|
<VerticalLayout width="100%" height="100%" align="MIDDLE_CENTER"
|
|
spacing="true">
|
|
<HorizontalLayout width="100%" spacing="true">
|
|
<TextField expandRatio="0.8" width="100%" id="txfPesquisaJogo"
|
|
caption="Pesquise pelo nome do jogo" type="string"
|
|
immediate="true">
|
|
|
|
<events>
|
|
<valueChange>
|
|
<script language="JavaScript">
|
|
<![CDATA[
|
|
function run(){
|
|
engine.getField("dbtJogos").refresh();
|
|
}
|
|
]]>
|
|
</script>
|
|
</valueChange>
|
|
</events>
|
|
</TextField>
|
|
<ButtonWidget defaultIcon="SEARCH" id="btnPesquisar"
|
|
caption="Pesquisar" style="BLUE" expandRatio="0.2">
|
|
<onClickScript language="JavaScript">
|
|
<![CDATA[
|
|
function run() {
|
|
engine.getField("dbtJogos").refresh();
|
|
}
|
|
]]>
|
|
</onClickScript>
|
|
</ButtonWidget>
|
|
</HorizontalLayout>
|
|
<DBTable id="dbtJogos" align="MIDDLE_CENTER" type="string" width="100%"
|
|
gridSelectable="true" height="100%"
|
|
expandRatio="0.5" showRowCount="true" drawRefreshButton="true">
|
|
<datasource>
|
|
<sqlBuilderDataSource connection-key="vitruvio"
|
|
language="JavaScript">
|
|
<![CDATA[
|
|
function buildSQL(_){
|
|
var txfPesquisa = engine.getField("txfPesquisaJogo").getValue();
|
|
|
|
var sqlBase = "SELECT J.CODIGO, J.TITULO, J.GENERO, J.ANO_LANCAMENTO, J.PRODUTORA, COALESCE(ROUND(AVG(A.NOTA), 2), 0) AS NOTA_MEDIA, J.DESCRICAO FROM TB_MATHEUS_MEDEIROS_JOGOS J LEFT JOIN TB_MATHEUS_MEDEIROS_AVALIACOES A ON J.CODIGO = A.ID_JOGO";
|
|
|
|
if (txfPesquisa) {
|
|
sqlBase += " WHERE UPPER(J.TITULO) LIKE UPPER('%" + txfPesquisa + "%')";
|
|
}
|
|
|
|
sqlBase += " GROUP BY J.CODIGO, J.TITULO, J.GENERO, J.ANO_LANCAMENTO, J.PRODUTORA, J.DESCRICAO";
|
|
sqlBase += " ORDER BY J.CODIGO";
|
|
|
|
return sqlBase;
|
|
}
|
|
]]>
|
|
</sqlBuilderDataSource>
|
|
</datasource>
|
|
<key-field>CODIGO</key-field>
|
|
<columns>
|
|
<column name="CODIGO" caption="ID" />
|
|
<column name="TITULO" caption="TÍTULO" />
|
|
<column name="GENERO" caption="GÊNERO" />
|
|
<column name="ANO_LANCAMENTO" caption="ANO DE LANÇAMENTO" />
|
|
<column name="PRODUTORA" caption="PRODUTORA" />
|
|
<column name="NOTA_MEDIA" caption="NOTA MÉDIA" />
|
|
<column name="DESCRICAO" caption="DESCRIÇÃO" />
|
|
|
|
<generated name="AVALIACOES" caption="AVALIACOES" align="CENTER">
|
|
<scriptColumnGenerator language="JavaScript">
|
|
<![CDATA[
|
|
function Generator() {
|
|
var comp = libService.loadScript("vaadinComponents");
|
|
this.generate = function (itemId, columnId, item, container) {
|
|
var btn = comp.buttonIcon("Avaliações", function () {
|
|
engine.getField("dbtJogos").setValue(itemId);
|
|
engine.getField("dbtAvaliacoes").refresh();
|
|
var idJogoSelecionado = engine.getField("dbtJogos").getValue();
|
|
engine.getGlobalVariable("showTableReviews")(itemId);
|
|
}, "star");
|
|
|
|
return btn;
|
|
}
|
|
}
|
|
var script = new Generator();
|
|
]]>
|
|
</scriptColumnGenerator>
|
|
</generated>
|
|
<generated name="EDITAR" caption="EDITAR" align="CENTER">
|
|
<scriptColumnGenerator language="JavaScript">
|
|
<![CDATA[
|
|
function Generator() {
|
|
var comp = libService.loadScript("vaadinComponents");
|
|
this.generate = function (itemId, columnId, item, container) {
|
|
var btn = comp.buttonIcon("Editar", function () {
|
|
var id = itemId;
|
|
engine.getField("txfCodigo").setValue(id);
|
|
|
|
if (id != null) {
|
|
engine.getGlobalVariable("changeCrudPanel")("cadastroJogo");
|
|
var config_jogos = engine.getGlobalVariable('config_jogos');
|
|
var lib = libService.loadScript('lib_cadastro_padrao');
|
|
var sql = lib.fncCarregarCampos(config_jogos, id);
|
|
}
|
|
}, "pencil");
|
|
|
|
return btn;
|
|
}
|
|
}
|
|
var script = new Generator();
|
|
]]>
|
|
</scriptColumnGenerator>
|
|
</generated>
|
|
<generated name="EXCLUIR" caption="EXCLUIR" align="CENTER">
|
|
<scriptColumnGenerator language="JavaScript">
|
|
<![CDATA[
|
|
function Generator() {
|
|
var comp = libService.loadScript("vaadinComponents");
|
|
this.generate = function (itemId, columnId, item, container) {
|
|
var btn = comp.buttonIcon(
|
|
"Excluir",
|
|
function () {
|
|
var lib = engine.getGlobalVariable("lib_cadastro_padrao");
|
|
var config_jogos = engine.getGlobalVariable("config_jogos");
|
|
var registro = itemId + " - " + item.getItemProperty("titulo");
|
|
var msg = "Tem certeza de que deseja excluir o jogo " + registro + "?";
|
|
var lib_msg = libService.loadScript("messages");
|
|
lib_msg.confirmationBox(
|
|
{
|
|
icon: lib_msg.confirmationIcon.question,
|
|
caption: "Confirmar operação",
|
|
msg: msg,
|
|
actions: lib_msg.confirmationControls.yes_no,
|
|
},
|
|
function(action) {
|
|
if(action.yes()) {
|
|
try {
|
|
lib.fncDeletarRegistro(config_jogos, itemId);
|
|
engine.getField("dbtJogos").refresh();
|
|
} catch (error) {
|
|
engine.getField("dbtJogos").refresh();
|
|
lib_msg.showNotification({
|
|
type: lib_msg.notificationType.tray,
|
|
caption: "Apagado!!",
|
|
msg: "O jogo foi apagado com sucesso.",
|
|
position: lib_msg.notificationPosition.bottom_right,
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
);
|
|
},
|
|
"trash",
|
|
);
|
|
return btn;
|
|
}
|
|
}
|
|
var script = new Generator();
|
|
|
|
]]>
|
|
</scriptColumnGenerator>
|
|
</generated>
|
|
</columns>
|
|
</DBTable>
|
|
<HorizontalLayout align="MIDDLE_RIGHT" spacing="true">
|
|
<ButtonWidget defaultIcon="ADD" id="btnAdicionarJogo" style="GREEN"
|
|
caption="Novo">
|
|
<onClickScript language="JavaScript">
|
|
<![CDATA[
|
|
function run (){
|
|
engine.getGlobalVariable("changeCrudPanel")("cadastroJogo");
|
|
}
|
|
]]>
|
|
</onClickScript>
|
|
</ButtonWidget>
|
|
<ButtonWidget defaultIcon="STAR" id="btnVerAvaliacoes" style="ORANGE"
|
|
caption="Avaliações">
|
|
<onClickScript language="JavaScript">
|
|
<![CDATA[
|
|
function run (){
|
|
engine.getField("dbtAvaliacoes").refresh();
|
|
var idJogoSelecionado = engine.getField("dbtJogos").getValue();
|
|
engine.getGlobalVariable("showTableReviews")(idJogoSelecionado);
|
|
}
|
|
]]>
|
|
</onClickScript>
|
|
</ButtonWidget>
|
|
</HorizontalLayout>
|
|
</VerticalLayout>
|
|
</Section>
|
|
</CrudPanel>
|
|
|
|
<CrudPanel id="pnlCadastroJogo" width="100%" height="100%" visible="false">
|
|
<Header backgroundColor="ORANGE">
|
|
<Caption>Cadastro de jogos</Caption>
|
|
<SubCaption>Dados para cadastro de jogos</SubCaption>
|
|
</Header>
|
|
<Section caption="Novo jogo" subCaption="Informe os dados abaixo" width="100%">
|
|
|
|
<VerticalLayout width="100%" height="100%" align="MIDDLE_CENTER"
|
|
spacing="true">
|
|
<Panel id="pnlDadosJogos" width="100%" height="100%" caption="Dados do Jogo" margin="true">
|
|
<VerticalLayout caption="Dados do Jogo" width="100%" spacing="true">
|
|
|
|
<TextField id="txfCodigo" caption="Código" type="number"
|
|
width="100%" enabled="false" visible="false" />
|
|
<NumericField id="txfNotaMedia" caption="Nota média"
|
|
type="number"
|
|
width="100%" enabled="false" visible="false" />
|
|
<TextField id="txfTitulo" caption="Título" type="string"
|
|
width="100%"
|
|
required="true" minLength="3" maxLength="100" />
|
|
<ComboBox id="cbbGenero" allowNullSelection="false"
|
|
caption="Gênero" description="ComboBox Exemplo"
|
|
updatable="false" required="true"
|
|
visible="true" type="string" width="100%">
|
|
<entry value="Ação" key="Ação" />
|
|
<entry value="Aventura" key="Aventura" />
|
|
<entry value="Corrida" key="Corrida" />
|
|
<entry value="Esporte" key="Esporte" />
|
|
<entry value="Estratégia" key="Estratégia" />
|
|
<entry value="Luta" key="Luta" />
|
|
<entry value="RPG" key="RPG" />
|
|
<entry value="Simulação" key="Simulação" />
|
|
<entry value="Terror" key="Terror" />
|
|
<entry value="Sobrevivência" key="Sobrevivência" />
|
|
<entry value="Infântil" key="Infântil" />
|
|
</ComboBox>
|
|
<TextField id="txfAnoLancamento" caption="Ano de Lançamento"
|
|
type="number" width="100%" required="true" maxLength="4">
|
|
<validation>
|
|
<script language="JavaScript">
|
|
<![CDATA[
|
|
function validator(){
|
|
|
|
|
|
this.getMessage = function(){
|
|
return "O ano de lançamento deve ser um número válido entre 1970 e o ano atual.";
|
|
};
|
|
|
|
|
|
this.isValid = function(){
|
|
|
|
if(!engine.getField("txfAnoLancamento").isRequired()){
|
|
return true;
|
|
}
|
|
|
|
var value = engine.getField("txfAnoLancamento").getValue();
|
|
var currentYear = new Date().getFullYear();
|
|
return value >= 1970 && value <= currentYear;
|
|
};
|
|
}
|
|
var script = new validator();
|
|
]]>
|
|
</script>
|
|
</validation>
|
|
</TextField>
|
|
<TextField id="txfProdutora" caption="Produtora" type="string"
|
|
width="100%" required="true" maxLength="50" />
|
|
<TextArea id="txaDescricao" caption="Descrição do Jogo"
|
|
type="string" width="100%" height="" maxLength="500" />
|
|
</VerticalLayout>
|
|
</Panel>
|
|
<HorizontalLayout align="MIDDLE_RIGHT" spacing="true">
|
|
<ButtonWidget id="btnLimpar" caption="Limpar" defaultIcon="REFRESH"
|
|
style="ORANGE">
|
|
<onClickScript language="JavaScript">
|
|
<![CDATA[
|
|
function run(){
|
|
var config_jogos = engine.getGlobalVariable('config_jogos');
|
|
var lib = libService.loadScript('lib_cadastro_padrao');
|
|
var retorno = lib.fncLimpaCampos(config_jogos);
|
|
}
|
|
]]>
|
|
</onClickScript>
|
|
</ButtonWidget>
|
|
<ButtonWidget id="btnSalvar" caption="Salvar" defaultIcon="SAVE"
|
|
style="BLUE">
|
|
<onClickScript language="JavaScript">
|
|
<![CDATA[
|
|
function run() {
|
|
engine.getGlobalVariable("organizeRequiredFields")("avaliacoes", false);
|
|
if(engine.isValid()){
|
|
var config_jogos = engine.getGlobalVariable("config_jogos");
|
|
var lib = libService.loadScript("lib_cadastro_padrao");
|
|
var id = engine.getField("txfCodigo").getValue();
|
|
var retorno = lib.fncGravarRegistro(config_jogos, id);
|
|
if (retorno) {
|
|
var lib_msg = libService.loadScript("messages");
|
|
engine.getField("dbtJogos").refresh();
|
|
engine.getGlobalVariable("resetPanelGames")();
|
|
engine.getGlobalVariable("changeCrudPanel")("listaJogos");
|
|
lib_msg.showNotification({
|
|
type: lib_msg.notificationType.tray,
|
|
caption: "Sucesso!",
|
|
msg: "O jogo foi gravado com sucesso",
|
|
position: lib_msg.notificationPosition.bottom_right,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
]]>
|
|
</onClickScript>
|
|
</ButtonWidget>
|
|
<ButtonWidget id="btnVoltar" caption="Voltar" defaultIcon="BACK"
|
|
style="BLACK">
|
|
<onClickScript language="JavaScript">
|
|
<![CDATA[
|
|
function run() {
|
|
engine.getGlobalVariable("changeCrudPanel")("listaJogos");
|
|
}
|
|
]]>
|
|
</onClickScript>
|
|
</ButtonWidget>
|
|
</HorizontalLayout>
|
|
</VerticalLayout>
|
|
</Section>
|
|
</CrudPanel>
|
|
</VerticalLayout>
|
|
</components>
|
|
</form>
|
|
</panel-form>
|