mirror of https://github.com/interlegis/sapl.git
17 changed files with 761 additions and 763 deletions
@ -1,20 +1,30 @@ |
|||
module.exports = { |
|||
root: true, |
|||
env: { |
|||
browser: true, |
|||
node: true, |
|||
jquery: true |
|||
}, |
|||
extends: ["plugin:vue/essential", "@vue/prettier"], |
|||
extends: [ |
|||
"plugin:vue/essential", |
|||
'standard' |
|||
], |
|||
rules: { |
|||
'generator-star-spacing': 'off', |
|||
"no-console": process.env.NODE_ENV === "production" ? "error" : "off", |
|||
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" |
|||
}, |
|||
// required to lint *.vue files
|
|||
plugins: [ |
|||
'vue' |
|||
], |
|||
parserOptions: { |
|||
parser: "babel-eslint" |
|||
}, |
|||
|
|||
globals: { |
|||
"$": true, |
|||
"jQuery": true |
|||
"jQuery": true, |
|||
'_': true |
|||
} |
|||
}; |
|||
|
|||
@ -1,287 +1,278 @@ |
|||
|
|||
|
|||
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 DispositivoSearch(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(); |
|||
}); |
|||
} |
|||
function SetCookie (cookieName, cookieValue, nDays) { |
|||
let today = new Date() |
|||
let 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) { |
|||
let theCookie = ' ' + document.cookie |
|||
let ind = theCookie.indexOf(' ' + cookieName + '=') |
|||
if (ind === -1) ind = theCookie.indexOf(';' + cookieName + '=') |
|||
if (ind === -1 || cookieName === '') return '' |
|||
let 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 DispositivoSearch (opts) { |
|||
$(function () { |
|||
let formData = {} |
|||
let containerDs = $('body').children('#container_ds') |
|||
if (containerDs.length > 0) { |
|||
$(containerDs).remove() |
|||
} |
|||
containerDs = $('<div id="container_ds"/>') |
|||
$('body').prepend(containerDs) |
|||
|
|||
let fields = $('[data-sapl-ta="DispositivoSearch"]') |
|||
fields.each(function () { |
|||
let field = $(this) |
|||
let dataTypeSelection = field.attr('data-type-selection') |
|||
let dataField = field.attr('data-field') |
|||
let dataFunction = field.attr('data-function') |
|||
|
|||
let onChangeFieldSelects = function (event) { |
|||
if (dataTypeSelection === 'checkbox') { |
|||
let tas = field.find('input[name="ta_select_all"]') // tas - Textos Articulados
|
|||
tas.off() |
|||
|
|||
tas.on('change', function (event) { |
|||
$(this).closest('ul').find('input[name="' + dataField + '"]').prop('checked', this.checked) |
|||
// $(this).prop('checked', false)
|
|||
}) |
|||
} else { |
|||
let 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); |
|||
}); |
|||
} |
|||
} |
|||
onChangeFieldSelects() |
|||
|
|||
let onChangeParamTA = function (event) { |
|||
let tipoTa = $('select[name="tipo_ta"]').val() |
|||
let tipoModel = $('select[name="tipo_model"]').val() |
|||
let numTa = $('input[name="num_ta"]').val() |
|||
let anoTa = $('input[name="ano_ta"]').val() |
|||
let dispositivosInternos = $('input[name="dispositivos_internos"]:checked').val() |
|||
let rotuloDispositivo = $('input[name="rotulo_dispositivo"]').val() |
|||
let textoDispositivo = $('input[name="texto_dispositivo"]').val() |
|||
let maxResults = $('select[name="max_results"]').val() |
|||
let url = '' |
|||
|
|||
if (rotuloDispositivo.length > 0 || textoDispositivo.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') |
|||
dispositivosInternos = 'False' |
|||
} |
|||
formData = { |
|||
'tipo_ta': tipoTa, |
|||
'tipo_model': tipoModel, |
|||
'num_ta': numTa, |
|||
'ano_ta': anoTa, |
|||
'texto': textoDispositivo, |
|||
'rotulo': rotuloDispositivo, |
|||
'dispositivos_internos': dispositivosInternos, |
|||
'max_results': maxResults, |
|||
'data_type_selection': dataTypeSelection, |
|||
'data_field': dataField, |
|||
'data_function': dataFunction |
|||
} |
|||
|
|||
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'; |
|||
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 (dataTypeSelection === 'checkbox') { |
|||
let tas = $('.result-busca-dispositivo').find('input[name="ta_select_all"]') |
|||
tas.off() |
|||
tas.on('change', function (event) { |
|||
$(this).closest('ul').find('input[name="' + dataField + '"]').prop('checked', this.checked) |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
|
|||
let onKeyPressRotuloBuscaTextual = function (event) { |
|||
let rotuloDispositivo = $('input[name="rotulo_dispositivo"]').val() |
|||
let textoDispositivo = $('input[name="texto_dispositivo"]').val() |
|||
// let dispositivosInternos = $('input[name="dispositivos_internos"]:checked').val()
|
|||
|
|||
if (rotuloDispositivo.length > 0 || textoDispositivo.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') |
|||
// dispositivosInternos = '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; |
|||
} |
|||
|
|||
let buttonDs = field.children('#buttonDs') |
|||
if (buttonDs.length > 0) { |
|||
$(buttonDs).remove() |
|||
} |
|||
buttonDs = $('<div id="buttonDs" class="clearfix"/>') |
|||
field.prepend(buttonDs) |
|||
|
|||
let btnOpenSearch = $('<button>') |
|||
.text(opts['text_button']) |
|||
.attr('type', 'button') |
|||
.attr('class', 'btn btn-sm btn-success btn-modal-open') |
|||
buttonDs.append(btnOpenSearch) |
|||
btnOpenSearch.on('click', function () { |
|||
$.get(opts['url_form'], function (data) { |
|||
containerDs.html(data) |
|||
let modalDs = $('#modal-ds') |
|||
// OptionalCustomFrontEnd().init()
|
|||
|
|||
modalDs.find('select[name="tipo_ta"]').change(function (event) { |
|||
let url = '' |
|||
url = '/ta/search_fragment_form?action=get_tipos&tipo_ta=' + this.value |
|||
modalDs.find('label[for="id_tipo_model"]').html('Tipos de ' + this.children[this.selectedIndex].innerHTML) |
|||
|
|||
let select = modalDs.find('select[name="tipo_model"]') |
|||
select.empty() |
|||
$('<option value="">Carregando...</option>').appendTo(select) |
|||
|
|||
$.get(url).done(function (data) { |
|||
select.empty() |
|||
for (let item in data) { |
|||
for (let 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)
|
|||
}) |
|||
}) |
|||
|
|||
//insere os dispositivos não presentes
|
|||
var inputs_for_this = $(this).find('input'); |
|||
/* modalDs.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); */ |
|||
modalDs.find('input[name="texto_dispositivo"], ' + |
|||
'input[name="rotulo_dispositivo"]') |
|||
.on('keyup', onKeyPressRotuloBuscaTextual) |
|||
|
|||
modalDs.find('.btn-busca').click(onChangeParamTA) |
|||
|
|||
modalDs.find('#btn-modal-select').click(function () { |
|||
// limpar selecionados se o tipo é radio
|
|||
let listas = field.find('ul') |
|||
if (dataTypeSelection === 'radio') { |
|||
listas.remove() |
|||
} |
|||
// adicionar itens selecionados na caixa modal
|
|||
let selecionados = modalDs.find('[name="' + dataField + '"]: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
|
|||
let ulLista = field.find('#' + this.id) |
|||
if (ulLista.length === 0) { |
|||
field.append(this) |
|||
return |
|||
} |
|||
|
|||
inputs_for_this.each(function() { |
|||
if (ul_lista.find("#"+this.id).length > 0) |
|||
return; |
|||
ul_lista.append($(this).closest('li')); |
|||
}); |
|||
}); |
|||
// insere os dispositivos não presentes
|
|||
let inputForThis = $(this).find('input') |
|||
|
|||
onChangeFieldSelects(); |
|||
inputForThis.each(function () { |
|||
if (ulLista.find('#' + this.id).length > 0) { |
|||
return |
|||
} |
|||
ulLista.append($(this).closest('li')) |
|||
}) |
|||
}) |
|||
|
|||
modal_ds.modal('hide'); |
|||
onChangeFieldSelects() |
|||
|
|||
if ('post_selected' in opts) |
|||
opts['post_selected'](opts['params_post_selected']) |
|||
modalDs.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) { |
|||
console.log(e) |
|||
} |
|||
|
|||
setTimeout(function () { |
|||
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); |
|||
$('select[name="tipo_ta"]').val(formData.tipo_ta) |
|||
$('select[name="tipo_ta"]').trigger('change') |
|||
// modalDs.find('.btn-busca').trigger('click')
|
|||
// onChangeParamTA()
|
|||
} catch (e) { |
|||
|
|||
console.log(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'); |
|||
|
|||
}) |
|||
}); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
|
|||
export default { |
|||
SetCookie, |
|||
ReadCookie, |
|||
insertWaitAjax, |
|||
DispositivoSearch |
|||
} |
|||
}, 200) |
|||
|
|||
modalDs.modal('show') |
|||
}) |
|||
}) |
|||
}) |
|||
}) |
|||
} |
|||
|
|||
export default { |
|||
SetCookie, |
|||
ReadCookie, |
|||
insertWaitAjax, |
|||
DispositivoSearch |
|||
} |
|||
|
|||
@ -1,145 +1,134 @@ |
|||
|
|||
function onEventsDneExec(pk, model) { |
|||
|
|||
$('html, body').animate({ |
|||
scrollTop: $('#dne' + pk ).offset().top - window.innerHeight / 5 |
|||
}, 300); |
|||
|
|||
refreshDatePicker(); |
|||
|
|||
$('#dne'+pk+" #button-id-submit-form").click(onSubmitEditNVForm); |
|||
$('#dne'+pk+" .btn-close-container").click(function(){ |
|||
$(this).closest('.dne-nota').removeClass('dne-nota'); |
|||
$(this).closest('.dne-form').html(''); |
|||
}); |
|||
|
|||
if (model == 'nota') { |
|||
$('#dne'+pk+" select[name='tipo']").change(function(event) { |
|||
var url = ''; |
|||
url = 'text/'+pk+'/nota/create?action=modelo_nota&id_tipo='+this.value; |
|||
$.get(url).done(function( data ) { |
|||
$('#dne'+pk+" textarea[name='texto']").val(data); |
|||
}); |
|||
}); |
|||
} |
|||
else if (model == 'vide') { |
|||
|
|||
DispositivoSearch({ |
|||
'url_form': '/ta/search_form', |
|||
'text_button': 'Definir Dispositivo' |
|||
}); |
|||
} |
|||
function onEventsDneExec (pk, model) { |
|||
$('html, body').animate({ |
|||
scrollTop: $('#dne' + pk).offset().top - window.innerHeight / 5 |
|||
}, 300) |
|||
|
|||
window.refreshDatePicker() |
|||
|
|||
$('#dne' + pk + ' #button-id-submit-form').click(onSubmitEditNVForm) |
|||
$('#dne' + pk + ' .btn-close-container').click(function () { |
|||
$(this).closest('.dne-nota').removeClass('dne-nota') |
|||
$(this).closest('.dne-form').html('') |
|||
}) |
|||
|
|||
if (model === 'nota') { |
|||
$('#dne' + pk + ' select[name="tipo"]').change(function (event) { |
|||
let url = '' |
|||
url = 'text/' + pk + '/nota/create?action=modelo_nota&id_tipo=' + this.value |
|||
$.get(url).done(function (data) { |
|||
$('#dne' + pk + ' textarea[name="texto"]').val(data) |
|||
}) |
|||
}) |
|||
} else if (model === 'vide') { |
|||
window.DispositivoSearch({ |
|||
'url_form': '/ta/search_form', |
|||
'text_button': 'Definir Dispositivo' |
|||
}) |
|||
} |
|||
} |
|||
|
|||
function onSubmitEditNVForm(event) { |
|||
|
|||
var url = ''; |
|||
var model = 'nota'; |
|||
var id_edit = null; |
|||
var id_dispositivo = $('#id_dispositivo').val(); |
|||
|
|||
if (id_dispositivo == null) { // trata-se de um vide
|
|||
//$('#id_dispositivo_ref').remove();
|
|||
id_dispositivo = $('#id_dispositivo_base').val(); |
|||
model='vide'; |
|||
} |
|||
|
|||
id_edit = $('#id_pk').val(); |
|||
url = 'text/'+id_dispositivo+'/'+model+'/' |
|||
if (id_edit == null || id_edit == '') |
|||
url += 'create'; |
|||
else |
|||
url += id_edit+'/edit'; |
|||
|
|||
console.log($('#dne'+id_dispositivo+" form").serialize()); |
|||
|
|||
$.post( url, $('#dne'+id_dispositivo+" form").serialize(), function(data) { |
|||
|
|||
if (typeof data == "string") { |
|||
if (data.indexOf('<form') >= 0) { |
|||
$('#dne'+id_dispositivo+' .dne-form').html(data); |
|||
onEventsDneExec(id_dispositivo, model); |
|||
} |
|||
else { |
|||
$('#dne'+id_dispositivo+' .dne-form').closest('.dpt').html(data) |
|||
onReadyNotasVides(); |
|||
try { |
|||
$('html, body').animate({ |
|||
scrollTop: $('#dne' + id_dispositivo ).offset().top - window.innerHeight / 3 |
|||
}, 300); |
|||
} |
|||
catch(err) { |
|||
} |
|||
} |
|||
} |
|||
function onSubmitEditNVForm (event) { |
|||
let url = '' |
|||
let model = 'nota' |
|||
let idEdit = null |
|||
let idDispositivo = $('#idDispositivo').val() |
|||
|
|||
if (idDispositivo === null) { // trata-se de um vide
|
|||
// $('#idDispositivo_ref').remove()
|
|||
idDispositivo = $('#idDispositivo_base').val() |
|||
model = 'vide' |
|||
} |
|||
|
|||
idEdit = $('#id_pk').val() |
|||
url = 'text/' + idDispositivo + '/' + model + '/' |
|||
if (idEdit === null || idEdit === '') { |
|||
url += 'create' |
|||
} else { |
|||
url += idEdit + '/edit' |
|||
} |
|||
|
|||
console.log($('#dne' + idDispositivo + ' form').serialize()) |
|||
|
|||
$.post(url, $('#dne' + idDispositivo + ' form').serialize(), function (data) { |
|||
if (typeof data === 'string') { |
|||
if (data.indexOf('<form') >= 0) { |
|||
$('#dne' + idDispositivo + ' .dne-form').html(data) |
|||
onEventsDneExec(idDispositivo, model) |
|||
} else { |
|||
$('#dne' + idDispositivo + ' .dne-form').closest('.dpt').html(data) |
|||
onReadyNotasVides() |
|||
try { |
|||
$('html, body').animate({ |
|||
scrollTop: $('#dne' + idDispositivo).offset().top - window.innerHeight / 3 |
|||
}, 300) |
|||
} catch (err) { |
|||
} |
|||
); |
|||
} |
|||
} |
|||
}) |
|||
} |
|||
function onDelete(event) { |
|||
|
|||
var model = $(event).attr('model'); |
|||
function onDelete (event) { |
|||
let model = $(event).attr('model') |
|||
|
|||
var id_dispositivo = $(event).closest('.dn').attr('pk'); |
|||
var id_delete = $(event).attr('pk'); |
|||
var url = 'text/'+id_dispositivo+'/'+model+'/'+id_delete+'/delete'; |
|||
let idDispositivo = $(event).closest('.dn').attr('pk') |
|||
let idDelete = $(event).attr('pk') |
|||
let url = 'text/' + idDispositivo + '/' + model + '/' + idDelete + '/delete' |
|||
|
|||
$.get( url, function(data) { |
|||
$('#dne'+id_dispositivo+' .dne-form').closest('.dpt').html(data) |
|||
onReadyNotasVides(); |
|||
} |
|||
); |
|||
$.get(url, function (data) { |
|||
$('#dne' + idDispositivo + ' .dne-form').closest('.dpt').html(data) |
|||
onReadyNotasVides() |
|||
}) |
|||
} |
|||
|
|||
function getForm(_this) { |
|||
|
|||
var url = ''; |
|||
var model = $(_this).attr('model'); |
|||
var id_dispositivo = $('.dne-nota .dne-form').closest('.dne').attr('pk'); |
|||
if (id_dispositivo != null) { |
|||
$('#dne'+id_dispositivo).removeClass('dne-nota'); |
|||
$('#dne'+id_dispositivo+' .dne-form').html(''); |
|||
} |
|||
|
|||
if (_this.className.indexOf('create') >= 0 ) { |
|||
id_dispositivo = $(_this).attr('pk'); |
|||
url = 'text/'+id_dispositivo+'/'+model+'/create'; |
|||
} |
|||
else if (_this.className.indexOf('edit') >= 0 ) { |
|||
var id_edit = $(_this).attr('pk'); |
|||
id_dispositivo = $(_this).closest('.dn').attr('pk'); |
|||
url = 'text/'+id_dispositivo+'/'+model+'/'+id_edit+'/edit' |
|||
} |
|||
|
|||
$('#dne'+id_dispositivo).addClass('dne-nota'); |
|||
|
|||
$.get(url).done(function( data ) { |
|||
$('#dne'+id_dispositivo+' .dne-form').html(data); |
|||
onEventsDneExec(id_dispositivo, model); |
|||
}).fail(function() { |
|||
onReadyNotasVides(); |
|||
}); |
|||
function getForm (_this) { |
|||
let url = '' |
|||
let model = $(_this).attr('model') |
|||
let idDispositivo = $('.dne-nota .dne-form').closest('.dne').attr('pk') |
|||
if (idDispositivo != null) { |
|||
$('#dne' + idDispositivo).removeClass('dne-nota') |
|||
$('#dne' + idDispositivo + ' .dne-form').html('') |
|||
} |
|||
|
|||
if (_this.className.indexOf('create') >= 0) { |
|||
idDispositivo = $(_this).attr('pk') |
|||
url = 'text/' + idDispositivo + '/' + model + '/create' |
|||
} else if (_this.className.indexOf('edit') >= 0) { |
|||
let idEdit = $(_this).attr('pk') |
|||
idDispositivo = $(_this).closest('.dn').attr('pk') |
|||
url = 'text/' + idDispositivo + '/' + model + '/' + idEdit + '/edit' |
|||
} |
|||
|
|||
$('#dne' + idDispositivo).addClass('dne-nota') |
|||
|
|||
$.get(url).done(function (data) { |
|||
$('#dne' + idDispositivo + ' .dne-form').html(data) |
|||
onEventsDneExec(idDispositivo, model) |
|||
}).fail(function () { |
|||
onReadyNotasVides() |
|||
}) |
|||
} |
|||
|
|||
function onReadyNotasVides() { |
|||
function onReadyNotasVides () { |
|||
$('.dne-nota').removeClass('dne-nota') |
|||
$('.dne-form').html('') |
|||
|
|||
$('.dne-nota').removeClass('dne-nota'); |
|||
$('.dne-form').html(''); |
|||
$('.dne .btn-action').off() |
|||
$('.dn .btn-action').off() |
|||
|
|||
$('.dne .btn-action').off(); |
|||
$('.dn .btn-action').off(); |
|||
$('.dne .btn-action, .dn .btn-action').not('.btn-nota-delete').not('.btn-vide-delete').click(function () { |
|||
getForm(this) |
|||
}) |
|||
|
|||
$('.dne .btn-action, .dn .btn-action').not('.btn-nota-delete').not('.btn-vide-delete').click(function(){ |
|||
getForm(this); |
|||
}); |
|||
|
|||
$('.dn .btn-nota-delete, .dn .btn-vide-delete').click(function(){ |
|||
onDelete(this); |
|||
}); |
|||
$('.dn .btn-nota-delete, .dn .btn-vide-delete').click(function () { |
|||
onDelete(this) |
|||
}) |
|||
} |
|||
|
|||
export default { |
|||
onEventsDneExec, |
|||
onSubmitEditNVForm, |
|||
onDelete, |
|||
onReadyNotasVides |
|||
} |
|||
onEventsDneExec, |
|||
onSubmitEditNVForm, |
|||
onDelete, |
|||
onReadyNotasVides |
|||
} |
|||
|
|||
@ -1,50 +1,47 @@ |
|||
// TODO: migrar compilacao para VueJs
|
|||
|
|||
import "./scss/compilacao.scss"; |
|||
import './scss/compilacao.scss' |
|||
|
|||
import compilacao from "./js/old/compilacao"; |
|||
import compilacao_view from "./js/old/compilacao_view"; |
|||
import compilacao_notas from "./js/old/compilacao_notas"; |
|||
import _ from "lodash"; |
|||
import 'bootstrap' |
|||
|
|||
import compilacao from './js/old/compilacao' |
|||
import compilacaoView from './js/old/compilacao_view' |
|||
import compilacaoNotas from './js/old/compilacao_notas' |
|||
|
|||
// import './js/compilacao_edit'
|
|||
|
|||
//import "./js/compilacao_edit";
|
|||
_.forEach(_.merge(_.merge(compilacao, compilacaoNotas), compilacaoView), function (func, key) { |
|||
window[key] = func |
|||
}) |
|||
|
|||
_.forEach(_.merge(_.merge(compilacao, compilacao_notas),compilacao_view), function(func, key) { |
|||
window[key] = func; |
|||
}); |
|||
|
|||
$(document).ready(function() { |
|||
setTimeout(function() { |
|||
var href = location.href.split("#"); |
|||
if (href.length == 2) { |
|||
$(document).ready(function () { |
|||
setTimeout(function () { |
|||
var href = location.href.split('#') |
|||
if (href.length === 2) { |
|||
try { |
|||
$("html, body").animate( |
|||
$('html, body').animate( |
|||
{ |
|||
scrollTop: |
|||
$("#dptt" + href[1]).offset().top - window.innerHeight / 9 |
|||
$('#dptt' + href[1]).offset().top - window.innerHeight / 9 |
|||
}, |
|||
0 |
|||
); |
|||
) |
|||
} catch (err) { |
|||
console.log(err); |
|||
console.log(err) |
|||
} |
|||
} |
|||
}, 100); |
|||
|
|||
$("#btn_font_menos").click(function() { |
|||
$(".dpt").css("font-size", "-=1"); |
|||
}); |
|||
$("#btn_font_mais").click(function() { |
|||
$(".dpt").css("font-size", "+=1"); |
|||
}); |
|||
|
|||
$(".dpt.bloco_alteracao .dpt").each(function() { |
|||
var nivel = parseInt($(this).attr("nivel")); |
|||
$(this).css("z-index", 15 - nivel); |
|||
}); |
|||
|
|||
onReadyNotasVides(); |
|||
|
|||
}); |
|||
}, 100) |
|||
|
|||
$('#btn_font_menos').click(function () { |
|||
$('.dpt').css('font-size', '-=1') |
|||
}) |
|||
$('#btn_font_mais').click(function () { |
|||
$('.dpt').css('font-size', '+=1') |
|||
}) |
|||
|
|||
$('.dpt.bloco_alteracao .dpt').each(function () { |
|||
var nivel = parseInt($(this).attr('nivel')) |
|||
$(this).css('z-index', 15 - nivel) |
|||
}) |
|||
window.onReadyNotasVides() |
|||
}) |
|||
|
|||
@ -1,6 +1,6 @@ |
|||
/* eslint-disable */ |
|||
import './css/jquery.Jcrop.min.css'; |
|||
import './css/image_cropping.css'; |
|||
import './css/jquery.Jcrop.min.css' |
|||
import './css/image_cropping.css' |
|||
|
|||
import './js/jquery.Jcrop.min'; |
|||
import './image_cropping'; |
|||
import './js/jquery.Jcrop.min' |
|||
import './image_cropping' |
|||
@ -1,19 +1,19 @@ |
|||
// eslint-disable-next-line
|
|||
require('imports-loader?window.jQuery=jquery!./jquery.runner.js') |
|||
|
|||
require("imports-loader?window.jQuery=jquery!./jquery.runner.js"); |
|||
import 'jquery-mask-plugin' |
|||
|
|||
import "jquery-mask-plugin"; |
|||
import 'webpack-jquery-ui/dialog' |
|||
import 'webpack-jquery-ui/sortable' |
|||
|
|||
import "webpack-jquery-ui/dialog"; |
|||
import "webpack-jquery-ui/sortable"; |
|||
import 'bootstrap' |
|||
|
|||
import "bootstrap"; |
|||
import './functions' |
|||
|
|||
import "./functions"; |
|||
|
|||
import "./image_cropping"; |
|||
import './image_cropping' |
|||
|
|||
window.jQuery = jQuery |
|||
window.$ = jQuery |
|||
|
|||
window.autorModal(); |
|||
window.refreshMask(); |
|||
window.autorModal() |
|||
window.refreshMask() |
|||
|
|||
@ -1,12 +1,12 @@ |
|||
import Vue from "vue"; |
|||
import App from "./App.vue"; |
|||
import router from "./router"; |
|||
import store from "./store"; |
|||
import Vue from "vue" |
|||
import App from "./App.vue" |
|||
import router from "./router" |
|||
import store from "./store" |
|||
|
|||
Vue.config.productionTip = false; |
|||
Vue.config.productionTip = false |
|||
|
|||
new Vue({ |
|||
router, |
|||
store, |
|||
render: h => h(App) |
|||
}).$mount("#app"); |
|||
}).$mount("#app") |
|||
|
|||
@ -1,10 +1,10 @@ |
|||
import Vue from "vue"; |
|||
import Router from "vue-router"; |
|||
import Vue from "vue" |
|||
import Router from "vue-router" |
|||
|
|||
Vue.use(Router); |
|||
Vue.use(Router) |
|||
|
|||
export default new Router({ |
|||
mode: "history", |
|||
base: process.env.BASE_URL, |
|||
routes: [] |
|||
}); |
|||
}) |
|||
|
|||
Loading…
Reference in new issue