Browse Source

ajustes de eslint em compilação

pull/2485/head
Leandro Roberto 7 years ago
parent
commit
03f2a7befb
  1. 14
      sapl-frontend/.eslintrc.js
  2. 15
      sapl-frontend/package.json
  3. 529
      sapl-frontend/src/apps/compilacao/js/old/compilacao.js
  4. 241
      sapl-frontend/src/apps/compilacao/js/old/compilacao_notas.js
  5. 155
      sapl-frontend/src/apps/compilacao/js/old/compilacao_view.js
  6. 67
      sapl-frontend/src/apps/compilacao/main.js
  7. 5
      sapl-frontend/src/apps/compilacao/scss/compilacao.scss
  8. 136
      sapl-frontend/src/global/image_cropping/image_cropping.js
  9. 8
      sapl-frontend/src/global/image_cropping/index.js
  10. 298
      sapl-frontend/src/global/jquery.runner.js
  11. 20
      sapl-frontend/src/global/main.js
  12. 12
      sapl-frontend/src/hellow/main.js
  13. 8
      sapl-frontend/src/hellow/router.js
  14. 6
      sapl-frontend/src/hellow/store.js
  15. 4
      sapl-frontend/src/hellow/views/Home.vue
  16. 2
      sapl-frontend/vue.config.js
  17. 2
      sapl/templates/compilacao/dispositivo_form_search.html

14
sapl-frontend/.eslintrc.js

@ -1,20 +1,30 @@
module.exports = { module.exports = {
root: true, root: true,
env: { env: {
browser: true,
node: true, node: true,
jquery: true jquery: true
}, },
extends: ["plugin:vue/essential", "@vue/prettier"], extends: [
"plugin:vue/essential",
'standard'
],
rules: { rules: {
'generator-star-spacing': 'off',
"no-console": process.env.NODE_ENV === "production" ? "error" : "off", "no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off"
}, },
// required to lint *.vue files
plugins: [
'vue'
],
parserOptions: { parserOptions: {
parser: "babel-eslint" parser: "babel-eslint"
}, },
globals: { globals: {
"$": true, "$": true,
"jQuery": true "jQuery": true,
'_': true
} }
}; };

15
sapl-frontend/package.json

@ -32,13 +32,20 @@
"@vue/cli-plugin-babel": "^3.3.0", "@vue/cli-plugin-babel": "^3.3.0",
"@vue/cli-plugin-eslint": "^3.3.0", "@vue/cli-plugin-eslint": "^3.3.0",
"@vue/cli-service": "^3.3.0", "@vue/cli-service": "^3.3.0",
"@vue/eslint-config-prettier": "^4.0.1",
"babel-eslint": "^10.0.1", "babel-eslint": "^10.0.1",
"css-loader": "^2.1.0", "css-loader": "^2.1.0",
"eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0",
"node-sass": "^4.9.0", "node-sass": "^4.9.0",
"sass-loader": "^7.0.1", "sass-loader": "^7.0.1",
"vue-template-compiler": "^2.5.21" "vue-template-compiler": "^2.5.21",
"eslint": "^5.12.0",
"eslint-config-standard": "^12.0.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^5.1.0"
} }
} }

529
sapl-frontend/src/apps/compilacao/js/old/compilacao.js

@ -1,287 +1,278 @@
function SetCookie (cookieName, cookieValue, nDays) {
let today = new Date()
function SetCookie(cookieName,cookieValue,nDays) { let expire = new Date()
var today = new Date(); if (nDays === null || nDays === 0) nDays = 1
var expire = new Date(); expire.setTime(today.getTime() + 3600000 * 24 * nDays)
if (nDays==null || nDays==0) nDays=1; document.cookie = cookieName + '=' + escape(cookieValue) +
expire.setTime(today.getTime() + 3600000*24*nDays); ';expires=' + expire.toGMTString()
document.cookie = cookieName+"="+escape(cookieValue) }
+ ";expires="+expire.toGMTString();
} function ReadCookie (cookieName) {
let theCookie = ' ' + document.cookie
function ReadCookie(cookieName) { let ind = theCookie.indexOf(' ' + cookieName + '=')
var theCookie=" "+document.cookie; if (ind === -1) ind = theCookie.indexOf(';' + cookieName + '=')
var ind=theCookie.indexOf(" "+cookieName+"="); if (ind === -1 || cookieName === '') return ''
if (ind==-1) ind=theCookie.indexOf(";"+cookieName+"="); let ind1 = theCookie.indexOf(';', ind + 1)
if (ind==-1 || cookieName=="") return ""; if (ind1 === -1) ind1 = theCookie.length
var ind1=theCookie.indexOf(";",ind+1); return unescape(theCookie.substring(ind + cookieName.length + 2, ind1))
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>')
function insertWaitAjax(element) { jQuery(element).append('<div style="text-align:center;"><i style="font-size: 200%;" class="fa fa-refresh fa-spin"></i></div>')
//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 () {
function DispositivoSearch(opts) { let formData = {}
$(function() { let containerDs = $('body').children('#container_ds')
let formData = {} if (containerDs.length > 0) {
var container_ds = $('body').children("#container_ds"); $(containerDs).remove()
if (container_ds.length > 0) }
$(container_ds).remove(); containerDs = $('<div id="container_ds"/>')
container_ds = $('<div id="container_ds"/>'); $('body').prepend(containerDs)
$('body').prepend(container_ds);
let fields = $('[data-sapl-ta="DispositivoSearch"]')
var fields = $("[data-sapl-ta='DispositivoSearch']"); fields.each(function () {
fields.each(function() { let field = $(this)
var field = $(this); let dataTypeSelection = field.attr('data-type-selection')
var data_type_selection = field.attr('data-type-selection'); let dataField = field.attr('data-field')
var data_field = field.attr('data-field'); let dataFunction = field.attr('data-function')
var data_function = field.attr('data-function');
let onChangeFieldSelects = function (event) {
var onChangeFieldSelects = function(event) { if (dataTypeSelection === 'checkbox') {
if (data_type_selection == 'checkbox') { let tas = field.find('input[name="ta_select_all"]') // tas - Textos Articulados
var tas = field.find('input[name="ta_select_all"]'); //tas - Textos Articulados tas.off()
tas.off();
tas.on('change', function (event) {
tas.on('change', function(event) { $(this).closest('ul').find('input[name="' + dataField + '"]').prop('checked', this.checked)
$(this).closest('ul').find('input[name="'+data_field+'"]').prop("checked", this.checked); // $(this).prop('checked', false)
//$(this).prop("checked", false); })
}); } else {
let dpts = field.find('input')
dpts.off()
} dpts.attr('type', 'hidden')
else { $('<a class="text-danger">')
var dpts = field.find('input'); .insertBefore(dpts)
dpts.off() .append($('<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>'))
dpts.attr('type', 'hidden'); .on('click', function () {
$('<a class="text-danger">') if ($(this).closest('ul').find('li').length === 2) {
.insertBefore(dpts) $(this).closest('ul').remove()
.append($('<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>')) } else {
.on('click', function() { $(this).closest('li').remove()
if ($(this).closest('ul').find('li').length == 2) }
$(this).closest('ul').remove(); })
else
$(this).closest('li').remove();
});
}
} }
onChangeFieldSelects(); }
onChangeFieldSelects()
var onChangeParamTA = function(event) {
let onChangeParamTA = function (event) {
var tipo_ta = $("select[name='tipo_ta']").val(); let tipoTa = $('select[name="tipo_ta"]').val()
var tipo_model = $("select[name='tipo_model']").val(); let tipoModel = $('select[name="tipo_model"]').val()
var num_ta = $("input[name='num_ta']").val(); let numTa = $('input[name="num_ta"]').val()
var ano_ta = $("input[name='ano_ta']").val(); let anoTa = $('input[name="ano_ta"]').val()
var dispositivos_internos = $("input[name='dispositivos_internos']:checked").val(); let dispositivosInternos = $('input[name="dispositivos_internos"]:checked').val()
var rotulo_dispositivo = $("input[name='rotulo_dispositivo']").val(); let rotuloDispositivo = $('input[name="rotulo_dispositivo"]').val()
var texto_dispositivo = $("input[name='texto_dispositivo']").val(); let textoDispositivo = $('input[name="texto_dispositivo"]').val()
var max_results = $("select[name='max_results']").val(); let maxResults = $('select[name="max_results"]').val()
var url = ''; let url = ''
if (rotulo_dispositivo.length > 0 || texto_dispositivo.length > 0) { if (rotuloDispositivo.length > 0 || textoDispositivo.length > 0) {
$("input[name='dispositivos_internos']").prop('disabled', false); $('input[name="dispositivos_internos"]').prop('disabled', false)
$("input[name='dispositivos_internos']").each((idx, element) => { $('input[name="dispositivos_internos"]').each((idx, element) => {
element.parentElement.classList.remove('disabled') element.parentElement.classList.remove('disabled')
}); })
$("input[name='dispositivos_internos']").closest('#div_id_dispositivos_internos').css('opacity','1'); $('input[name="dispositivos_internos"]').closest('#div_id_dispositivos_internos').css('opacity', '1')
} } else {
else { $('input[name="dispositivos_internos"]').filter('[value="False"]').prop('checked', true)
$("input[name='dispositivos_internos']").filter('[value="False"]').prop('checked', true); $('input[name="dispositivos_internos"]').prop('disabled', 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);
});
}
}); $('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) { window.localStorage.setItem('dispositivo_search_form_data', JSON.stringify(formData))
var rotulo_dispositivo = $("input[name='rotulo_dispositivo']").val();
var texto_dispositivo = $("input[name='texto_dispositivo']").val(); url = '/ta/search_fragment_form'
var dispositivos_internos = $("input[name='dispositivos_internos']:checked").val(); $('.result-busca-dispositivo').html('')
insertWaitAjax('.result-busca-dispositivo')
if (rotulo_dispositivo.length > 0 || texto_dispositivo.length > 0) { $.get(url, formData).done(function (data) {
$("input[name='dispositivos_internos']").prop('disabled', false); $('.result-busca-dispositivo').html(data)
$("input[name='dispositivos_internos']").each((idx, element) => { // OptionalCustomFrontEnd().init()
element.parentElement.classList.remove('disabled') if (dataTypeSelection === 'checkbox') {
}); let tas = $('.result-busca-dispositivo').find('input[name="ta_select_all"]')
$("input[name='dispositivos_internos']").closest('#div_id_dispositivos_internos').css('opacity','1'); tas.off()
} tas.on('change', function (event) {
else { $(this).closest('ul').find('input[name="' + dataField + '"]').prop('checked', this.checked)
$("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';
} }
})
}
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) let buttonDs = field.children('#buttonDs')
$(button_ds).remove(); if (buttonDs.length > 0) {
button_ds = $('<div id="button_ds" class="clearfix"/>'); $(buttonDs).remove()
field.prepend(button_ds); }
buttonDs = $('<div id="buttonDs" class="clearfix"/>')
var btn_open_search = $('<button>') field.prepend(buttonDs)
.text(opts['text_button'])
.attr('type','button') let btnOpenSearch = $('<button>')
.attr('class','btn btn-sm btn-success btn-modal-open'); .text(opts['text_button'])
button_ds.append(btn_open_search); .attr('type', 'button')
btn_open_search.on('click', function() { .attr('class', 'btn btn-sm btn-success btn-modal-open')
$.get(opts['url_form'], function(data) { buttonDs.append(btnOpenSearch)
container_ds.html(data); btnOpenSearch.on('click', function () {
var modal_ds = $('#modal-ds'); $.get(opts['url_form'], function (data) {
//OptionalCustomFrontEnd().init(); containerDs.html(data)
let modalDs = $('#modal-ds')
modal_ds.find("select[name='tipo_ta']").change(function(event) { // OptionalCustomFrontEnd().init()
var url = '';
url = '/ta/search_fragment_form?action=get_tipos&tipo_ta='+this.value; modalDs.find('select[name="tipo_ta"]').change(function (event) {
modal_ds.find("label[for='id_tipo_model']").html('Tipos de ' + this.children[this.selectedIndex].innerHTML); let url = ''
url = '/ta/search_fragment_form?action=get_tipos&tipo_ta=' + this.value
var select = modal_ds.find("select[name='tipo_model']"); modalDs.find('label[for="id_tipo_model"]').html('Tipos de ' + this.children[this.selectedIndex].innerHTML)
select.empty();
$('<option value="">Carregando...</option>').appendTo(select); let select = modalDs.find('select[name="tipo_model"]')
select.empty()
$.get(url).done(function( data ) { $('<option value="">Carregando...</option>').appendTo(select)
select.empty();
for(var item in data) { $.get(url).done(function (data) {
for (var i in data[item]) select.empty()
select.append($("<option>").attr('value',i).text(data[item][i])); for (let item in data) {
} for (let i in data[item]) {
setTimeout(function() { select.append($('<option>').attr('value', i).text(data[item][i]))
$("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;
} }
}
setTimeout(function () {
$('select[name="tipo_model"]').val(formData.tipo_model)
}, 200)
// select.change(onChangeParamTA)
})
})
//insere os dispositivos não presentes /* modalDs.find('input[name="num_ta"], '
var inputs_for_this = $(this).find('input'); +'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() { // insere os dispositivos não presentes
if (ul_lista.find("#"+this.id).length > 0) let inputForThis = $(this).find('input')
return;
ul_lista.append($(this).closest('li'));
});
});
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) modalDs.modal('hide')
opts['post_selected'](opts['params_post_selected'])
}); 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 { try {
formData = JSON.parse(window.localStorage.getItem("dispositivo_search_form_data")) $('select[name="tipo_ta"]').val(formData.tipo_ta)
$("input[name='num_ta']").val(formData.num_ta); $('select[name="tipo_ta"]').trigger('change')
$("input[name='ano_ta']").val(formData.ano_ta); // modalDs.find('.btn-busca').trigger('click')
$("input[name='rotulo_dispositivo']").val(formData.rotulo); // onChangeParamTA()
$("input[name='texto_dispositivo']").val(formData.texto);
$("select[name='max_results']").val(formData.max_results);
} catch (e) { } catch (e) {
console.log(e)
} }
}, 200)
setTimeout(function() {
try { modalDs.modal('show')
$("select[name='tipo_ta']").val(formData.tipo_ta); })
$("select[name='tipo_ta']").trigger('change') })
//modal_ds.find(".btn-busca").trigger('click') })
//onChangeParamTA(); })
} catch (e) { }
} export default {
SetCookie,
}, 200) ReadCookie,
insertWaitAjax,
modal_ds.modal('show'); DispositivoSearch
}
})
});
});
});
}
export default {
SetCookie,
ReadCookie,
insertWaitAjax,
DispositivoSearch
}

241
sapl-frontend/src/apps/compilacao/js/old/compilacao_notas.js

@ -1,145 +1,134 @@
function onEventsDneExec(pk, model) { function onEventsDneExec (pk, model) {
$('html, body').animate({
$('html, body').animate({ scrollTop: $('#dne' + pk).offset().top - window.innerHeight / 5
scrollTop: $('#dne' + pk ).offset().top - window.innerHeight / 5 }, 300)
}, 300);
window.refreshDatePicker()
refreshDatePicker();
$('#dne' + pk + ' #button-id-submit-form').click(onSubmitEditNVForm)
$('#dne'+pk+" #button-id-submit-form").click(onSubmitEditNVForm); $('#dne' + pk + ' .btn-close-container').click(function () {
$('#dne'+pk+" .btn-close-container").click(function(){ $(this).closest('.dne-nota').removeClass('dne-nota')
$(this).closest('.dne-nota').removeClass('dne-nota'); $(this).closest('.dne-form').html('')
$(this).closest('.dne-form').html(''); })
});
if (model === 'nota') {
if (model == 'nota') { $('#dne' + pk + ' select[name="tipo"]').change(function (event) {
$('#dne'+pk+" select[name='tipo']").change(function(event) { let url = ''
var url = ''; url = 'text/' + pk + '/nota/create?action=modelo_nota&id_tipo=' + this.value
url = 'text/'+pk+'/nota/create?action=modelo_nota&id_tipo='+this.value; $.get(url).done(function (data) {
$.get(url).done(function( data ) { $('#dne' + pk + ' textarea[name="texto"]').val(data)
$('#dne'+pk+" textarea[name='texto']").val(data); })
}); })
}); } else if (model === 'vide') {
} window.DispositivoSearch({
else if (model == 'vide') { 'url_form': '/ta/search_form',
'text_button': 'Definir Dispositivo'
DispositivoSearch({ })
'url_form': '/ta/search_form', }
'text_button': 'Definir Dispositivo'
});
}
} }
function onSubmitEditNVForm(event) { function onSubmitEditNVForm (event) {
let url = ''
var url = ''; let model = 'nota'
var model = 'nota'; let idEdit = null
var id_edit = null; let idDispositivo = $('#idDispositivo').val()
var id_dispositivo = $('#id_dispositivo').val();
if (idDispositivo === null) { // trata-se de um vide
if (id_dispositivo == null) { // trata-se de um vide // $('#idDispositivo_ref').remove()
//$('#id_dispositivo_ref').remove(); idDispositivo = $('#idDispositivo_base').val()
id_dispositivo = $('#id_dispositivo_base').val(); model = 'vide'
model='vide'; }
}
idEdit = $('#id_pk').val()
id_edit = $('#id_pk').val(); url = 'text/' + idDispositivo + '/' + model + '/'
url = 'text/'+id_dispositivo+'/'+model+'/' if (idEdit === null || idEdit === '') {
if (id_edit == null || id_edit == '') url += 'create'
url += 'create'; } else {
else url += idEdit + '/edit'
url += id_edit+'/edit'; }
console.log($('#dne'+id_dispositivo+" form").serialize()); console.log($('#dne' + idDispositivo + ' form').serialize())
$.post( url, $('#dne'+id_dispositivo+" form").serialize(), function(data) { $.post(url, $('#dne' + idDispositivo + ' form').serialize(), function (data) {
if (typeof data === 'string') {
if (typeof data == "string") { if (data.indexOf('<form') >= 0) {
if (data.indexOf('<form') >= 0) { $('#dne' + idDispositivo + ' .dne-form').html(data)
$('#dne'+id_dispositivo+' .dne-form').html(data); onEventsDneExec(idDispositivo, model)
onEventsDneExec(id_dispositivo, model); } else {
} $('#dne' + idDispositivo + ' .dne-form').closest('.dpt').html(data)
else { onReadyNotasVides()
$('#dne'+id_dispositivo+' .dne-form').closest('.dpt').html(data) try {
onReadyNotasVides(); $('html, body').animate({
try { scrollTop: $('#dne' + idDispositivo).offset().top - window.innerHeight / 3
$('html, body').animate({ }, 300)
scrollTop: $('#dne' + id_dispositivo ).offset().top - window.innerHeight / 3 } catch (err) {
}, 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'); let idDispositivo = $(event).closest('.dn').attr('pk')
var id_delete = $(event).attr('pk'); let idDelete = $(event).attr('pk')
var url = 'text/'+id_dispositivo+'/'+model+'/'+id_delete+'/delete'; let url = 'text/' + idDispositivo + '/' + model + '/' + idDelete + '/delete'
$.get( url, function(data) { $.get(url, function (data) {
$('#dne'+id_dispositivo+' .dne-form').closest('.dpt').html(data) $('#dne' + idDispositivo + ' .dne-form').closest('.dpt').html(data)
onReadyNotasVides(); onReadyNotasVides()
} })
);
} }
function getForm(_this) { function getForm (_this) {
let url = ''
var url = ''; let model = $(_this).attr('model')
var model = $(_this).attr('model'); let idDispositivo = $('.dne-nota .dne-form').closest('.dne').attr('pk')
var id_dispositivo = $('.dne-nota .dne-form').closest('.dne').attr('pk'); if (idDispositivo != null) {
if (id_dispositivo != null) { $('#dne' + idDispositivo).removeClass('dne-nota')
$('#dne'+id_dispositivo).removeClass('dne-nota'); $('#dne' + idDispositivo + ' .dne-form').html('')
$('#dne'+id_dispositivo+' .dne-form').html(''); }
}
if (_this.className.indexOf('create') >= 0) {
if (_this.className.indexOf('create') >= 0 ) { idDispositivo = $(_this).attr('pk')
id_dispositivo = $(_this).attr('pk'); url = 'text/' + idDispositivo + '/' + model + '/create'
url = 'text/'+id_dispositivo+'/'+model+'/create'; } else if (_this.className.indexOf('edit') >= 0) {
} let idEdit = $(_this).attr('pk')
else if (_this.className.indexOf('edit') >= 0 ) { idDispositivo = $(_this).closest('.dn').attr('pk')
var id_edit = $(_this).attr('pk'); url = 'text/' + idDispositivo + '/' + model + '/' + idEdit + '/edit'
id_dispositivo = $(_this).closest('.dn').attr('pk'); }
url = 'text/'+id_dispositivo+'/'+model+'/'+id_edit+'/edit'
} $('#dne' + idDispositivo).addClass('dne-nota')
$('#dne'+id_dispositivo).addClass('dne-nota'); $.get(url).done(function (data) {
$('#dne' + idDispositivo + ' .dne-form').html(data)
$.get(url).done(function( data ) { onEventsDneExec(idDispositivo, model)
$('#dne'+id_dispositivo+' .dne-form').html(data); }).fail(function () {
onEventsDneExec(id_dispositivo, model); onReadyNotasVides()
}).fail(function() { })
onReadyNotasVides();
});
} }
function onReadyNotasVides() { function onReadyNotasVides () {
$('.dne-nota').removeClass('dne-nota')
$('.dne-nota').removeClass('dne-nota'); $('.dne-form').html('')
$('.dne-form').html('');
$('.dne .btn-action').off(); $('.dne .btn-action').off()
$('.dn .btn-action').off(); $('.dn .btn-action').off()
$('.dne .btn-action, .dn .btn-action').not('.btn-nota-delete').not('.btn-vide-delete').click(function(){ $('.dne .btn-action, .dn .btn-action').not('.btn-nota-delete').not('.btn-vide-delete').click(function () {
getForm(this); getForm(this)
}); })
$('.dn .btn-nota-delete, .dn .btn-vide-delete').click(function(){ $('.dn .btn-nota-delete, .dn .btn-vide-delete').click(function () {
onDelete(this); onDelete(this)
}); })
} }
export default { export default {
onEventsDneExec, onEventsDneExec,
onSubmitEditNVForm, onSubmitEditNVForm,
onDelete, onDelete,
onReadyNotasVides onReadyNotasVides
} }

155
sapl-frontend/src/apps/compilacao/js/old/compilacao_view.js

@ -1,11 +1,11 @@
let JsDiff = require("diff"); let JsDiff = require('diff')
function isElementInViewport(el) { function isElementInViewport (el) {
if (typeof jQuery === "function" && el instanceof jQuery) { if (typeof jQuery === 'function' && el instanceof jQuery) {
el = el[0]; el = el[0]
} }
var rect = el.getBoundingClientRect(); let rect = el.getBoundingClientRect()
return ( return (
rect.top >= 0 && rect.top >= 0 &&
@ -13,92 +13,91 @@ function isElementInViewport(el) {
rect.bottom <= rect.bottom <=
(window.innerHeight || document.documentElement.clientHeight) && (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth) rect.right <= (window.innerWidth || document.documentElement.clientWidth)
); )
} }
function textoMultiVigente(item, diff) { function textoMultiVigente (item, diff) {
var elv = null; let elv = null
var ldpts = $(".dptt"); let ldpts = $('.dptt')
for (var i = 0; i < ldpts.length; i++) { for (let i = 0; i < ldpts.length; i++) {
if ($(ldpts[i]).hasClass("displaynone")) continue; if ($(ldpts[i]).hasClass('displaynone')) continue
if (isElementInViewport(ldpts[i])) { if (isElementInViewport(ldpts[i])) {
if (i + 1 < ldpts.length) elv = ldpts[i + 1]; if (i + 1 < ldpts.length) elv = ldpts[i + 1]
else { else {
elv = ldpts[i]; elv = ldpts[i]
} }
break; break
} }
} }
$(".cp .tipo-vigencias a").removeClass("selected"); $('.cp .tipo-vigencias a').removeClass('selected')
$(item).addClass("selected"); $(item).addClass('selected')
$(".dptt.desativado").removeClass("displaynone"); $('.dptt.desativado').removeClass('displaynone')
$(".dtxt").removeClass("displaynone"); $('.dtxt').removeClass('displaynone')
$(".dtxt.diff").remove(); $('.dtxt.diff').remove()
$(".nota-alteracao").removeClass("displaynone"); $('.nota-alteracao').removeClass('displaynone')
if (diff) { if (diff) {
$(".dtxt[id^='da'").each(function() { $('.dtxt[id^="da"').each(function () {
if ( if ($(this)
$(this) .html()
.html() .search(/<\/\w+>/g) > 0) {
.search(/<\/\w+>/g) > 0 return
) }
return;
var pk = $(this).attr("pk"); let pk = $(this).attr('pk')
var pks = $(this).attr("pks"); let pks = $(this).attr('pks')
var a = $("#d" + pks) let a = $('#d' + pks)
.contents() .contents()
.filter(function() { .filter(function () {
return this.nodeType === Node.TEXT_NODE; return this.nodeType === Node.TEXT_NODE
}); })
var b = $("#da" + pk) let b = $('#da' + pk)
.contents() .contents()
.filter(function() { .filter(function () {
return this.nodeType === Node.TEXT_NODE; return this.nodeType === Node.TEXT_NODE
}); })
var diff = JsDiff.diffWordsWithSpace($(a).text(), $(b).text()); let diff = JsDiff.diffWordsWithSpace($(a).text(), $(b).text())
if (diff.length > 0) { if (diff.length > 0) {
$("#d" + pks) $('#d' + pks)
.closest(".desativado") .closest('.desativado')
.addClass("displaynone"); .addClass('displaynone')
var clone = $("#da" + pk).clone(); let clone = $('#da' + pk).clone()
$("#da" + pk).after(clone); $('#da' + pk).after(clone)
$("#da" + pk).addClass("displaynone"); $('#da' + pk).addClass('displaynone')
$(clone) $(clone)
.addClass("diff") .addClass('diff')
.html(""); .html('')
diff.forEach(function(part) { diff.forEach(function (part) {
//var color = part.added ? "#018" : part.removed ? "#faa" : ""; // let color = part.added ? '#018' : part.removed ? '#faa' : ''
var span = document.createElement("span"); let span = document.createElement('span')
var value = part.value; let value = part.value
if (part.removed) { if (part.removed) {
$(span).addClass("desativado"); $(span).addClass('desativado')
value += " "; value += ' '
} else if (part.added) { } else if (part.added) {
$(span).addClass("added"); $(span).addClass('added')
} }
span.appendChild(document.createTextNode(value)); span.appendChild(document.createTextNode(value))
$(clone).append(span); $(clone).append(span)
}); })
} }
}); })
//textoVigente(item, true); // textoVigente(item, true)
} }
if (elv) { if (elv) {
try { try {
$("html, body").animate( $('html, body').animate(
{ {
scrollTop: scrollTop:
$(elv) $(elv)
@ -106,37 +105,37 @@ function textoMultiVigente(item, diff) {
.offset().top - 60 .offset().top - 60
}, },
0 0
); )
} catch (err) { } catch (err) {
console.log(err); console.log(err)
} }
} }
} }
function textoVigente(item, link) { function textoVigente (item, link) {
var elv = null; let elv = null
var ldpts = $(".dptt"); let ldpts = $('.dptt')
for (var i = 0; i < ldpts.length; i++) { for (let i = 0; i < ldpts.length; i++) {
if ($(ldpts[i]).hasClass("displaynone")) continue; if ($(ldpts[i]).hasClass('displaynone')) continue
if (isElementInViewport(ldpts[i])) { if (isElementInViewport(ldpts[i])) {
if (i + 1 < ldpts.length) elv = ldpts[i + 1]; if (i + 1 < ldpts.length) elv = ldpts[i + 1]
else { else {
elv = ldpts[i]; elv = ldpts[i]
} }
break; break
} }
} }
$(".cp .tipo-vigencias a").removeClass("selected"); $('.cp .tipo-vigencias a').removeClass('selected')
$(item).addClass("selected"); $(item).addClass('selected')
$(".dptt.desativado").addClass("displaynone"); $('.dptt.desativado').addClass('displaynone')
$(".nota-alteracao").removeClass("displaynone"); $('.nota-alteracao').removeClass('displaynone')
if (!link) $(".nota-alteracao").addClass("displaynone"); if (!link) $('.nota-alteracao').addClass('displaynone')
if (elv) { if (elv) {
try { try {
$("html, body").animate( $('html, body').animate(
{ {
scrollTop: scrollTop:
$(elv) $(elv)
@ -144,9 +143,9 @@ function textoVigente(item, link) {
.offset().top - 60 .offset().top - 60
}, },
0 0
); )
} catch (err) { } catch (err) {
console.log(err); console.log(err)
} }
} }
} }
@ -155,4 +154,4 @@ export default {
isElementInViewport, isElementInViewport,
textoMultiVigente, textoMultiVigente,
textoVigente textoVigente
}; }

67
sapl-frontend/src/apps/compilacao/main.js

@ -1,50 +1,47 @@
// TODO: migrar compilacao para VueJs // TODO: migrar compilacao para VueJs
import "./scss/compilacao.scss"; import './scss/compilacao.scss'
import compilacao from "./js/old/compilacao"; import 'bootstrap'
import compilacao_view from "./js/old/compilacao_view";
import compilacao_notas from "./js/old/compilacao_notas";
import _ from "lodash";
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) { $(document).ready(function () {
window[key] = func; 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 { try {
$("html, body").animate( $('html, body').animate(
{ {
scrollTop: scrollTop:
$("#dptt" + href[1]).offset().top - window.innerHeight / 9 $('#dptt' + href[1]).offset().top - window.innerHeight / 9
}, },
0 0
); )
} catch (err) { } catch (err) {
console.log(err); console.log(err)
} }
} }
}, 100); }, 100)
$("#btn_font_menos").click(function() { $('#btn_font_menos').click(function () {
$(".dpt").css("font-size", "-=1"); $('.dpt').css('font-size', '-=1')
}); })
$("#btn_font_mais").click(function() { $('#btn_font_mais').click(function () {
$(".dpt").css("font-size", "+=1"); $('.dpt').css('font-size', '+=1')
}); })
$(".dpt.bloco_alteracao .dpt").each(function() { $('.dpt.bloco_alteracao .dpt').each(function () {
var nivel = parseInt($(this).attr("nivel")); var nivel = parseInt($(this).attr('nivel'))
$(this).css("z-index", 15 - nivel); $(this).css('z-index', 15 - nivel)
}); })
window.onReadyNotasVides()
onReadyNotasVides(); })
});

5
sapl-frontend/src/apps/compilacao/scss/compilacao.scss

@ -306,6 +306,9 @@ a:link:after, a:visited:after {
} }
} }
.card-header {
font-size: 1.7rem;
}
.dn { /* Notas de Dispositivo*/ .dn { /* Notas de Dispositivo*/
font-weight: normal; font-weight: normal;
@ -464,7 +467,7 @@ a:link:after, a:visited:after {
.dne-form { .dne-form {
margin: 1em -2em 0em; margin: 1em -2em 0em;
text-align: left; text-align: left;
font-size: 1.6rem; font-size: 1rem;
} }
} }

136
sapl-frontend/src/global/image_cropping/image_cropping.js

@ -1,6 +1,6 @@
/* eslint-disable */ /* eslint-disable */
var image_cropping = (function ($) { var image_cropping = (function ($) {
var jcrop = {}; var jcrop = {}
function init() { function init() {
$('input.image-ratio').each(function() { $('input.image-ratio').each(function() {
var $this = $(this), var $this = $(this),
@ -10,40 +10,40 @@ var image_cropping = (function ($) {
// there should only be one file field we're referencing but in special cases // there should only be one file field we're referencing but in special cases
// there can be several. Deal with it gracefully. // there can be several. Deal with it gracefully.
$image_input = $('input.crop-thumb[data-field-name=' + field + ']:first'); $image_input = $('input.crop-thumb[data-field-name=' + field + ']:first')
// skip this image if it's empty and hide the whole field, within admin and by itself // skip this image if it's empty and hide the whole field, within admin and by itself
if (!$image_input.length || $image_input.data('thumbnail-url') === undefined) { if (!$image_input.length || $image_input.data('thumbnail-url') === undefined) {
$this.hide().parents('div.form-row:first').hide(); $this.hide().parents('div.form-row:first').hide()
return; return
} }
// check if the image field should be hidden // check if the image field should be hidden
if ($image_input.data('hide-field')) { if ($image_input.data('hide-field')) {
$image_input.hide().parents('div.form-row:first').hide(); $image_input.hide().parents('div.form-row:first').hide()
} }
var image_id = $this.attr('id') + '-image', var image_id = $this.attr('id') + '-image',
org_width = $image_input.data('org-width'), org_width = $image_input.data('org-width'),
org_height = $image_input.data('org-height'), org_height = $image_input.data('org-height'),
min_width = $this.data('min-width'), min_width = $this.data('min-width'),
min_height = $this.data('min-height'); min_height = $this.data('min-height')
var is_image_portrait = (org_height > org_width); var is_image_portrait = (org_height > org_width)
var is_select_portrait = (min_height > min_width); var is_select_portrait = (min_height > min_width)
if ($this.data('adapt-rotation') === true) { if ($this.data('adapt-rotation') === true) {
if (is_image_portrait != is_select_portrait) { if (is_image_portrait != is_select_portrait) {
// cropping height/width need to be switched, picture is in portrait mode // cropping height/width need to be switched, picture is in portrait mode
var x = min_width; var x = min_width
min_width = min_height; min_width = min_height
min_height = x; min_height = x
} }
} }
var $image = $('<img>', { var $image = $('<img>', {
'id': image_id, 'id': image_id,
'src': $image_input.data('thumbnail-url') 'src': $image_input.data('thumbnail-url')
}); })
var options = { var options = {
minSize: [5, 5], minSize: [5, 5],
@ -51,152 +51,152 @@ var image_cropping = (function ($) {
trueSize: [org_width, org_height], trueSize: [org_width, org_height],
onSelect: update_selection($this), onSelect: update_selection($this),
addClass: ($this.data('size-warning') && ((org_width < min_width) || (org_height < min_height))) ? 'size-warning jcrop-image': 'jcrop-image' addClass: ($this.data('size-warning') && ((org_width < min_width) || (org_height < min_height))) ? 'size-warning jcrop-image': 'jcrop-image'
}; }
if ($this.data('ratio')) { if ($this.data('ratio')) {
options['aspectRatio'] = $this.data('ratio'); options['aspectRatio'] = $this.data('ratio')
} }
if ($this.data('box_max_width')) { if ($this.data('box_max_width')) {
options['boxWidth'] = $this.data('box_max_width'); options['boxWidth'] = $this.data('box_max_width')
} }
if ($this.data('box_max_height')) { if ($this.data('box_max_height')) {
options['boxHeight'] = $this.data('box_max_height'); options['boxHeight'] = $this.data('box_max_height')
} }
var cropping_disabled = false; var cropping_disabled = false
if($this.val()[0] == "-"){ if($this.val()[0] == "-"){
cropping_disabled = true; cropping_disabled = true
$this.val($this.val().substr(1)); $this.val($this.val().substr(1))
} }
// is the image bigger than the minimal cropping values? // is the image bigger than the minimal cropping values?
// otherwise lock cropping area on full image // otherwise lock cropping area on full image
var initial; var initial
if ($this.val()) { if ($this.val()) {
initial = initial_cropping($this.val()); initial = initial_cropping($this.val())
} else { } else {
initial = max_cropping(min_width, min_height, org_width, org_height); initial = max_cropping(min_width, min_height, org_width, org_height)
// set cropfield to initial value // set cropfield to initial value
$this.val(initial.join(',')); $this.val(initial.join(','))
} }
$.extend(options, {setSelect: initial}); $.extend(options, {setSelect: initial})
// hide the input field, show image to crop instead // hide the input field, show image to crop instead
$this.hide().after($image); $this.hide().after($image)
$('#' + image_id).Jcrop(options, function(){jcrop[image_id]=this;}); $('#' + image_id).Jcrop(options, function(){jcrop[image_id]=this;})
if ($this.data('allow-fullsize') === true) { if ($this.data('allow-fullsize') === true) {
if(cropping_disabled){ if(cropping_disabled){
jcrop[image_id].release(); jcrop[image_id].release()
$this.val('-'+$this.val()); $this.val('-'+$this.val())
} }
var label = 'allow-fullsize-'+image_id; var label = 'allow-fullsize-'+image_id
var checked = cropping_disabled ? '' : ' checked="checked"'; var checked = cropping_disabled ? '' : ' checked="checked"'
var fullsize = $('<div class="field-box allow-fullsize">' + var fullsize = $('<div class="field-box allow-fullsize">' +
'<input type="checkbox" id="'+label+'" name="'+label+'"'+checked+'></div>'); '<input type="checkbox" id="'+label+'" name="'+label+'"'+checked+'></div>')
if ($this.parent().find('.help').length) { if ($this.parent().find('.help').length) {
fullsize.insertBefore($this.parent().find('.help')); fullsize.insertBefore($this.parent().find('.help'))
} else { } else {
fullsize.appendTo($this.parent()); fullsize.appendTo($this.parent())
} }
$('#'+label).click(function(){ $('#'+label).click(function(){
if (cropping_disabled === true){ if (cropping_disabled === true){
$this.val($this.val().substr(1)); $this.val($this.val().substr(1))
jcrop[image_id].setSelect($this.val().split(',')); jcrop[image_id].setSelect($this.val().split(','))
cropping_disabled = false; cropping_disabled = false
} else { } else {
$this.val('-'+$this.val()); $this.val('-'+$this.val())
jcrop[image_id].release(); jcrop[image_id].release()
cropping_disabled = true; cropping_disabled = true
} }
}); })
$this.parent().find('.jcrop-tracker').mousedown(function(){ $this.parent().find('.jcrop-tracker').mousedown(function(){
if (cropping_disabled){ if (cropping_disabled){
$('#'+label).attr('checked','checked'); $('#'+label).attr('checked','checked')
cropping_disabled = false; cropping_disabled = false
} }
}); })
} }
}); })
} }
function max_cropping (width, height, image_width, image_height) { function max_cropping (width, height, image_width, image_height) {
var ratio = width/height; var ratio = width/height
var offset; var offset
if (image_width < image_height * ratio) { if (image_width < image_height * ratio) {
// width fits fully, height needs to be cropped // width fits fully, height needs to be cropped
offset = Math.round((image_height-(image_width/ratio))/2); offset = Math.round((image_height-(image_width/ratio))/2)
return [0, offset, image_width, image_height - offset]; return [0, offset, image_width, image_height - offset]
} }
// height fits fully, width needs to be cropped // height fits fully, width needs to be cropped
offset = Math.round((image_width-(image_height * ratio))/2); offset = Math.round((image_width-(image_height * ratio))/2)
return [offset, 0, image_width - offset, image_height]; return [offset, 0, image_width - offset, image_height]
} }
function initial_cropping (val) { function initial_cropping (val) {
if (val === '') { return; } if (val === '') { return; }
var s = val.split(','); var s = val.split(',')
return [ return [
parseInt(s[0], 10), parseInt(s[0], 10),
parseInt(s[1], 10), parseInt(s[1], 10),
parseInt(s[2], 10), parseInt(s[2], 10),
parseInt(s[3], 10) parseInt(s[3], 10)
]; ]
} }
function _update_selection (sel, $crop_field) { function _update_selection (sel, $crop_field) {
if ($crop_field.data('size-warning')) { if ($crop_field.data('size-warning')) {
crop_indication(sel, $crop_field); crop_indication(sel, $crop_field)
} }
$crop_field.val(new Array( $crop_field.val(new Array(
Math.round(sel.x), Math.round(sel.x),
Math.round(sel.y), Math.round(sel.y),
Math.round(sel.x2), Math.round(sel.x2),
Math.round(sel.y2) Math.round(sel.y2)
).join(',')); ).join(','))
} }
function update_selection ($crop_field) { function update_selection ($crop_field) {
return function(sel) { _update_selection(sel, $crop_field); }; return function(sel) { _update_selection(sel, $crop_field); }
} }
function crop_indication (sel, $crop_field) { function crop_indication (sel, $crop_field) {
// indicate if cropped area gets smaller than the specified minimal cropping // indicate if cropped area gets smaller than the specified minimal cropping
var $jcrop_holder = $crop_field.siblings('.jcrop-holder'); var $jcrop_holder = $crop_field.siblings('.jcrop-holder')
var min_width = $crop_field.data("min-width"); var min_width = $crop_field.data("min-width")
var min_height = $crop_field.data("min-height"); var min_height = $crop_field.data("min-height")
if ((sel.w < min_width) || (sel.h < min_height)) { if ((sel.w < min_width) || (sel.h < min_height)) {
$jcrop_holder.addClass('size-warning'); $jcrop_holder.addClass('size-warning')
} else { } else {
$jcrop_holder.removeClass('size-warning'); $jcrop_holder.removeClass('size-warning')
} }
} }
return { return {
init: init, init: init,
jcrop: jcrop jcrop: jcrop
}; }
})(jQuery); })(jQuery)
jQuery(function() { jQuery(function() {
/*var image_cropping_jquery_url = jQuery('.image-ratio:first').data('jquery-url'); /*var image_cropping_jquery_url = jQuery('.image-ratio:first').data('jquery-url')
if (image_cropping_jquery_url == "None") { if (image_cropping_jquery_url == "None") {
// JQUERY_URL is set to `none`. We therefore use the existing version of // JQUERY_URL is set to `none`. We therefore use the existing version of
// jQuery and leave it otherwise untouched. // jQuery and leave it otherwise untouched.
jQ = jQuery; jQ = jQuery
} else { } else {
// JQUERY_URL is specified. Image Cropping's jQuery is included in no conflict mode, // JQUERY_URL is specified. Image Cropping's jQuery is included in no conflict mode,
jQ = jQuery.noConflict(true); jQ = jQuery.noConflict(true)
} }
jQ(function() {image_cropping.init();});*/ jQ(function() {image_cropping.init();});*/
$(function() { $(function() {
image_cropping.init(); image_cropping.init()
}); })
}); })

8
sapl-frontend/src/global/image_cropping/index.js

@ -1,6 +1,6 @@
/* eslint-disable */ /* eslint-disable */
import './css/jquery.Jcrop.min.css'; import './css/jquery.Jcrop.min.css'
import './css/image_cropping.css'; import './css/image_cropping.css'
import './js/jquery.Jcrop.min'; import './js/jquery.Jcrop.min'
import './image_cropping'; import './image_cropping'

298
sapl-frontend/src/global/jquery.runner.js

@ -5,101 +5,101 @@
* Copyright (c) 2014 Jyrki Laurila <https://github.com/jylauril> * Copyright (c) 2014 Jyrki Laurila <https://github.com/jylauril>
*/ */
(function() { (function() {
var Runner, formatTime, meta, pad, runners, uid, _$, _requestAnimationFrame, _uid; var Runner, formatTime, meta, pad, runners, uid, _$, _requestAnimationFrame, _uid
meta = { meta = {
version: "2.3.3", version: "2.3.3",
name: "jQuery-runner" name: "jQuery-runner"
}; }
_$ = $; _$ = $
if (!(_$ && _$.fn)) { if (!(_$ && _$.fn)) {
throw new Error('[' + meta.name + '] jQuery or jQuery-like library is required for this plugin to work'); throw new Error('[' + meta.name + '] jQuery or jQuery-like library is required for this plugin to work')
} }
runners = {}; runners = {}
pad = function(num) { pad = function(num) {
return (num < 10 ? '0' : '') + num; return (num < 10 ? '0' : '') + num
}; }
_uid = 1; _uid = 1
uid = function() { uid = function() {
return 'runner' + _uid++; return 'runner' + _uid++
}; }
_requestAnimationFrame = (function(win, raf) { _requestAnimationFrame = (function(win, raf) {
return win['r' + raf] || win['webkitR' + raf] || win['mozR' + raf] || win['msR' + raf] || function(fn) { return win['r' + raf] || win['webkitR' + raf] || win['mozR' + raf] || win['msR' + raf] || function(fn) {
return setTimeout(fn, 30); return setTimeout(fn, 30)
}; }
})(this, 'equestAnimationFrame'); })(this, 'equestAnimationFrame')
formatTime = function(time, settings) { formatTime = function(time, settings) {
var i, len, ms, output, prefix, separator, step, steps, value, _i, _len; var i, len, ms, output, prefix, separator, step, steps, value, _i, _len
settings = settings || {}; settings = settings || {}
steps = [3600000, 60000, 1000, 10]; steps = [3600000, 60000, 1000, 10]
separator = ['', ':', ':', '.']; separator = ['', ':', ':', '.']
prefix = ''; prefix = ''
output = ''; output = ''
ms = settings.milliseconds; ms = settings.milliseconds
len = steps.length; len = steps.length
value = 0; value = 0
if (time < 0) { if (time < 0) {
time = Math.abs(time); time = Math.abs(time)
prefix = '-'; prefix = '-'
} }
for (i = _i = 0, _len = steps.length; _i < _len; i = ++_i) { for (i = _i = 0, _len = steps.length; _i < _len; i = ++_i) {
step = steps[i]; step = steps[i]
value = 0; value = 0
if (time >= step) { if (time >= step) {
value = Math.floor(time / step); value = Math.floor(time / step)
time -= value * step; time -= value * step
} }
if ((value || i > 1 || output) && (i !== len - 1 || ms)) { if ((value || i > 1 || output) && (i !== len - 1 || ms)) {
output += (output ? separator[i] : '') + pad(value); output += (output ? separator[i] : '') + pad(value)
} }
} }
return prefix + output; return prefix + output
}; }
Runner = (function() { Runner = (function() {
function Runner(items, options, start) { function Runner(items, options, start) {
var id; var id
if (!(this instanceof Runner)) { if (!(this instanceof Runner)) {
return new Runner(items, options, start); return new Runner(items, options, start)
} }
this.items = items; this.items = items
id = this.id = uid(); id = this.id = uid()
this.settings = _$.extend({}, this.settings, options); this.settings = _$.extend({}, this.settings, options)
runners[id] = this; runners[id] = this
items.each(function(index, element) { items.each(function(index, element) {
_$(element).data('runner', id); _$(element).data('runner', id)
}); })
this.value(this.settings.startAt); this.value(this.settings.startAt)
if (start || this.settings.autostart) { if (start || this.settings.autostart) {
this.start(); this.start()
} }
} }
Runner.prototype.running = false; Runner.prototype.running = false
Runner.prototype.updating = false; Runner.prototype.updating = false
Runner.prototype.finished = false; Runner.prototype.finished = false
Runner.prototype.interval = null; Runner.prototype.interval = null
Runner.prototype.total = 0; Runner.prototype.total = 0
Runner.prototype.lastTime = 0; Runner.prototype.lastTime = 0
Runner.prototype.startTime = 0; Runner.prototype.startTime = 0
Runner.prototype.lastLap = 0; Runner.prototype.lastLap = 0
Runner.prototype.lapTime = 0; Runner.prototype.lapTime = 0
Runner.prototype.settings = { Runner.prototype.settings = {
autostart: false, autostart: false,
@ -108,128 +108,128 @@
startAt: 0, startAt: 0,
milliseconds: true, milliseconds: true,
format: null format: null
}; }
Runner.prototype.value = function(value) { Runner.prototype.value = function(value) {
this.items.each((function(_this) { this.items.each((function(_this) {
return function(item, element) { return function(item, element) {
var action; var action
item = _$(element); item = _$(element)
action = item.is('input') ? 'val' : 'text'; action = item.is('input') ? 'val' : 'text'
item[action](_this.format(value)); item[action](_this.format(value))
}; }
})(this)); })(this))
}; }
Runner.prototype.format = function(value) { Runner.prototype.format = function(value) {
var format; var format
format = this.settings.format; format = this.settings.format
format = _$.isFunction(format) ? format : formatTime; format = _$.isFunction(format) ? format : formatTime
return format(value, this.settings); return format(value, this.settings)
}; }
Runner.prototype.update = function() { Runner.prototype.update = function() {
var countdown, delta, settings, stopAt, time; var countdown, delta, settings, stopAt, time
if (!this.updating) { if (!this.updating) {
this.updating = true; this.updating = true
settings = this.settings; settings = this.settings
time = _$.now(); time = _$.now()
stopAt = settings.stopAt; stopAt = settings.stopAt
countdown = settings.countdown; countdown = settings.countdown
delta = time - this.lastTime; delta = time - this.lastTime
this.lastTime = time; this.lastTime = time
if (countdown) { if (countdown) {
this.total -= delta; this.total -= delta
} else { } else {
this.total += delta; this.total += delta
} }
if (stopAt !== null && ((countdown && this.total <= stopAt) || (!countdown && this.total >= stopAt))) { if (stopAt !== null && ((countdown && this.total <= stopAt) || (!countdown && this.total >= stopAt))) {
this.total = stopAt; this.total = stopAt
this.finished = true; this.finished = true
this.stop(); this.stop()
this.fire('runnerFinish'); this.fire('runnerFinish')
} }
this.value(this.total); this.value(this.total)
this.updating = false; this.updating = false
} }
}; }
Runner.prototype.fire = function(event) { Runner.prototype.fire = function(event) {
this.items.trigger(event, this.info()); this.items.trigger(event, this.info())
}; }
Runner.prototype.start = function() { Runner.prototype.start = function() {
var step; var step
if (!this.running) { if (!this.running) {
this.running = true; this.running = true
if (!this.startTime || this.finished) { if (!this.startTime || this.finished) {
this.reset(); this.reset()
} }
this.lastTime = _$.now(); this.lastTime = _$.now()
step = (function(_this) { step = (function(_this) {
return function() { return function() {
if (_this.running) { if (_this.running) {
_this.update(); _this.update()
_requestAnimationFrame(step); _requestAnimationFrame(step)
} }
}; }
})(this); })(this)
_requestAnimationFrame(step); _requestAnimationFrame(step)
this.fire('runnerStart'); this.fire('runnerStart')
} }
}; }
Runner.prototype.stop = function() { Runner.prototype.stop = function() {
if (this.running) { if (this.running) {
this.running = false; this.running = false
this.update(); this.update()
this.fire('runnerStop'); this.fire('runnerStop')
} }
}; }
Runner.prototype.toggle = function() { Runner.prototype.toggle = function() {
if (this.running) { if (this.running) {
this.stop(); this.stop()
} else { } else {
this.start(); this.start()
} }
}; }
Runner.prototype.lap = function() { Runner.prototype.lap = function() {
var lap, last; var lap, last
last = this.lastTime; last = this.lastTime
lap = last - this.lapTime; lap = last - this.lapTime
if (this.settings.countdown) { if (this.settings.countdown) {
lap = -lap; lap = -lap
} }
if (this.running || lap) { if (this.running || lap) {
this.lastLap = lap; this.lastLap = lap
this.lapTime = last; this.lapTime = last
} }
last = this.format(this.lastLap); last = this.format(this.lastLap)
this.fire('runnerLap'); this.fire('runnerLap')
return last; return last
}; }
Runner.prototype.reset = function(stop) { Runner.prototype.reset = function(stop) {
var nowTime; var nowTime
if (stop) { if (stop) {
this.stop(); this.stop()
} }
nowTime = _$.now(); nowTime = _$.now()
if (typeof this.settings.startAt === 'number' && !this.settings.countdown) { if (typeof this.settings.startAt === 'number' && !this.settings.countdown) {
nowTime -= this.settings.startAt; nowTime -= this.settings.startAt
} }
this.startTime = this.lapTime = this.lastTime = nowTime; this.startTime = this.lapTime = this.lastTime = nowTime
this.total = this.settings.startAt; this.total = this.settings.startAt
this.value(this.total); this.value(this.total)
this.finished = false; this.finished = false
this.fire('runnerReset'); this.fire('runnerReset')
}; }
Runner.prototype.info = function() { Runner.prototype.info = function() {
var lap; var lap
lap = this.lastLap || 0; lap = this.lastLap || 0
return { return {
running: this.running, running: this.running,
finished: this.finished, finished: this.finished,
@ -239,58 +239,58 @@
lapTime: lap, lapTime: lap,
formattedLapTime: this.format(lap), formattedLapTime: this.format(lap),
settings: this.settings settings: this.settings
}; }
}; }
return Runner; return Runner
})(); })()
_$.fn.runner = function(method, options, start) { _$.fn.runner = function(method, options, start) {
var id, runner; var id, runner
if (!method) { if (!method) {
method = 'init'; method = 'init'
} }
if (typeof method === 'object') { if (typeof method === 'object') {
start = options; start = options
options = method; options = method
method = 'init'; method = 'init'
} }
id = this.data('runner'); id = this.data('runner')
runner = id ? runners[id] : false; runner = id ? runners[id] : false
switch (method) { switch (method) {
case 'init': case 'init':
new Runner(this, options, start); new Runner(this, options, start)
break; break
case 'info': case 'info':
if (runner) { if (runner) {
return runner.info(); return runner.info()
} }
break; break
case 'reset': case 'reset':
if (runner) { if (runner) {
runner.reset(options); runner.reset(options)
} }
break; break
case 'lap': case 'lap':
if (runner) { if (runner) {
return runner.lap(); return runner.lap()
} }
break; break
case 'start': case 'start':
case 'stop': case 'stop':
case 'toggle': case 'toggle':
if (runner) { if (runner) {
return runner[method](); return runner[method]()
} }
break; break
case 'version': case 'version':
return meta.version; return meta.version
default: default:
_$.error('[' + meta.name + '] Method ' + method + ' does not exist'); _$.error('[' + meta.name + '] Method ' + method + ' does not exist')
} }
return this; return this
}; }
_$.fn.runner.format = formatTime; _$.fn.runner.format = formatTime
}).call(window); }).call(window)

20
sapl-frontend/src/global/main.js

@ -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 'bootstrap'
import "webpack-jquery-ui/sortable";
import "bootstrap"; import './functions'
import "./functions"; import './image_cropping'
import "./image_cropping";
window.jQuery = jQuery window.jQuery = jQuery
window.$ = jQuery window.$ = jQuery
window.autorModal(); window.autorModal()
window.refreshMask(); window.refreshMask()

12
sapl-frontend/src/hellow/main.js

@ -1,12 +1,12 @@
import Vue from "vue"; import Vue from "vue"
import App from "./App.vue"; import App from "./App.vue"
import router from "./router"; import router from "./router"
import store from "./store"; import store from "./store"
Vue.config.productionTip = false; Vue.config.productionTip = false
new Vue({ new Vue({
router, router,
store, store,
render: h => h(App) render: h => h(App)
}).$mount("#app"); }).$mount("#app")

8
sapl-frontend/src/hellow/router.js

@ -1,10 +1,10 @@
import Vue from "vue"; import Vue from "vue"
import Router from "vue-router"; import Router from "vue-router"
Vue.use(Router); Vue.use(Router)
export default new Router({ export default new Router({
mode: "history", mode: "history",
base: process.env.BASE_URL, base: process.env.BASE_URL,
routes: [] routes: []
}); })

6
sapl-frontend/src/hellow/store.js

@ -1,7 +1,7 @@
import Vue from "vue"; import Vue from "vue"
import Vuex from "vuex"; import Vuex from "vuex"
Vue.use(Vuex); Vue.use(Vuex)
export default new Vuex.Store({ export default new Vuex.Store({
state: {}, state: {},

4
sapl-frontend/src/hellow/views/Home.vue

@ -7,12 +7,12 @@
<script> <script>
// @ is an alias to /src // @ is an alias to /src
import HelloWorld from "@/hellow/components/HelloWorld.vue"; import HelloWorld from "@/hellow/components/HelloWorld.vue"
export default { export default {
name: "home", name: "home",
components: { components: {
HelloWorld HelloWorld
} }
}; }
</script> </script>

2
sapl-frontend/vue.config.js

@ -20,6 +20,8 @@ module.exports = {
.plugin('BundleTracker') .plugin('BundleTracker')
.use(BundleTracker, [{ filename: './webpack-stats.json' }]) .use(BundleTracker, [{ filename: './webpack-stats.json' }])
config.devtool = "source-map"
config.resolve.alias config.resolve.alias
.set('__STATIC__', 'static') .set('__STATIC__', 'static')

2
sapl/templates/compilacao/dispositivo_form_search.html

@ -1,6 +1,6 @@
{% load i18n crispy_forms_tags %} {% load i18n crispy_forms_tags %}
<div class="modal fade" id="modal-ds" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel"> <div class="modal" id="modal-ds" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
<div class="modal-dialog modal-lg" role="document"> <div class="modal-dialog modal-lg" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">

Loading…
Cancel
Save