diff --git a/sapl/templates/materia/materialegislativa_form.html b/sapl/templates/materia/materialegislativa_form.html index bb435be91..24e322400 100644 --- a/sapl/templates/materia/materialegislativa_form.html +++ b/sapl/templates/materia/materialegislativa_form.html @@ -24,42 +24,88 @@ $("#id_tipo, #id_ano").change(recuperar_numero_ano); function compare(a, b) { - if (a.text < b.text) - return -1; - if (a.text > b.text) - return 1; - return 0; - } + if (a.text < b.text) + return -1; + if (a.text > b.text) + return 1; + return 0; + } + + var modal_estilos = 'display: block;' + +'width: 85%; max-width: 600px;' + +'background: #fff; padding: 15px;' + +'border-radius: 5px;' + +'-webkit-box-shadow: 0px 6px 14px -2px rgba(0,0,0,0.75);' + +'-moz-box-shadow: 0px 6px 14px -2px rgba(0,0,0,0.75);' + +'box-shadow: 0px 6px 14px -2px rgba(0,0,0,0.75);' + +'position: fixed;' + +'top: 50%; left: 50%;' + +'transform: translate(-50%,-50%);' + +'z-index: 99999999; text-align: center'; + + var fundo_modal_estilos = 'top: 0; right: 0;' + +'bottom: 0; left: 0; position: fixed;' + +'background-color: rgba(0, 0, 0, 0.6); z-index: 99999999;' + +'display: none;'; + + var meu_modal = '
' + +'
' + +'

Atenção! Ano de apresentação e ano da matéria são diferentes.


' + +'' + +'
'; + + function verifica_ano(){ + let ano = $("select#id_ano.select").val(); + let data_apresentacao = $("input#id_data_apresentacao.dateinput").val(); + let ano_apresentacao = data_apresentacao.substr(data_apresentacao.length - 4); + + if(ano && ano_apresentacao && ano_apresentacao != ano){ + $('#fundo_modal').fadeIn(); + } + } - $(document).ready(function() { - $("#id_tipo_autor").change(function() { - var tipo_selecionado = $("#id_tipo_autor").val(); - var autor_selecionado = $("#id_autor").val(); - $("#id_autor option").remove() - if (tipo_selecionado !== undefined && tipo_selecionado !== null) { - var json_data = { - tipo : tipo_selecionado, - data_relativa : $("#id_data_apresentacao").val() - } - $.getJSON("/api/autor/possiveis", json_data, function(data){ - if (data) { - var results = data.sort(compare); - if (results.length > 1) { - $("#id_autor").append(""); - } - $.each(results, function(idx, obj) { - $("#id_autor") - .append($("") - .attr("value", obj.value) - .text(obj.text)); - }); - $("#id_autor").val(autor_selecionado); - } - }); + $(document).ready(function() { + $("#id_tipo_autor").change(function() { + var tipo_selecionado = $("#id_tipo_autor").val(); + var autor_selecionado = $("#id_autor").val(); + $("#id_autor option").remove() + if (tipo_selecionado !== undefined && tipo_selecionado !== null) { + var json_data = { + tipo : tipo_selecionado, + data_relativa : $("#id_data_apresentacao").val() + } + $.getJSON("/api/autor/possiveis", json_data, function(data){ + if (data) { + var results = data.sort(compare); + if (results.length > 1) { + $("#id_autor").append(""); } - }); - $("#id_tipo_autor").trigger('change'); - }); + $.each(results, function(idx, obj) { + $("#id_autor") + .append($("") + .attr("value", obj.value) + .text(obj.text)); + }); + $("#id_autor").val(autor_selecionado); + } + }); + } + }); + $("#id_tipo_autor").trigger('change'); + + $("body").append(meu_modal); + + $("#fundo_modal, #close_model_btn").click(function(){ $("#fundo_modal").hide(); }); + $("#meu_modal").click(function(e){ e.stopPropagation(); }); + + $("select#id_ano.select.form-control").blur(function(){ + verifica_ano(); + }); + $("input#id_data_apresentacao.dateinput.form-control").blur(function(){ + verifica_ano(); + }); + }); {% endblock %} diff --git a/sapl/templates/norma/normajuridica_form.html b/sapl/templates/norma/normajuridica_form.html index 4c29fc98b..91531c4d1 100644 --- a/sapl/templates/norma/normajuridica_form.html +++ b/sapl/templates/norma/normajuridica_form.html @@ -57,6 +57,54 @@ numeroField.val(numero.replace(/^0+/, '')); } }); + + var modal_estilos = 'display: block;' + +'width: 85%; max-width: 600px;' + +'background: #fff; padding: 15px;' + +'border-radius: 5px;' + +'-webkit-box-shadow: 0px 6px 14px -2px rgba(0,0,0,0.75);' + +'-moz-box-shadow: 0px 6px 14px -2px rgba(0,0,0,0.75);' + +'box-shadow: 0px 6px 14px -2px rgba(0,0,0,0.75);' + +'position: fixed;' + +'top: 50%; left: 50%;' + +'transform: translate(-50%,-50%);' + +'z-index: 99999999; text-align: center'; + + var fundo_modal_estilos = 'top: 0; right: 0;' + +'bottom: 0; left: 0; position: fixed;' + +'background-color: rgba(0, 0, 0, 0.6); z-index: 99999999;' + +'display: none;'; + + var meu_modal = '
' + +'
' + +'

Atenção! Ano de apresentação e ano da norma são diferentes.


' + +'' + +'
'; + + function verifica_ano(){ + let ano = $("select#id_ano.select").val(); + let data_apresentacao = $("input#id_data.dateinput").val(); + let ano_apresentacao = data_apresentacao.substr(data_apresentacao.length - 4); + + if(ano && ano_apresentacao && ano_apresentacao != ano){ + $('#fundo_modal').fadeIn(); + } + } + + $(document).ready(function() { + $("body").append(meu_modal); + + $("#fundo_modal, #close_model_btn").click(function(){ $("#fundo_modal").hide(); }); + $("#meu_modal").click(function(e){ e.stopPropagation(); }); + + $("select#id_ano.select.form-control").blur(function(){ + verifica_ano(); + }); + $("input#id_data.dateinput.form-control").blur(function(){ + verifica_ano(); + }); + }); {% endblock %}