refactor: add Nota Média field and improve form layout in cadastro_jogos desktop XML
davinTI/jogos_matheus/pipeline/head There was a failure building this commit
davinTI/jogos_matheus/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
<form width="100%" height="100%" formKey="formTeste">
|
||||
<description></description>
|
||||
<initScript language="JavaScript">
|
||||
<![CDATA[
|
||||
@@ -20,6 +20,7 @@
|
||||
'GENERO',
|
||||
'ANO_LANCAMENTO',
|
||||
'PRODUTORA',
|
||||
'NOTA_MEDIA',
|
||||
'DESCRICAO'
|
||||
],
|
||||
camposTable: [
|
||||
@@ -28,6 +29,7 @@
|
||||
'GENERO',
|
||||
'ANO_LANCAMENTO',
|
||||
'PRODUTORA',
|
||||
'NOTA_MEDIA',
|
||||
'DESCRICAO'
|
||||
],
|
||||
},
|
||||
@@ -37,6 +39,7 @@
|
||||
['GENERO', 'cbbGenero', 'String'],
|
||||
['ANO_LANCAMENTO', 'txfAnoLancamento', 'Number'],
|
||||
['PRODUTORA', 'txfProdutora', 'String'],
|
||||
['NOTA_MEDIA', 'txfNotaMedia', 'Number'],
|
||||
['DESCRICAO', 'txaDescricao', 'String']
|
||||
],
|
||||
validacaoExclusao: [],
|
||||
@@ -103,7 +106,7 @@
|
||||
engine.getField("txfEmail").setValue("");
|
||||
engine.getField("txfComentario").setValue("");
|
||||
engine.getField("dcfNota").setValue("");
|
||||
engine.getField("dtfDataAvaliacao").setValue(null);
|
||||
|
||||
}
|
||||
|
||||
function resetPanelGames(){
|
||||
@@ -116,7 +119,6 @@
|
||||
engine.getField("txfNotaMedia").setValue("");
|
||||
}
|
||||
|
||||
|
||||
function organizeRequiredFields(whichForm, isToRequest) {
|
||||
var fields = [];
|
||||
if(whichForm === "jogos"){
|
||||
@@ -140,6 +142,7 @@
|
||||
}
|
||||
});
|
||||
}};
|
||||
|
||||
function showTableReviews(gameId) {
|
||||
if(!gameId) {
|
||||
var lib_msg = libService.loadScript("messages");
|
||||
@@ -192,37 +195,13 @@
|
||||
caption="Comentário" required="true" />
|
||||
<DecimalField width="100%" id="dcfNota" type="decimal"
|
||||
caption="Nota (0 a 10)"
|
||||
required="true">
|
||||
<validation>
|
||||
<script language="JavaScript">
|
||||
<![CDATA[
|
||||
function validator(){
|
||||
this.getMessage = function(){
|
||||
return "A nota deve ser um número entre 0 e 10.";
|
||||
};
|
||||
this.isValid = function(){
|
||||
if(!engine.getField("dcfNota").isRequired()){
|
||||
return true;
|
||||
}
|
||||
var value = engine.getField("dcfNota").getValue();
|
||||
if(value === null || value === ""){
|
||||
return true;
|
||||
}
|
||||
return value >= 0 && value <= 10;
|
||||
};
|
||||
}
|
||||
var script = new validator();
|
||||
]]>
|
||||
</script>
|
||||
</validation>
|
||||
</DecimalField>
|
||||
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();
|
||||
@@ -230,14 +209,16 @@
|
||||
engine.getField("dtfDataAvaliacao").setValue(javaDate);
|
||||
|
||||
if(engine.isValid()){
|
||||
|
||||
engine.getField("txfCodigoJogo").setValue(engine.getField("dbtJogos").getValue());
|
||||
var config_avaliacoes = engine.getGlobalVariable("config_avaliacoes");
|
||||
var lib = libService.loadScript("lib_cadastro_padrao");
|
||||
var lib_msg = libService.loadScript("messages");
|
||||
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({
|
||||
@@ -246,16 +227,11 @@
|
||||
msg: "Avaliação foi salva com sucesso!",
|
||||
position: lib_msg.notificationPosition.bottom_right,
|
||||
});
|
||||
engine.getLayout("wltCriarAvaliacoes").closeWindow();
|
||||
engine.getLayout("wltListaAvaliacoes").showWindow();
|
||||
} else {
|
||||
lib_msg.showNotification({
|
||||
type: lib_msg.notificationType.tray,
|
||||
caption: "Erro!",
|
||||
msg: "Não foi possível salvar a avaliação.",
|
||||
position: lib_msg.notificationPosition.bottom_right,
|
||||
});
|
||||
}
|
||||
}
|
||||
engine.getLayout("wltCriarAvaliacoes").closeWindow();
|
||||
engine.getLayout("wltListaAvaliacoes").showWindow();
|
||||
engine.getGlobalVariable("organizeRequiredFields")("jogos", true);
|
||||
|
||||
}
|
||||
}
|
||||
]]>
|
||||
@@ -270,7 +246,7 @@
|
||||
<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%"
|
||||
gridSelectable="true" selectable="true" height="100%"
|
||||
expandRatio="0.2" showRowCount="true">
|
||||
<datasource>
|
||||
<sqlBuilderDataSource connection-key="vitruvio" language="JavaScript">
|
||||
@@ -279,10 +255,7 @@
|
||||
var sqlBase = "SELECT * FROM TB_MATHEUS_MEDEIROS_AVALIACOES ORDER BY CODIGO";
|
||||
var id_jogo = engine.getField("dbtJogos").getValue();
|
||||
if(id_jogo != null){
|
||||
id_jogo = parseInt(id_jogo, 10);
|
||||
if(!isNaN(id_jogo)){
|
||||
sqlBase = "SELECT * FROM TB_MATHEUS_MEDEIROS_AVALIACOES WHERE ID_JOGO = " + id_jogo + " ORDER BY CODIGO";
|
||||
}
|
||||
sqlBase = "SELECT * FROM TB_MATHEUS_MEDEIROS_AVALIACOES WHERE ID_JOGO = " + id_jogo + " ORDER BY CODIGO";
|
||||
}
|
||||
return sqlBase;
|
||||
}
|
||||
@@ -300,55 +273,63 @@
|
||||
<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 () {
|
||||
engine.getField("txfCodigoAvaliacao").setValue(itemId);
|
||||
if (itemId != null) {
|
||||
engine.getLayout("wltCriarAvaliacoes").showWindow();
|
||||
engine.getLayout("wltListaAvaliacoes").closeWindow();
|
||||
var config_avaliacoes = engine.getGlobalVariable('config_avaliacoes');
|
||||
var lib = libService.loadScript('lib_cadastro_padrao');
|
||||
lib.fncCarregarCampos(config_avaliacoes, itemId);
|
||||
}
|
||||
}, "pencil");
|
||||
return btn;
|
||||
}
|
||||
}
|
||||
var script = new Generator();
|
||||
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()) {
|
||||
lib.fncDeletarRegistro(config_avaliacoes, itemId);
|
||||
engine.getField("dbtAvaliacoes").refresh();
|
||||
engine.getField("dbtJogos").refresh();
|
||||
}
|
||||
});
|
||||
}, "trash");
|
||||
return btn;
|
||||
}
|
||||
}
|
||||
var script = new Generator();
|
||||
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()) {
|
||||
lib.fncDeletarRegistro(config_avaliacoes, itemId);
|
||||
engine.getField("dbtAvaliacoes").refresh();
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
"trash",
|
||||
);
|
||||
return btn;
|
||||
}
|
||||
}
|
||||
var script = new Generator();
|
||||
]]>
|
||||
</scriptColumnGenerator>
|
||||
</generated>
|
||||
@@ -376,14 +357,18 @@
|
||||
</WindowLayout>
|
||||
|
||||
<CrudPanel id="pnlListaJogos" width="100%" height="100%" visible="true">
|
||||
<Header>
|
||||
<Caption>Lista de jogos</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="txfPesquisa" expandRatio="0.8" width="100%" caption="Pesquisar jogo" type="string" immediate="true">
|
||||
<Header backgroundColor="ORANGE">
|
||||
<Caption>Cadastro de Jogos</Caption>
|
||||
<SubCaption>Cadastro de jogos</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="txfPesquisa"
|
||||
caption="Pesquise pelo nome do jogo" type="string"
|
||||
immediate="true">
|
||||
<events>
|
||||
<valueChange>
|
||||
<script language="JavaScript">
|
||||
@@ -407,7 +392,7 @@
|
||||
</onClickScript>
|
||||
</ButtonWidget>
|
||||
</HorizontalLayout>
|
||||
<DBTable id="dbtJogos" align="MIDDLE_CENTER" width="100%" height="100%" type="string" expandRatio="0.5" showRowCount="true" drawRefreshButton="true" gridSelectable="true" >
|
||||
<DBTable id="dbtJogos" align="MIDDLE_CENTER" width="100%" height="100%" type="string" expandRatio="0.5" showRowCount="true" drawRefreshButton="true" gridSelectable="true" selectable="true">
|
||||
<datasource>
|
||||
<sqlBuilderDataSource connection-key="vitruvio" language="JavaScript">
|
||||
<![CDATA[
|
||||
@@ -417,8 +402,7 @@
|
||||
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) {
|
||||
var safe = ("" + txfPesquisa).replace(/'/g, "''");
|
||||
sqlBase += " WHERE UPPER(J.TITULO) LIKE UPPER('%" + safe + "%')";
|
||||
sqlBase += " WHERE UPPER(J.TITULO) LIKE UPPER('%" + txfPesquisa + "%')";
|
||||
}
|
||||
|
||||
sqlBase += " GROUP BY J.CODIGO, J.TITULO, J.GENERO, J.ANO_LANCAMENTO, J.PRODUTORA, J.DESCRICAO";
|
||||
@@ -492,7 +476,7 @@
|
||||
function () {
|
||||
var lib = engine.getGlobalVariable("lib_cadastro_padrao");
|
||||
var config_jogos = engine.getGlobalVariable("config_jogos");
|
||||
var registro = itemId + " - " + item.getItemProperty("TITULO");
|
||||
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(
|
||||
@@ -526,7 +510,6 @@
|
||||
<onClickScript language="JavaScript">
|
||||
<![CDATA[
|
||||
function run (){
|
||||
engine.getGlobalVariable("resetPanelGames")();
|
||||
engine.getGlobalVariable("changeCrudPanel")("cadastroJogo");
|
||||
}
|
||||
]]>
|
||||
@@ -554,12 +537,12 @@
|
||||
</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="pnlDadosJogo" width="100%" expandRatio="0.7" height="100%" margin="true" >
|
||||
<Panel id="pnlDadosJogo" 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" minLength="3"/>
|
||||
<ComboBox id="cbbGenero" type="string" caption="Gênero" width="100%" required="true">
|
||||
<ComboBox id="cbbGenero" type="string" caption="Gênero" updatable="false" allowNullSelection="true" width="100%" required="true">
|
||||
<entry key="ACAO" value="Ação"/>
|
||||
<entry key="AVENTURA" value="Aventura"/>
|
||||
<entry key="RPG" value="RPG"/>
|
||||
@@ -597,10 +580,10 @@
|
||||
</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"/>
|
||||
<TextArea id="txaDescricao" caption="Descrição" type="string" width="100%" maxLength="500"/>
|
||||
</VerticalLayout>
|
||||
</Panel>
|
||||
<HorizontalLayout align="MIDDLE_RIGHT" expandRatio="0.3" spacing="true" >
|
||||
<HorizontalLayout align="MIDDLE_RIGHT" spacing="true" >
|
||||
<ButtonWidget id="btnVoltar" caption="Voltar" defaultIcon="BACK" style="BLACK">
|
||||
<onClickScript language="JavaScript">
|
||||
<![CDATA[
|
||||
@@ -629,10 +612,10 @@
|
||||
if(engine.isValid()){
|
||||
var config_jogos = engine.getGlobalVariable("config_jogos");
|
||||
var lib = libService.loadScript("lib_cadastro_padrao");
|
||||
var lib_msg = libService.loadScript("messages");
|
||||
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");
|
||||
@@ -642,14 +625,7 @@
|
||||
msg: "O jogo foi gravado com sucesso!",
|
||||
position: lib_msg.notificationPosition.bottom_right,
|
||||
});
|
||||
} else {
|
||||
lib_msg.showNotification({
|
||||
type: lib_msg.notificationType.tray,
|
||||
caption: "Erro!",
|
||||
msg: "Não foi possível gravar o jogo.",
|
||||
position: lib_msg.notificationPosition.bottom_right,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
@@ -664,4 +640,4 @@
|
||||
|
||||
</components>
|
||||
</form>
|
||||
</panel-form>
|
||||
</panel-form>
|
||||
|
||||
Reference in New Issue
Block a user