mirror of https://github.com/interlegis/sapl.git
8 changed files with 16 additions and 405 deletions
@ -1,115 +0,0 @@ |
|||||
|
|
||||
function initTinymce(elements, readonly=false) { |
|
||||
removeTinymce(); |
|
||||
var config_tinymce = { |
|
||||
force_br_newlines : false, |
|
||||
force_p_newlines : false, |
|
||||
forced_root_block : '', |
|
||||
plugins: ["table save code"], |
|
||||
menubar: "edit format table tools", |
|
||||
toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent", |
|
||||
tools: "inserttable", |
|
||||
} |
|
||||
|
|
||||
if (readonly) { |
|
||||
config_tinymce.readonly = 1; |
|
||||
config_tinymce.menubar = false; |
|
||||
config_tinymce.toolbar = false; |
|
||||
} |
|
||||
|
|
||||
if (elements != null) { |
|
||||
config_tinymce['elements'] = elements; |
|
||||
config_tinymce['mode'] = "exact"; |
|
||||
} |
|
||||
else |
|
||||
config_tinymce['mode'] = "textareas"; |
|
||||
|
|
||||
tinymce.init(config_tinymce); |
|
||||
} |
|
||||
|
|
||||
function removeTinymce() { |
|
||||
while (tinymce.editors.length > 0) { |
|
||||
tinymce.remove(tinymce.editors[0]); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
function OptionalCustomFrontEnd() { |
|
||||
// Adaptações opcionais de layout com a presença de JS.
|
|
||||
// Não implementar customizações que a funcionalidade que fique dependente.
|
|
||||
var instance; |
|
||||
if (!(this instanceof OptionalCustomFrontEnd)) { |
|
||||
if (!instance) { |
|
||||
instance = new OptionalCustomFrontEnd(); |
|
||||
} |
|
||||
return instance; |
|
||||
} |
|
||||
instance = this; |
|
||||
OptionalCustomFrontEnd = function() { |
|
||||
return instance; |
|
||||
} |
|
||||
instance.customCheckBoxAndRadio = function() { |
|
||||
$('[type=radio], [type=checkbox]').each(function() { |
|
||||
var _this = $(this) |
|
||||
var _controls = _this.closest('.controls'); |
|
||||
_controls && _controls.find(':file').length == 0 && !_controls.hasClass('controls-radio-checkbox') && _controls.addClass('controls-radio-checkbox'); |
|
||||
_controls.find(':file').length > 0 && _controls.addClass('controls-file'); |
|
||||
}); |
|
||||
} |
|
||||
instance.customCheckBoxAndRadioWithoutLabel = function() { |
|
||||
|
|
||||
$('[type=radio], [type=checkbox]').each(function() { |
|
||||
let _this = $(this) |
|
||||
|
|
||||
if (this.id === undefined || this.id.length === 0) { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
let _label = _this.closest('label') |
|
||||
|
|
||||
if (_label.length === 0) { |
|
||||
_label = $('label[for='+this.id+']'); |
|
||||
if (_label.length === 0) { |
|
||||
_label = $('<label for='+this.id+'/>').insertBefore(this) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (this.type === "checkbox") { |
|
||||
_label.prepend(_this); |
|
||||
|
|
||||
var _div = _label.closest('.checkbox'); |
|
||||
if (_div.length == 0) { |
|
||||
_label.addClass('checkbox-inline') |
|
||||
} |
|
||||
|
|
||||
_this.checkbox(); |
|
||||
} |
|
||||
else if (this.type === "radio") { |
|
||||
_label.prepend(_this); |
|
||||
|
|
||||
var _div = _label.closest('.radio'); |
|
||||
if (_div.length == 0) { |
|
||||
_label.addClass('radio-inline') |
|
||||
} |
|
||||
|
|
||||
_this.radio(); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
}); |
|
||||
} |
|
||||
instance.init = function() { |
|
||||
this.customCheckBoxAndRadio(); |
|
||||
this.customCheckBoxAndRadioWithoutLabel(); |
|
||||
} |
|
||||
instance.init(); |
|
||||
} |
|
||||
|
|
||||
$(document).ready(function(){ |
|
||||
refreshDatePicker(); |
|
||||
initTinymce("texto-rico"); |
|
||||
|
|
||||
//OptionalCustomFrontEnd();
|
|
||||
}); |
|
||||
|
|
||||
File diff suppressed because one or more lines are too long
@ -1,276 +0,0 @@ |
|||||
function SetCookie(cookieName,cookieValue,nDays) { |
|
||||
var today = new Date(); |
|
||||
var expire = new Date(); |
|
||||
if (nDays==null || nDays==0) nDays=1; |
|
||||
expire.setTime(today.getTime() + 3600000*24*nDays); |
|
||||
document.cookie = cookieName+"="+escape(cookieValue) |
|
||||
+ ";expires="+expire.toGMTString(); |
|
||||
} |
|
||||
|
|
||||
function ReadCookie(cookieName) { |
|
||||
var theCookie=" "+document.cookie; |
|
||||
var ind=theCookie.indexOf(" "+cookieName+"="); |
|
||||
if (ind==-1) ind=theCookie.indexOf(";"+cookieName+"="); |
|
||||
if (ind==-1 || cookieName=="") return ""; |
|
||||
var ind1=theCookie.indexOf(";",ind+1); |
|
||||
if (ind1==-1) ind1=theCookie.length; |
|
||||
return unescape(theCookie.substring(ind+cookieName.length+2,ind1)); |
|
||||
} |
|
||||
|
|
||||
function insertWaitAjax(element) { |
|
||||
//jQuery(element).append('<div style="text-align:center;"><img src="/static/img/ajax-loader.gif"></div>');
|
|
||||
jQuery(element).append('<div style="text-align:center;"><i style="font-size: 200%;"class="fa fa-refresh fa-spin"></i></div>'); |
|
||||
} |
|
||||
|
|
||||
function DispostivoSearch(opts) { |
|
||||
$(function() { |
|
||||
let formData = {} |
|
||||
var container_ds = $('body').children("#container_ds"); |
|
||||
if (container_ds.length > 0) |
|
||||
$(container_ds).remove(); |
|
||||
container_ds = $('<div id="container_ds"/>'); |
|
||||
$('body').prepend(container_ds); |
|
||||
|
|
||||
var fields = $("[data-sapl-ta='DispositivoSearch']"); |
|
||||
fields.each(function() { |
|
||||
var field = $(this); |
|
||||
var data_type_selection = field.attr('data-type-selection'); |
|
||||
var data_field = field.attr('data-field'); |
|
||||
var data_function = field.attr('data-function'); |
|
||||
|
|
||||
var onChangeFieldSelects = function(event) { |
|
||||
if (data_type_selection == 'checkbox') { |
|
||||
var tas = field.find('input[name="ta_select_all"]'); //tas - Textos Articulados
|
|
||||
tas.off(); |
|
||||
|
|
||||
tas.on('change', function(event) { |
|
||||
$(this).closest('ul').find('input[name="'+data_field+'"]').prop("checked", this.checked); |
|
||||
//$(this).prop("checked", false);
|
|
||||
}); |
|
||||
|
|
||||
|
|
||||
} |
|
||||
else { |
|
||||
var dpts = field.find('input'); |
|
||||
dpts.off() |
|
||||
dpts.attr('type', 'hidden'); |
|
||||
$('<a class="text-danger">') |
|
||||
.insertBefore(dpts) |
|
||||
.append($('<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>')) |
|
||||
.on('click', function() { |
|
||||
if ($(this).closest('ul').find('li').length == 2) |
|
||||
$(this).closest('ul').remove(); |
|
||||
else |
|
||||
$(this).closest('li').remove(); |
|
||||
}); |
|
||||
} |
|
||||
} |
|
||||
onChangeFieldSelects(); |
|
||||
|
|
||||
var onChangeParamTA = function(event) { |
|
||||
|
|
||||
var tipo_ta = $("select[name='tipo_ta']").val(); |
|
||||
var tipo_model = $("select[name='tipo_model']").val(); |
|
||||
var num_ta = $("input[name='num_ta']").val(); |
|
||||
var ano_ta = $("input[name='ano_ta']").val(); |
|
||||
var dispositivos_internos = $("input[name='dispositivos_internos']:checked").val(); |
|
||||
var rotulo_dispositivo = $("input[name='rotulo_dispositivo']").val(); |
|
||||
var texto_dispositivo = $("input[name='texto_dispositivo']").val(); |
|
||||
var max_results = $("select[name='max_results']").val(); |
|
||||
var url = ''; |
|
||||
|
|
||||
if (rotulo_dispositivo.length > 0 || texto_dispositivo.length > 0) { |
|
||||
$("input[name='dispositivos_internos']").prop('disabled', false); |
|
||||
$("input[name='dispositivos_internos']").each((idx, element) => { |
|
||||
element.parentElement.classList.remove('disabled') |
|
||||
}); |
|
||||
$("input[name='dispositivos_internos']").closest('#div_id_dispositivos_internos').css('opacity','1'); |
|
||||
} |
|
||||
else { |
|
||||
$("input[name='dispositivos_internos']").filter('[value="False"]').prop('checked', true); |
|
||||
$("input[name='dispositivos_internos']").prop('disabled', true); |
|
||||
|
|
||||
$("input[name='dispositivos_internos']").each((idx, element) => { |
|
||||
element.parentElement.classList.add('disabled') |
|
||||
}); |
|
||||
$("input[name='dispositivos_internos']").closest('#div_id_dispositivos_internos').css('opacity','0.3'); |
|
||||
dispositivos_internos = 'False'; |
|
||||
} |
|
||||
formData = { |
|
||||
'tipo_ta' : tipo_ta, |
|
||||
'tipo_model' : tipo_model, |
|
||||
'num_ta' : num_ta, |
|
||||
'ano_ta' : ano_ta, |
|
||||
'texto' : texto_dispositivo, |
|
||||
'rotulo' : rotulo_dispositivo, |
|
||||
'dispositivos_internos' : dispositivos_internos, |
|
||||
'max_results' : max_results, |
|
||||
'data_type_selection' : data_type_selection, |
|
||||
'data_field' : data_field, |
|
||||
'data_function' : data_function, |
|
||||
}; |
|
||||
|
|
||||
window.localStorage.setItem("dispositivo_search_form_data", JSON.stringify(formData)) |
|
||||
|
|
||||
|
|
||||
url = '/ta/search_fragment_form'; |
|
||||
$('.result-busca-dispositivo').html(''); |
|
||||
insertWaitAjax('.result-busca-dispositivo') |
|
||||
$.get(url, formData).done(function( data ) { |
|
||||
$('.result-busca-dispositivo').html(data); |
|
||||
////OptionalCustomFrontEnd().init();
|
|
||||
if (data_type_selection == 'checkbox') { |
|
||||
var tas = $('.result-busca-dispositivo').find('input[name="ta_select_all"]'); |
|
||||
tas.off(); |
|
||||
tas.on('change', function(event) { |
|
||||
$(this).closest('ul').find('input[name="'+data_field+'"]').prop("checked", this.checked); |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
var onKeyPressRotuloBuscaTextual = function(event) { |
|
||||
var rotulo_dispositivo = $("input[name='rotulo_dispositivo']").val(); |
|
||||
var texto_dispositivo = $("input[name='texto_dispositivo']").val(); |
|
||||
var dispositivos_internos = $("input[name='dispositivos_internos']:checked").val(); |
|
||||
|
|
||||
if (rotulo_dispositivo.length > 0 || texto_dispositivo.length > 0) { |
|
||||
$("input[name='dispositivos_internos']").prop('disabled', false); |
|
||||
$("input[name='dispositivos_internos']").each((idx, element) => { |
|
||||
element.parentElement.classList.remove('disabled') |
|
||||
}); |
|
||||
$("input[name='dispositivos_internos']").closest('#div_id_dispositivos_internos').css('opacity','1'); |
|
||||
} |
|
||||
else { |
|
||||
$("input[name='dispositivos_internos']").filter('[value="False"]').prop('checked', true); |
|
||||
$("input[name='dispositivos_internos']").prop('disabled', true); |
|
||||
$("input[name='dispositivos_internos']").each((idx, element) => { |
|
||||
element.parentElement.classList.add('disabled') |
|
||||
}); |
|
||||
$("input[name='dispositivos_internos']").closest('#div_id_dispositivos_internos').css('opacity','0.3'); |
|
||||
dispositivos_internos = 'False'; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
var button_ds = field.children("#button_ds"); |
|
||||
if (button_ds.length > 0) |
|
||||
$(button_ds).remove(); |
|
||||
button_ds = $('<div id="button_ds" class="clearfix"/>'); |
|
||||
field.prepend(button_ds); |
|
||||
|
|
||||
var btn_open_search = $('<button>') |
|
||||
.text(opts['text_button']) |
|
||||
.attr('type','button') |
|
||||
.attr('class','btn btn-sm btn-success btn-modal-open'); |
|
||||
button_ds.append(btn_open_search); |
|
||||
btn_open_search.on('click', function() { |
|
||||
$.get(opts['url_form'], function(data) { |
|
||||
container_ds.html(data); |
|
||||
var modal_ds = $('#modal-ds'); |
|
||||
//OptionalCustomFrontEnd().init();
|
|
||||
|
|
||||
modal_ds.find("select[name='tipo_ta']").change(function(event) { |
|
||||
var url = ''; |
|
||||
url = '/ta/search_fragment_form?action=get_tipos&tipo_ta='+this.value; |
|
||||
modal_ds.find("label[for='id_tipo_model']").html('Tipos de ' + this.children[this.selectedIndex].innerHTML); |
|
||||
|
|
||||
var select = modal_ds.find("select[name='tipo_model']"); |
|
||||
select.empty(); |
|
||||
$('<option value="">Carregando...</option>').appendTo(select); |
|
||||
|
|
||||
$.get(url).done(function( data ) { |
|
||||
select.empty(); |
|
||||
for(var item in data) { |
|
||||
for (var i in data[item]) |
|
||||
select.append($("<option>").attr('value',i).text(data[item][i])); |
|
||||
} |
|
||||
setTimeout(function() { |
|
||||
$("select[name='tipo_model']").val(formData.tipo_model); |
|
||||
}, 200) |
|
||||
//select.change(onChangeParamTA)
|
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
/*modal_ds.find("input[name='num_ta'], " |
|
||||
+"input[name='ano_ta'], " |
|
||||
+"select[name='tipo_model'], " |
|
||||
+"input[name='texto_dispositivo'], " |
|
||||
+"input[name='dispositivos_internos'], " |
|
||||
+"input[name='rotulo_dispositivo']" |
|
||||
).change(onChangeParamTA);*/ |
|
||||
modal_ds.find("input[name='texto_dispositivo'], " |
|
||||
+"input[name='rotulo_dispositivo']") |
|
||||
.on('keyup', onKeyPressRotuloBuscaTextual) |
|
||||
|
|
||||
modal_ds.find(".btn-busca").click(onChangeParamTA); |
|
||||
|
|
||||
modal_ds.find("#btn-modal-select").click(function() { |
|
||||
// limpar selecionados se o tipo é radio
|
|
||||
var listas = field.find('ul'); |
|
||||
if (data_type_selection == 'radio') |
|
||||
listas.remove(); |
|
||||
|
|
||||
// adicionar itens selecionados na caixa modal
|
|
||||
var selecionados = modal_ds.find('[name="'+data_field+'"]:checked'); |
|
||||
|
|
||||
// com base nos selecionados, limpa seus ta's removendo os não selecionados
|
|
||||
selecionados.closest('ul').find('input:not(:checked)').filter('[name!="ta_select_all"]').closest('li').remove(); |
|
||||
|
|
||||
selecionados.closest('ul').each(function() { |
|
||||
//insere na lista de selecionados os ta's não presentes
|
|
||||
var ul_lista = field.find('#'+this.id); |
|
||||
if (ul_lista.length == 0) { |
|
||||
field.append(this); |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
//insere os dispositivos não presentes
|
|
||||
var inputs_for_this = $(this).find('input'); |
|
||||
|
|
||||
inputs_for_this.each(function() { |
|
||||
if (ul_lista.find("#"+this.id).length > 0) |
|
||||
return; |
|
||||
ul_lista.append($(this).closest('li')); |
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
onChangeFieldSelects(); |
|
||||
|
|
||||
modal_ds.modal('hide'); |
|
||||
|
|
||||
if ('post_selected' in opts) |
|
||||
opts['post_selected'](opts['params_post_selected']) |
|
||||
|
|
||||
}); |
|
||||
|
|
||||
|
|
||||
try { |
|
||||
formData = JSON.parse(window.localStorage.getItem("dispositivo_search_form_data")) |
|
||||
$("input[name='num_ta']").val(formData.num_ta); |
|
||||
$("input[name='ano_ta']").val(formData.ano_ta); |
|
||||
$("input[name='rotulo_dispositivo']").val(formData.rotulo); |
|
||||
$("input[name='texto_dispositivo']").val(formData.texto); |
|
||||
$("select[name='max_results']").val(formData.max_results); |
|
||||
} catch (e) { |
|
||||
|
|
||||
} |
|
||||
|
|
||||
setTimeout(function() { |
|
||||
try { |
|
||||
$("select[name='tipo_ta']").val(formData.tipo_ta); |
|
||||
$("select[name='tipo_ta']").trigger('change') |
|
||||
//modal_ds.find(".btn-busca").trigger('click')
|
|
||||
//onChangeParamTA();
|
|
||||
} catch (e) { |
|
||||
|
|
||||
} |
|
||||
|
|
||||
}, 200) |
|
||||
|
|
||||
modal_ds.modal('show'); |
|
||||
}) |
|
||||
}); |
|
||||
}); |
|
||||
}); |
|
||||
} |
|
||||
@ -1 +1 @@ |
|||||
{"status":"done","publicPath":"/static/","chunks":{"chunk-vendors":[{"name":"css/chunk-vendors.79dbe19a.css","publicPath":"/static/css/chunk-vendors.79dbe19a.css","path":"../sapl/static/css/chunk-vendors.79dbe19a.css"},{"name":"js/chunk-vendors.ff11043a.js","publicPath":"/static/js/chunk-vendors.ff11043a.js","path":"../sapl/static/js/chunk-vendors.ff11043a.js"}],"compilacao":[{"name":"css/compilacao.ef12dfcf.css","publicPath":"/static/css/compilacao.ef12dfcf.css","path":"../sapl/static/css/compilacao.ef12dfcf.css"},{"name":"js/compilacao.c9929252.js","publicPath":"/static/js/compilacao.c9929252.js","path":"../sapl/static/js/compilacao.c9929252.js"}],"global":[{"name":"css/global.8608d5e7.css","publicPath":"/static/css/global.8608d5e7.css","path":"../sapl/static/css/global.8608d5e7.css"},{"name":"js/global.7411602f.js","publicPath":"/static/js/global.7411602f.js","path":"../sapl/static/js/global.7411602f.js"}],"sapl-oficial-theme":[{"name":"js/sapl-oficial-theme.391f1e2f.js","publicPath":"/static/js/sapl-oficial-theme.391f1e2f.js","path":"../sapl/static/js/sapl-oficial-theme.391f1e2f.js"}]}} |
{"status":"done","publicPath":"http://localhost:8080/","chunks":{"compilacao":[{"name":"compilacao.js","publicPath":"http://localhost:8080/compilacao.js","path":"../sapl/static/compilacao.js"},{"name":"compilacao.80cf4c95fe3d3b717889.hot-update.js","publicPath":"http://localhost:8080/compilacao.80cf4c95fe3d3b717889.hot-update.js","path":"../sapl/static/compilacao.80cf4c95fe3d3b717889.hot-update.js"}],"global":[{"name":"global.js","publicPath":"http://localhost:8080/global.js","path":"../sapl/static/global.js"}],"sapl-oficial-theme":[{"name":"sapl-oficial-theme.js","publicPath":"http://localhost:8080/sapl-oficial-theme.js","path":"../sapl/static/sapl-oficial-theme.js"}]}} |
||||
Loading…
Reference in new issue