Compare commits
2
Commits
a0f3d94de8
...
c4fce638ca
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4fce638ca | ||
|
|
6891f63534 |
@@ -11,8 +11,8 @@
|
|||||||
tabela:
|
tabela:
|
||||||
{
|
{
|
||||||
conexao : 'vitruvio',
|
conexao : 'vitruvio',
|
||||||
nome : '',
|
nome : 'TB_MATHEUS_MEDEIROS_JOGOS',
|
||||||
sequence : '',
|
sequence : 'TB_MATHEUS_MEDEIROS_JOGOS_SEQ',
|
||||||
idTabela : 'CODIGO',
|
idTabela : 'CODIGO',
|
||||||
campos: [
|
campos: [
|
||||||
'CODIGO',
|
'CODIGO',
|
||||||
@@ -20,7 +20,6 @@
|
|||||||
'GENERO',
|
'GENERO',
|
||||||
'ANO_LANCAMENTO',
|
'ANO_LANCAMENTO',
|
||||||
'PRODUTORA',
|
'PRODUTORA',
|
||||||
'NOTA_MEDIA',
|
|
||||||
'DESCRICAO'
|
'DESCRICAO'
|
||||||
],
|
],
|
||||||
camposTable: [
|
camposTable: [
|
||||||
@@ -29,7 +28,6 @@
|
|||||||
'GENERO',
|
'GENERO',
|
||||||
'ANO_LANCAMENTO',
|
'ANO_LANCAMENTO',
|
||||||
'PRODUTORA',
|
'PRODUTORA',
|
||||||
'NOTA_MEDIA',
|
|
||||||
'DESCRICAO'
|
'DESCRICAO'
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -39,7 +37,6 @@
|
|||||||
['GENERO', 'cbbGenero', 'String'],
|
['GENERO', 'cbbGenero', 'String'],
|
||||||
['ANO_LANCAMENTO', 'txfAnoLancamento', 'Number'],
|
['ANO_LANCAMENTO', 'txfAnoLancamento', 'Number'],
|
||||||
['PRODUTORA', 'txfProdutora', 'String'],
|
['PRODUTORA', 'txfProdutora', 'String'],
|
||||||
['NOTA_MEDIA', 'txfNotaMedia', 'Number'],
|
|
||||||
['DESCRICAO', 'txaDescricao', 'String']
|
['DESCRICAO', 'txaDescricao', 'String']
|
||||||
],
|
],
|
||||||
validacaoExclusao: [],
|
validacaoExclusao: [],
|
||||||
@@ -51,8 +48,8 @@
|
|||||||
var config_avaliacoes = {
|
var config_avaliacoes = {
|
||||||
tabela: {
|
tabela: {
|
||||||
conexao : 'vitruvio',
|
conexao : 'vitruvio',
|
||||||
nome : '',
|
nome : 'TB_MATHEUS_MEDEIROS_AVALIACOES',
|
||||||
sequence : '',
|
sequence : 'TB_MATHEUS_MEDEIROS_AVALIACOES_SEQ',
|
||||||
idTabela : 'CODIGO',
|
idTabela : 'CODIGO',
|
||||||
campos: [
|
campos: [
|
||||||
'CODIGO',
|
'CODIGO',
|
||||||
@@ -106,7 +103,7 @@
|
|||||||
engine.getField("txfEmail").setValue("");
|
engine.getField("txfEmail").setValue("");
|
||||||
engine.getField("txfComentario").setValue("");
|
engine.getField("txfComentario").setValue("");
|
||||||
engine.getField("dcfNota").setValue("");
|
engine.getField("dcfNota").setValue("");
|
||||||
|
engine.getField("dtfDataAvaliacao").setValue(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetPanelGames(){
|
function resetPanelGames(){
|
||||||
@@ -119,29 +116,26 @@
|
|||||||
engine.getField("txfNotaMedia").setValue("");
|
engine.getField("txfNotaMedia").setValue("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gerencia apenas os campos de negócio obrigatórios.
|
||||||
|
* Os campos de ID (CODIGO) NÃO entram aqui, pois são
|
||||||
|
* gerados automaticamente e ficariam vazios em uma inclusão.
|
||||||
|
*/
|
||||||
function organizeRequiredFields(whichForm, isToRequest) {
|
function organizeRequiredFields(whichForm, isToRequest) {
|
||||||
var fields = [];
|
var fields = [];
|
||||||
if(whichForm === "jogos"){
|
if(whichForm === "jogos"){
|
||||||
fields = ["txfCodigo", "txfTitulo", "cbbGenero", "txfAnoLancamento", "txfProdutora", "txaDescricao"];
|
fields = ["txfTitulo", "cbbGenero", "txfAnoLancamento", "txfProdutora", "txaDescricao"];
|
||||||
} else if(whichForm === "avaliacoes") {
|
} else if(whichForm === "avaliacoes") {
|
||||||
fields = ["txfCodigoAvaliacao", "txfCodigoJogo", "txfNome", "txfEmail", "txfComentario", "dcfNota"];
|
fields = ["txfNome", "txfEmail", "txfComentario", "dcfNota"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isToRequest) {
|
fields.forEach(function(fieldId) {
|
||||||
fields.forEach(function(fieldId) {
|
var field = engine.getField(fieldId);
|
||||||
var field = engine.getField(fieldId);
|
if (field) {
|
||||||
if (field) {
|
field.setRequired(isToRequest);
|
||||||
field.setRequired(true);
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
} else {
|
|
||||||
fields.forEach(function(fieldId) {
|
|
||||||
var field = engine.getField(fieldId);
|
|
||||||
if (field) {
|
|
||||||
field.setRequired(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}};
|
|
||||||
|
|
||||||
function showTableReviews(gameId) {
|
function showTableReviews(gameId) {
|
||||||
if(!gameId) {
|
if(!gameId) {
|
||||||
@@ -172,21 +166,229 @@
|
|||||||
|
|
||||||
</initScript>
|
</initScript>
|
||||||
<components>
|
<components>
|
||||||
<VerticalLayout width="100%" height="100%" >
|
<VerticalLayout width="100%" height="100%" align="MIDDLE_RIGHT">
|
||||||
<CrudPanel width="100%" height="100%" visible="true">
|
|
||||||
|
<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">
|
||||||
|
<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; /* obrigatoriedade tratada pelo required */
|
||||||
|
}
|
||||||
|
return value >= 0 && value <= 10;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var script = new validator();
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
</validation>
|
||||||
|
</DecimalField>
|
||||||
|
<ButtonWidget id="btnSalvarAvaliacao" caption="Salvar" defaultIcon="SAVE"
|
||||||
|
style="BLUE">
|
||||||
|
<onClickScript language="JavaScript">
|
||||||
|
<![CDATA[
|
||||||
|
function run() {
|
||||||
|
engine.getGlobalVariable("organizeRequiredFields")("avaliacoes", true);
|
||||||
|
|
||||||
|
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()){
|
||||||
|
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) {
|
||||||
|
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();
|
||||||
|
} 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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</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 sqlBase = "SELECT * FROM TB_MATHEUS_MEDEIROS_AVALIACOES ORDER BY CODIGO";
|
||||||
|
var id_jogo = engine.getField("dbtJogos").getValue();
|
||||||
|
if(id_jogo != null){
|
||||||
|
/* Cast numérico para evitar injeção via concatenação */
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 () {
|
||||||
|
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();
|
||||||
|
]]>
|
||||||
|
</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();
|
||||||
|
]]>
|
||||||
|
</scriptColumnGenerator>
|
||||||
|
</generated>
|
||||||
|
</columns>
|
||||||
|
</DBTable>
|
||||||
|
<HorizontalLayout spacing="true" align="MIDDLE_RIGHT">
|
||||||
|
<ButtonWidget id="btnVoltarAvaliacoes" style="BLACK" caption="Voltar" defaultIcon="BACK">
|
||||||
|
<onClickScript language="JavaScript"><![CDATA[
|
||||||
|
function run() {
|
||||||
|
engine.getLayout("wltListaAvaliacoes").closeWindow();
|
||||||
|
}
|
||||||
|
]]></onClickScript>
|
||||||
|
</ButtonWidget>
|
||||||
|
<ButtonWidget id="btnAdicionarAvaliacoes" style="GREEN" caption="Nova Avaliação" 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>
|
<Header>
|
||||||
<Caption></Caption>
|
<Caption>Lista de jogos</Caption>
|
||||||
<SubCaption>Cadastro de jogos</SubCaption>
|
<SubCaption>Cadastro de jogos</SubCaption>
|
||||||
</Header>
|
</Header>
|
||||||
<Section height="100%" width="100%" caption="Jogos" subCaption="Veja todos os jogos" id = "secJogos">
|
<Section height="100%" width="100%" caption="Jogos" subCaption="Veja todos os jogos" id = "secJogos">
|
||||||
<VerticalLayout height="100%" width="100%" align="MIDDLE_CENTER" spacing="true">
|
<VerticalLayout height="100%" width="100%" align="MIDDLE_CENTER" spacing="true">
|
||||||
<HorizontalLayout width="100%" spacing="true">
|
<HorizontalLayout width="100%" spacing="true">
|
||||||
<TextField id="txfPesquisaJogo" expandRatio="0.8" width="100%" caption="Pesquisar jogo" type="string" immediate="true">
|
<TextField id="txfPesquisa" expandRatio="0.8" width="100%" caption="Pesquisar jogo" type="string" immediate="true">
|
||||||
<events>
|
<events>
|
||||||
<valueChange>
|
<valueChange>
|
||||||
<script language="JavaScript">
|
<script language="JavaScript">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
function run() {
|
||||||
|
engine.getField("dbtJogos").refresh();
|
||||||
|
}
|
||||||
]]>
|
]]>
|
||||||
</script>
|
</script>
|
||||||
</valueChange>
|
</valueChange>
|
||||||
@@ -194,14 +396,37 @@
|
|||||||
</TextField>
|
</TextField>
|
||||||
<ButtonWidget id="btnPesquisar" caption="Pesquisar" defaultIcon="SEARCH" style="BLACK">
|
<ButtonWidget id="btnPesquisar" caption="Pesquisar" defaultIcon="SEARCH" style="BLACK">
|
||||||
<onClickScript language="JavaScript">
|
<onClickScript language="JavaScript">
|
||||||
<![CDATA[ ]]>
|
<![CDATA[
|
||||||
|
function run() {
|
||||||
|
engine.getField("dbtJogos").refresh();
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
|
||||||
</onClickScript>
|
</onClickScript>
|
||||||
</ButtonWidget>
|
</ButtonWidget>
|
||||||
</HorizontalLayout>
|
</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" >
|
||||||
<datasource>
|
<datasource>
|
||||||
<sqlBuilderDataSource connection-key="" language="JavaScript">
|
<sqlBuilderDataSource connection-key="vitruvio" language="JavaScript">
|
||||||
|
<![CDATA[
|
||||||
|
function buildSQL(_){
|
||||||
|
var txfPesquisa = engine.getField("txfPesquisa").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) {
|
||||||
|
/* Escapa aspas simples para mitigar SQL Injection.
|
||||||
|
O ideal é usar bind/parâmetro do framework. */
|
||||||
|
var safe = ("" + txfPesquisa).replace(/'/g, "''");
|
||||||
|
sqlBase += " WHERE UPPER(J.TITULO) LIKE UPPER('%" + safe + "%')";
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlBase += " GROUP BY J.CODIGO, J.TITULO, J.GENERO, J.ANO_LANCAMENTO, J.PRODUTORA, J.DESCRICAO";
|
||||||
|
sqlBase += " ORDER BY J.CODIGO";
|
||||||
|
|
||||||
|
return sqlBase;
|
||||||
|
}
|
||||||
|
]]>
|
||||||
</sqlBuilderDataSource>
|
</sqlBuilderDataSource>
|
||||||
</datasource>
|
</datasource>
|
||||||
<key-field>
|
<key-field>
|
||||||
@@ -217,17 +442,81 @@
|
|||||||
<column name="DESCRICAO" caption="DESCRIÇÃO" />
|
<column name="DESCRICAO" caption="DESCRIÇÃO" />
|
||||||
<generated name="AVALIACOES" caption="AVALIAÇÕES" align="CENTER">
|
<generated name="AVALIACOES" caption="AVALIAÇÕES" align="CENTER">
|
||||||
<scriptColumnGenerator language="JavaScript">
|
<scriptColumnGenerator language="JavaScript">
|
||||||
<![CDATA[ ]]>
|
<![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();
|
||||||
|
engine.getGlobalVariable("showTableReviews")(itemId);
|
||||||
|
}, "star");
|
||||||
|
return btn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var script = new Generator();
|
||||||
|
]]>
|
||||||
</scriptColumnGenerator>
|
</scriptColumnGenerator>
|
||||||
</generated>
|
</generated>
|
||||||
<generated name="EDITAR" caption="EDITAR" align="CENTER">
|
<generated name="EDITAR" caption="EDITAR" align="CENTER">
|
||||||
<scriptColumnGenerator language="JavaScript">
|
<scriptColumnGenerator language="JavaScript">
|
||||||
<![CDATA[ ]]>
|
<![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');
|
||||||
|
lib.fncCarregarCampos(config_jogos, id);
|
||||||
|
}
|
||||||
|
}, "pencil");
|
||||||
|
return btn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var script = new Generator();
|
||||||
|
]]>
|
||||||
</scriptColumnGenerator>
|
</scriptColumnGenerator>
|
||||||
</generated>
|
</generated>
|
||||||
<generated name="EXCLUIR" caption="EXCLUIR" align="CENTER">
|
<generated name="EXCLUIR" caption="EXCLUIR" align="CENTER">
|
||||||
<scriptColumnGenerator language="JavaScript">
|
<scriptColumnGenerator language="JavaScript">
|
||||||
<![CDATA[ ]]>
|
<![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()) {
|
||||||
|
lib.fncDeletarRegistro(config_jogos, itemId);
|
||||||
|
engine.getField("dbtJogos").refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
"trash",
|
||||||
|
);
|
||||||
|
return btn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var script = new Generator();
|
||||||
|
]]>
|
||||||
</scriptColumnGenerator>
|
</scriptColumnGenerator>
|
||||||
</generated>
|
</generated>
|
||||||
</columns>
|
</columns>
|
||||||
@@ -235,13 +524,24 @@
|
|||||||
<HorizontalLayout align="MIDDLE_RIGHT" spacing="true">
|
<HorizontalLayout align="MIDDLE_RIGHT" spacing="true">
|
||||||
<ButtonWidget id="btnNovoJogo" caption="Novo Jogo" defaultIcon="ADD" style="GREEN">
|
<ButtonWidget id="btnNovoJogo" caption="Novo Jogo" defaultIcon="ADD" style="GREEN">
|
||||||
<onClickScript language="JavaScript">
|
<onClickScript language="JavaScript">
|
||||||
<![CDATA[ ]]>
|
<![CDATA[
|
||||||
</onClickScript>
|
function run (){
|
||||||
|
engine.getGlobalVariable("resetPanelGames")();
|
||||||
|
engine.getGlobalVariable("changeCrudPanel")("cadastroJogo");
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</onClickScript>
|
||||||
</ButtonWidget>
|
</ButtonWidget>
|
||||||
<ButtonWidget id="btnVerAvaliacoes" caption="Ver Avaliações" defaultIcon="STAR" style="BLUE">
|
<ButtonWidget id="btnVerAvaliacoes" caption="Ver Avaliações" defaultIcon="STAR" style="BLUE">
|
||||||
<onClickScript language="JavaScript">
|
<onClickScript language="JavaScript">
|
||||||
<![CDATA[ ]]>
|
<![CDATA[
|
||||||
</onClickScript>
|
function run (){
|
||||||
|
engine.getField("dbtAvaliacoes").refresh();
|
||||||
|
var idJogoSelecionado = engine.getField("dbtJogos").getValue();
|
||||||
|
engine.getGlobalVariable("showTableReviews")(idJogoSelecionado);
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</onClickScript>
|
||||||
</ButtonWidget>
|
</ButtonWidget>
|
||||||
</HorizontalLayout>
|
</HorizontalLayout>
|
||||||
</VerticalLayout>
|
</VerticalLayout>
|
||||||
@@ -254,11 +554,11 @@
|
|||||||
</Header>
|
</Header>
|
||||||
<Section caption="Cadastro de novo Jogo" subCaption="Insira os dados do jogo" width="100%" height="100%" >
|
<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">
|
<VerticalLayout width="100%" height="100%" align="MIDDLE_CENTER" spacing="true">
|
||||||
<Panel id="pnlCadastroJogo" width="100%" height="100%" margin="true" >
|
<Panel id="pnlDadosJogo" width="100%" height="100%" margin="true" >
|
||||||
<VerticalLayout caption="Dados do Jogo" width="100%" spacing="true">
|
<VerticalLayout caption="Dados do Jogo" width="100%" spacing="true">
|
||||||
<TextField id="txfCodigo" caption="Código" type="number" width="100%" enabled="false" visible="false"/>
|
<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"/>
|
<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"/>
|
<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" width="100%" required="true">
|
||||||
<entry key="ACAO" value="Ação"/>
|
<entry key="ACAO" value="Ação"/>
|
||||||
<entry key="AVENTURA" value="Aventura"/>
|
<entry key="AVENTURA" value="Aventura"/>
|
||||||
@@ -269,19 +569,32 @@
|
|||||||
<entry key="Sobrevivencia" value="Sobrevivência"/>
|
<entry key="Sobrevivencia" value="Sobrevivência"/>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
<TextField id="txfAnoLancamento" caption="Ano de Lançamento" type="number" width="100%" required="true">
|
<TextField id="txfAnoLancamento" caption="Ano de Lançamento" type="number" width="100%" required="true">
|
||||||
<validation>
|
<validation>
|
||||||
<script language="JavaScript">
|
<script language="JavaScript">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
function validate() {
|
function validator(){
|
||||||
var ano = this.getValue();
|
|
||||||
var anoAtual = new Date().getFullYear();
|
|
||||||
if (ano < 1950 || ano > anoAtual) {
|
this.getMessage = function(){
|
||||||
throw new Error("Ano de lançamento inválido. Deve estar entre 1950 e " + anoAtual);
|
return "O ano de lançamento deve ser um número válido entre 1970 e o ano atual.";
|
||||||
}
|
};
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</script>
|
this.isValid = function(){
|
||||||
</validation>
|
|
||||||
|
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>
|
||||||
<TextField id="txfProdutora" caption="Produtora" type="string" width="100%" required="true" maxLength="50"/>
|
<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%" required="true" maxLength="500"/>
|
||||||
@@ -290,18 +603,57 @@
|
|||||||
<HorizontalLayout align="MIDDLE_RIGHT" spacing="true" >
|
<HorizontalLayout align="MIDDLE_RIGHT" spacing="true" >
|
||||||
<ButtonWidget id="btnVoltar" caption="Voltar" defaultIcon="BACK" style="BLACK">
|
<ButtonWidget id="btnVoltar" caption="Voltar" defaultIcon="BACK" style="BLACK">
|
||||||
<onClickScript language="JavaScript">
|
<onClickScript language="JavaScript">
|
||||||
<![CDATA[ ]]>
|
<![CDATA[
|
||||||
</onClickScript>
|
function run() {
|
||||||
|
engine.getGlobalVariable("changeCrudPanel")("listaJogos");
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</onClickScript>
|
||||||
</ButtonWidget>
|
</ButtonWidget>
|
||||||
<ButtonWidget id="btnLimpar" caption="Limpar" defaultIcon="REMOVE" style="BLUE">
|
<ButtonWidget id="btnLimpar" caption="Limpar" defaultIcon="REMOVE" style="BLUE">
|
||||||
<onClickScript language="JavaScript">
|
<onClickScript language="JavaScript">
|
||||||
<![CDATA[ ]]>
|
<![CDATA[
|
||||||
</onClickScript>
|
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>
|
||||||
<ButtonWidget id="btnSalvarJogo" caption="Salvar" defaultIcon="SAVE" style="GREEN">
|
<ButtonWidget id="btnSalvarJogo" caption="Salvar" defaultIcon="SAVE" style="GREEN">
|
||||||
<onClickScript language="JavaScript">
|
<onClickScript language="JavaScript">
|
||||||
<![CDATA[ ]]>
|
<![CDATA[
|
||||||
</onClickScript>
|
function run() {
|
||||||
|
engine.getGlobalVariable("organizeRequiredFields")("jogos", true);
|
||||||
|
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) {
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
} 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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</onClickScript>
|
||||||
</ButtonWidget>
|
</ButtonWidget>
|
||||||
</HorizontalLayout>
|
</HorizontalLayout>
|
||||||
</VerticalLayout>
|
</VerticalLayout>
|
||||||
|
|||||||
+68
-3
@@ -5,13 +5,78 @@
|
|||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
|
http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
|
||||||
|
|
||||||
<changeSet author="nome.usuario" id="id_unico_changeset">
|
|
||||||
|
|
||||||
|
<changeSet author="matheus.medeiros" id="matheus.medeiros-1">
|
||||||
<preConditions onError="WARN" onFail="MARK_RAN" onSqlOutput="IGNORE">
|
<preConditions onError="WARN" onFail="MARK_RAN" onSqlOutput="IGNORE">
|
||||||
<not>
|
<not>
|
||||||
<tableExists tableName="go_setor" />
|
<tableExists tableName="TB_MATHEUS_MEDEIROS_JOGOS" />
|
||||||
</not>
|
</not>
|
||||||
</preConditions>
|
</preConditions>
|
||||||
<sql endDelimiter=";" splitStatements="true" stripComments="false">CREATE TABLE tabela ()</sql>
|
|
||||||
|
<sql endDelimiter=";" splitStatements="true" stripComments="false">CREATE TABLE TB_MATHEUS_MEDEIROS_JOGOS (
|
||||||
|
CODIGO NUMBER(10) NOT NULL,
|
||||||
|
TITULO VARCHAR2(150) NOT NULL,
|
||||||
|
GENERO VARCHAR2(30) NOT NULL,
|
||||||
|
ANO_LANCAMENTO NUMBER(4) NOT NULL,
|
||||||
|
PRODUTORA VARCHAR2(50) NOT NULL,
|
||||||
|
DESCRICAO VARCHAR2(500) NOT NULL,
|
||||||
|
CONSTRAINT PK_MM_JOGOS PRIMARY KEY (CODIGO),
|
||||||
|
CONSTRAINT CK_MM_JOGOS_ANO
|
||||||
|
CHECK (ANO_LANCAMENTO BETWEEN 1970 AND EXTRACT(YEAR FROM SYSDATE)),
|
||||||
|
CHECK (TITULO BETWEEN 3 AND 100)
|
||||||
|
);
|
||||||
|
</sql>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="matheus.medeiros" id="matheus.medeiros-2">
|
||||||
|
<preConditions onError="WARN" onFail="MARK_RAN" onSqlOutput="IGNORE">
|
||||||
|
<not>
|
||||||
|
<sequenceExists sequenceName="TB_MATHEUS_MEDEIROS_JOGOS_SEQ" />
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<sql endDelimiter=";" splitStatements="true" stripComments="false">
|
||||||
|
CREATE SEQUENCE TB_MATHEUS_MEDEIROS_JOGOS_SEQ
|
||||||
|
START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
|
||||||
|
</sql>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<changeSet author="matheus.medeiros" id="matheus.medeiros-4">
|
||||||
|
<preConditions onError="WARN" onFail="MARK_RAN" onSqlOutput="IGNORE">
|
||||||
|
<not>
|
||||||
|
<tableExists tableName="TB_MATHEUS_MEDEIROS_AVALIACOES" />
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<sql endDelimiter=";" splitStatements="true" stripComments="false">
|
||||||
|
CREATE TABLE TB_MATHEUS_MEDEIROS_AVALIACOES (
|
||||||
|
CODIGO NUMBER(10) NOT NULL,
|
||||||
|
NOME VARCHAR2(100) NOT NULL,
|
||||||
|
EMAIL VARCHAR2(150) NOT NULL,
|
||||||
|
COMENTARIO VARCHAR2(1000) NOT NULL,
|
||||||
|
NOTA NUMBER(4,2) NOT NULL,
|
||||||
|
DATA_AVALIACAO DATE NOT NULL,
|
||||||
|
ID_JOGO NUMBER(10) NOT NULL,
|
||||||
|
CONSTRAINT PK_MM_AVALIACOES PRIMARY KEY (CODIGO),
|
||||||
|
CONSTRAINT FK_MM_AVAL_JOGO
|
||||||
|
FOREIGN KEY (ID_JOGO)
|
||||||
|
REFERENCES TB_MATHEUS_MEDEIROS_JOGOS (CODIGO),
|
||||||
|
CONSTRAINT CK_MM_AVAL_NOTA
|
||||||
|
CHECK (NOTA BETWEEN 0 AND 10)
|
||||||
|
);</sql>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet author="matheus.medeiros" id="matheus.medeiros-3">
|
||||||
|
<preConditions onError="WARN" onFail="MARK_RAN" onSqlOutput="IGNORE">
|
||||||
|
<not>
|
||||||
|
<sequenceExists sequenceName="TB_MATHEUS_MEDEIROS_AVALIACOES_SEQ" />
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<sql endDelimiter=";" splitStatements="true" stripComments="false">
|
||||||
|
CREATE SEQUENCE TB_MATHEUS_MEDEIROS_AVALIACOES_SEQ
|
||||||
|
START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
|
||||||
|
</sql>
|
||||||
|
</changeSet>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
Reference in New Issue
Block a user