refactor: update panel configuration and add cadastro_jogos desktop XML
This commit is contained in:
@@ -0,0 +1,315 @@
|
||||
<?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 width="100%" height="100%" target="DEFAULT" formKey="formTeste">
|
||||
<description></description>
|
||||
<initScript language="JavaScript">
|
||||
<![CDATA[
|
||||
var lib_cadastro_padrao = libService.loadScript("lib_cadastro_padrao");
|
||||
|
||||
var config_jogos = {
|
||||
tabela:
|
||||
{
|
||||
conexao : 'vitruvio',
|
||||
nome : '',
|
||||
sequence : '',
|
||||
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_LUCAS_AGUILAR_JOGOS_AVALIACOES',
|
||||
sequence : 'TB_LUCAS_AGUILAR_JOGOS_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%" >
|
||||
<CrudPanel width="100%" height="100%" visible="true">
|
||||
<Header>
|
||||
<Caption></Caption>
|
||||
<SubCaption>Cadastro de jogos</SubCaption>
|
||||
</Header>
|
||||
<Section height="100%" width="100%" caption="Jogos" subCaption="Veja todos os jogos" id = "secJogos">
|
||||
<VerticalLayout height="100%" width="100%" align="MIDDLE_CENTER" spacing="true">
|
||||
<HorizontalLayout width="100%" spacing="true">
|
||||
<TextField id="txfPesquisaJogo" expandRatio="0.8" width="100%" caption="Pesquisar jogo" type="string" immediate="true">
|
||||
<events>
|
||||
<valueChange>
|
||||
<script language="JavaScript">
|
||||
<![CDATA[
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</valueChange>
|
||||
</events>
|
||||
</TextField>
|
||||
<ButtonWidget id="btnPesquisar" caption="Pesquisar" defaultIcon="SEARCH" style="BLACK">
|
||||
<onClickScript language="JavaScript">
|
||||
<![CDATA[ ]]>
|
||||
</onClickScript>
|
||||
</ButtonWidget>
|
||||
</HorizontalLayout>
|
||||
<DBTable id="dbtJogos" align="MIDDLE_CENTER" width="100%" height="100%" type="string" expandRatio="0.5" showRowCount="true" drawRefreshButton="true" gridSelectable="true" >
|
||||
<datasource>
|
||||
<sqlBuilderDataSource connection-key="" language="JavaScript">
|
||||
|
||||
</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="AVALIAÇÕES" align="CENTER">
|
||||
<scriptColumnGenerator language="JavaScript">
|
||||
<![CDATA[ ]]>
|
||||
</scriptColumnGenerator>
|
||||
</generated>
|
||||
<generated name="EDITAR" caption="EDITAR" align="CENTER">
|
||||
<scriptColumnGenerator language="JavaScript">
|
||||
<![CDATA[ ]]>
|
||||
</scriptColumnGenerator>
|
||||
</generated>
|
||||
<generated name="EXCLUIR" caption="EXCLUIR" align="CENTER">
|
||||
<scriptColumnGenerator language="JavaScript">
|
||||
<![CDATA[ ]]>
|
||||
</scriptColumnGenerator>
|
||||
</generated>
|
||||
</columns>
|
||||
</DBTable>
|
||||
<HorizontalLayout align="MIDDLE_RIGHT" spacing="true">
|
||||
<ButtonWidget id="btnNovoJogo" caption="Novo Jogo" defaultIcon="ADD" style="GREEN">
|
||||
<onClickScript language="JavaScript">
|
||||
<![CDATA[ ]]>
|
||||
</onClickScript>
|
||||
</ButtonWidget>
|
||||
<ButtonWidget id="btnVerAvaliacoes" caption="Ver Avaliações" defaultIcon="STAR" style="BLUE">
|
||||
<onClickScript language="JavaScript">
|
||||
<![CDATA[ ]]>
|
||||
</onClickScript>
|
||||
</ButtonWidget>
|
||||
</HorizontalLayout>
|
||||
</VerticalLayout>
|
||||
</Section>
|
||||
</CrudPanel>
|
||||
<CrudPanel id="pnlCadastroJogo" width="100%" height="100%" visible="false">
|
||||
<Header>
|
||||
<Caption> Cadastro de um novo jogo</Caption>
|
||||
<SubCaption>Cadastro de jogo</SubCaption>
|
||||
</Header>
|
||||
<Section caption="Cadastro de novo Jogo" subCaption="Insira os dados do jogo" width="100%" height="100%" >
|
||||
<VerticalLayout width="100%" height="100%" align="MIDDLE_CENTER" spacing="true">
|
||||
<Panel id="pnlCadastroJogo" width="100%" height="100%" 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"/>
|
||||
<ComboBox id="cbbGenero" type="string" caption="Gênero" width="100%" required="true">
|
||||
<entry key="ACAO" value="Ação"/>
|
||||
<entry key="AVENTURA" value="Aventura"/>
|
||||
<entry key="RPG" value="RPG"/>
|
||||
<entry key="ESPORTES" value="Esportes"/>
|
||||
<entry key="ESTRATEGIA" value="Estratégia"/>
|
||||
<entry key="CORRIDA" value="Corrida"/>
|
||||
<entry key="Sobrevivencia" value="Sobrevivência"/>
|
||||
</ComboBox>
|
||||
<TextField id="txfAnoLancamento" caption="Ano de Lançamento" type="number" width="100%" required="true">
|
||||
<validation>
|
||||
<script language="JavaScript">
|
||||
<![CDATA[
|
||||
function validate() {
|
||||
var ano = this.getValue();
|
||||
var anoAtual = new Date().getFullYear();
|
||||
if (ano < 1950 || ano > anoAtual) {
|
||||
throw new Error("Ano de lançamento inválido. Deve estar entre 1950 e " + anoAtual);
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
</validation>
|
||||
</TextField>
|
||||
<TextField id="txfProdutora" caption="Produtora" type="string" width="100%" required="true" maxLength="50"/>
|
||||
<TextArea id="txaDescricao" caption="Descrição" type="string" width="100%" required="true" maxLength="500"/>
|
||||
</VerticalLayout>
|
||||
</Panel>
|
||||
<HorizontalLayout align="MIDDLE_RIGHT" spacing="true" >
|
||||
<ButtonWidget id="btnVoltar" caption="Voltar" defaultIcon="BACK" style="BLACK">
|
||||
<onClickScript language="JavaScript">
|
||||
<![CDATA[ ]]>
|
||||
</onClickScript>
|
||||
</ButtonWidget>
|
||||
<ButtonWidget id="btnLimpar" caption="Limpar" defaultIcon="REMOVE" style="BLUE">
|
||||
<onClickScript language="JavaScript">
|
||||
<![CDATA[ ]]>
|
||||
</onClickScript>
|
||||
</ButtonWidget>
|
||||
<ButtonWidget id="btnSalvarJogo" caption="Salvar" defaultIcon="SAVE" style="GREEN">
|
||||
<onClickScript language="JavaScript">
|
||||
<![CDATA[ ]]>
|
||||
</onClickScript>
|
||||
</ButtonWidget>
|
||||
</HorizontalLayout>
|
||||
</VerticalLayout>
|
||||
</Section>
|
||||
|
||||
</CrudPanel>
|
||||
</VerticalLayout>
|
||||
|
||||
</components>
|
||||
</form>
|
||||
</panel-form>
|
||||
+4
-4
@@ -10,8 +10,8 @@
|
||||
},
|
||||
"panels": [
|
||||
{
|
||||
"key": "my-panel",
|
||||
"name": "Meu Painel",
|
||||
"key": "cadastro_jogos",
|
||||
"name": "Cadastro de Jogos",
|
||||
"description": "Descrição curta do que este painel faz.",
|
||||
"category": "Categoria/Subcategoria",
|
||||
"displayOrder": 1,
|
||||
@@ -24,8 +24,8 @@
|
||||
],
|
||||
"allowedUsers": [],
|
||||
"forms": {
|
||||
"desktop": "panels/my-panel/my-panel-desktop.xml",
|
||||
"mobile": "panels/my-panel/my-panel-mobile.xml",
|
||||
"desktop": "panels/cadastro_jogos-desktop.xml",
|
||||
"mobile": "panels/cadastro_jogos-mobile.xml",
|
||||
"mobileAlternative": null
|
||||
},
|
||||
"defaultState": "panels/my-panel/default-state.json",
|
||||
|
||||
Reference in New Issue
Block a user