|
|
@ -1,57 +1,57 @@ |
|
|
function DispositivoEdit () { |
|
|
function DispositivoEdit () { |
|
|
// Função única - Singleton pattern - operador new sempre devolve o mesmo objeto
|
|
|
// Função única - Singleton pattern - operador new sempre devolve o mesmo objeto
|
|
|
var instance; |
|
|
var instance |
|
|
|
|
|
|
|
|
var editortype = "textarea"; |
|
|
var editortype = 'textarea' |
|
|
|
|
|
|
|
|
if (!(this instanceof DispositivoEdit)) { |
|
|
if (!(this instanceof DispositivoEdit)) { |
|
|
if (!instance) { |
|
|
if (!instance) { |
|
|
instance = new DispositivoEdit(); |
|
|
instance = new DispositivoEdit() |
|
|
} |
|
|
} |
|
|
return instance; |
|
|
return instance |
|
|
} |
|
|
} |
|
|
instance = this; |
|
|
instance = this |
|
|
DispositivoEdit = function () { |
|
|
DispositivoEdit = function () { |
|
|
return instance; |
|
|
return instance |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
instance.bindActionsEditorType = function (event) { |
|
|
instance.bindActionsEditorType = function (event) { |
|
|
editortype = this.getAttribute('editortype'); |
|
|
editortype = this.getAttribute('editortype') |
|
|
SetCookie("editortype", editortype, 30); |
|
|
SetCookie('editortype', editortype, 30) |
|
|
var dpt = $(this).closest('.dpt'); |
|
|
var dpt = $(this).closest('.dpt') |
|
|
|
|
|
|
|
|
var pk = dpt.attr('pk'); |
|
|
var pk = dpt.attr('pk') |
|
|
instance.clearEditSelected(); |
|
|
instance.clearEditSelected() |
|
|
instance.triggerBtnDptEdit(pk); |
|
|
instance.triggerBtnDptEdit(pk) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.bindActionsClick = function (event) { |
|
|
instance.bindActionsClick = function (event) { |
|
|
var pk = this.getAttribute('pk'); |
|
|
var pk = this.getAttribute('pk') |
|
|
|
|
|
|
|
|
var form_data = { |
|
|
var form_data = { |
|
|
'action': this.getAttribute('action'), |
|
|
'action': this.getAttribute('action'), |
|
|
'tipo_pk': this.getAttribute('tipo_pk'), |
|
|
'tipo_pk': this.getAttribute('tipo_pk'), |
|
|
'perfil_pk': this.getAttribute('perfil_pk'), |
|
|
'perfil_pk': this.getAttribute('perfil_pk'), |
|
|
'variacao': this.getAttribute('variacao'), |
|
|
'variacao': this.getAttribute('variacao'), |
|
|
'pk_bloco' : this.getAttribute('pk_bloco'), |
|
|
'pk_bloco': this.getAttribute('pk_bloco') |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
var url = pk+'/refresh'; |
|
|
var url = pk + '/refresh' |
|
|
instance.waitShow(); |
|
|
instance.waitShow() |
|
|
|
|
|
|
|
|
$.get(url, form_data).done(function (data) { |
|
|
$.get(url, form_data).done(function (data) { |
|
|
instance.clearEditSelected(); |
|
|
instance.clearEditSelected() |
|
|
if (data.pk != null) { |
|
|
if (data.pk != null) { |
|
|
instance.message(data); |
|
|
instance.message(data) |
|
|
} |
|
|
} |
|
|
}).fail(instance.waitHide).always(instance.waitHide); |
|
|
}).fail(instance.waitHide).always(instance.waitHide) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.clearEditSelected = function () { |
|
|
instance.clearEditSelected = function () { |
|
|
$('.dpt-selected > .dpt-form').html(''); |
|
|
$('.dpt-selected > .dpt-form').html('') |
|
|
$('.dpt-actions, .dpt-actions-bottom').html(''); |
|
|
$('.dpt-actions, .dpt-actions-bottom').html('') |
|
|
tinymce.remove(); |
|
|
tinymce.remove() |
|
|
$('.dpt-selected').removeClass('dpt-selected'); |
|
|
$('.dpt-selected').removeClass('dpt-selected') |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.editDispositivo = function (event) { |
|
|
instance.editDispositivo = function (event) { |
|
|
@ -59,260 +59,245 @@ function DispositivoEdit() { |
|
|
? event.target |
|
|
? event.target |
|
|
: (event.target.parentElement.classList.contains('dpt-link') |
|
|
: (event.target.parentElement.classList.contains('dpt-link') |
|
|
? event.target.parentElement |
|
|
? event.target.parentElement |
|
|
: null)); |
|
|
: null)) |
|
|
|
|
|
|
|
|
if (obj_click && obj_click.getAttribute('href') && obj_click.getAttribute('href').length > 0) |
|
|
if (obj_click && obj_click.getAttribute('href') && obj_click.getAttribute('href').length > 0) { return } |
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
var dpt = $(this).closest('.dpt'); |
|
|
var dpt = $(this).closest('.dpt') |
|
|
if (dpt.hasClass('dpt-selected')) { |
|
|
if (dpt.hasClass('dpt-selected')) { |
|
|
if (this.getAttribute('action') == 'editor-close') |
|
|
if (this.getAttribute('action') == 'editor-close') { instance.clearEditSelected() } |
|
|
instance.clearEditSelected(); |
|
|
return |
|
|
return; |
|
|
|
|
|
} |
|
|
} |
|
|
instance.clearEditSelected(); |
|
|
instance.clearEditSelected() |
|
|
instance.loadActionsEdit(dpt); |
|
|
instance.loadActionsEdit(dpt) |
|
|
|
|
|
|
|
|
var formtype = dpt.attr('formtype'); |
|
|
var formtype = dpt.attr('formtype') |
|
|
dpt.on(formtype, instance[formtype]); |
|
|
dpt.on(formtype, instance[formtype]) |
|
|
instance.loadForm(dpt, formtype); |
|
|
instance.loadForm(dpt, formtype) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.gc = function () { |
|
|
instance.gc = function () { |
|
|
setTimeout(function () { |
|
|
setTimeout(function () { |
|
|
$('.dpt:not(.dpt-selected) > .dpt-form').html(''); |
|
|
$('.dpt:not(.dpt-selected) > .dpt-form').html('') |
|
|
},500); |
|
|
}, 500) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.get_form_base = function () { |
|
|
instance.get_form_base = function () { |
|
|
var _this = $(this); |
|
|
var _this = $(this) |
|
|
_this.addClass('dpt-selected'); |
|
|
_this.addClass('dpt-selected') |
|
|
|
|
|
|
|
|
var dpt_form = _this.children().filter('.dpt-form'); |
|
|
var dpt_form = _this.children().filter('.dpt-form') |
|
|
dpt_form.find('form').submit(instance.onSubmitEditFormBase); |
|
|
dpt_form.find('form').submit(instance.onSubmitEditFormBase) |
|
|
|
|
|
|
|
|
instance.scrollTo(_this); |
|
|
instance.scrollTo(_this) |
|
|
_this.off('get_form_base') |
|
|
_this.off('get_form_base') |
|
|
|
|
|
|
|
|
var btn_fechar = _this.find('.btn-fechar'); |
|
|
var btn_fechar = _this.find('.btn-fechar') |
|
|
btn_fechar.on('click', function () { |
|
|
btn_fechar.on('click', function () { |
|
|
instance.clearEditSelected(); |
|
|
instance.clearEditSelected() |
|
|
}); |
|
|
}) |
|
|
|
|
|
|
|
|
var btns_excluir = _this.find('.btns-excluir'); |
|
|
var btns_excluir = _this.find('.btns-excluir') |
|
|
_this.find('.dpt-actions-bottom').first().append(btns_excluir); |
|
|
_this.find('.dpt-actions-bottom').first().append(btns_excluir) |
|
|
|
|
|
|
|
|
btns_excluir.find('.btn-outline-danger').on('click', instance.bindActionsClick); |
|
|
btns_excluir.find('.btn-outline-danger').on('click', instance.bindActionsClick) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.get_form_alteracao = function () { |
|
|
instance.get_form_alteracao = function () { |
|
|
var _this = $(this); |
|
|
var _this = $(this) |
|
|
_this.off('get_form_alteracao'); |
|
|
_this.off('get_form_alteracao') |
|
|
$('.dpt-actions, .dpt-actions-bottom').html(''); |
|
|
$('.dpt-actions, .dpt-actions-bottom').html('') |
|
|
|
|
|
|
|
|
var dpt_form = _this.children().filter('.dpt-form').children().first(); |
|
|
var dpt_form = _this.children().filter('.dpt-form').children().first() |
|
|
var url_search = dpt_form[0]['id_dispositivo_search_form'].value; |
|
|
var url_search = dpt_form[0]['id_dispositivo_search_form'].value |
|
|
DispositivoSearch({ |
|
|
DispositivoSearch({ |
|
|
'url_form': url_search, |
|
|
'url_form': url_search, |
|
|
'text_button': 'Selecionar' |
|
|
'text_button': 'Selecionar' |
|
|
}); |
|
|
}) |
|
|
|
|
|
|
|
|
instance.scrollTo(_this); |
|
|
instance.scrollTo(_this) |
|
|
dpt_form.submit(instance.onSubmitFormRegistraAlteracao); |
|
|
dpt_form.submit(instance.onSubmitFormRegistraAlteracao) |
|
|
|
|
|
|
|
|
var btn_fechar = _this.find('.btn-fechar'); |
|
|
var btn_fechar = _this.find('.btn-fechar') |
|
|
btn_fechar.on('click', function () { |
|
|
btn_fechar.on('click', function () { |
|
|
instance.clearEditSelected(); |
|
|
instance.clearEditSelected() |
|
|
instance.triggerBtnDptEdit(_this.attr('pk')); |
|
|
instance.triggerBtnDptEdit(_this.attr('pk')) |
|
|
}); |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.get_form_inclusao = function () { |
|
|
instance.get_form_inclusao = function () { |
|
|
var _this = $(this); |
|
|
var _this = $(this) |
|
|
_this.off('get_form_inclusao'); |
|
|
_this.off('get_form_inclusao') |
|
|
$('.dpt-actions, .dpt-actions-bottom').html(''); |
|
|
$('.dpt-actions, .dpt-actions-bottom').html('') |
|
|
|
|
|
|
|
|
var dpt_form = _this.children().filter('.dpt-form').children().first(); |
|
|
var dpt_form = _this.children().filter('.dpt-form').children().first() |
|
|
var url_search = dpt_form[0]['id_dispositivo_search_form'].value; |
|
|
var url_search = dpt_form[0]['id_dispositivo_search_form'].value |
|
|
DispositivoSearch({ |
|
|
DispositivoSearch({ |
|
|
'url_form': url_search, |
|
|
'url_form': url_search, |
|
|
'text_button': 'Selecionar', |
|
|
'text_button': 'Selecionar', |
|
|
'post_selected': instance.allowed_inserts_registro_inclusao, |
|
|
'post_selected': instance.allowed_inserts_registro_inclusao, |
|
|
'params_post_selected': { 'pk_bloco': _this.attr('pk') } |
|
|
'params_post_selected': { 'pk_bloco': _this.attr('pk') } |
|
|
|
|
|
|
|
|
}); |
|
|
}) |
|
|
|
|
|
|
|
|
instance.scrollTo(_this); |
|
|
instance.scrollTo(_this) |
|
|
dpt_form.submit(instance.onSubmitFormRegistraInclusao); |
|
|
dpt_form.submit(instance.onSubmitFormRegistraInclusao) |
|
|
|
|
|
|
|
|
var btn_fechar = _this.find('.btn-fechar'); |
|
|
var btn_fechar = _this.find('.btn-fechar') |
|
|
btn_fechar.on('click', function () { |
|
|
btn_fechar.on('click', function () { |
|
|
instance.clearEditSelected(); |
|
|
instance.clearEditSelected() |
|
|
instance.triggerBtnDptEdit(_this.attr('pk')); |
|
|
instance.triggerBtnDptEdit(_this.attr('pk')) |
|
|
}); |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.get_form_revogacao = function () { |
|
|
instance.get_form_revogacao = function () { |
|
|
var _this = $(this); |
|
|
var _this = $(this) |
|
|
_this.off('get_form_revogacao'); |
|
|
_this.off('get_form_revogacao') |
|
|
$('.dpt-actions, .dpt-actions-bottom').html(''); |
|
|
$('.dpt-actions, .dpt-actions-bottom').html('') |
|
|
|
|
|
|
|
|
var dpt_form = _this.children().filter('.dpt-form').children().first(); |
|
|
var dpt_form = _this.children().filter('.dpt-form').children().first() |
|
|
var url_search = dpt_form[0]['id_dispositivo_search_form'].value; |
|
|
var url_search = dpt_form[0]['id_dispositivo_search_form'].value |
|
|
DispositivoSearch({ |
|
|
DispositivoSearch({ |
|
|
'url_form': url_search, |
|
|
'url_form': url_search, |
|
|
'text_button': 'Selecionar' |
|
|
'text_button': 'Selecionar' |
|
|
}); |
|
|
}) |
|
|
|
|
|
|
|
|
instance.scrollTo(_this); |
|
|
instance.scrollTo(_this) |
|
|
dpt_form.submit(instance.onSubmitFormRegistraRevogacao); |
|
|
dpt_form.submit(instance.onSubmitFormRegistraRevogacao) |
|
|
|
|
|
|
|
|
|
|
|
var btn_fechar = _this.find('.btn-fechar') |
|
|
var btn_fechar = _this.find('.btn-fechar'); |
|
|
|
|
|
btn_fechar.on('click', function () { |
|
|
btn_fechar.on('click', function () { |
|
|
instance.clearEditSelected(); |
|
|
instance.clearEditSelected() |
|
|
instance.triggerBtnDptEdit(_this.attr('pk')); |
|
|
instance.triggerBtnDptEdit(_this.attr('pk')) |
|
|
}); |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.allowed_inserts_registro_inclusao = function (params) { |
|
|
instance.allowed_inserts_registro_inclusao = function (params) { |
|
|
|
|
|
var dispositivo_base_para_inclusao = $('#id' + params.pk_bloco + " input[name='dispositivo_base_para_inclusao']") |
|
|
|
|
|
if (dispositivo_base_para_inclusao.length == 0) { return } |
|
|
|
|
|
|
|
|
var dispositivo_base_para_inclusao = $("#id"+params.pk_bloco+" input[name='dispositivo_base_para_inclusao']") |
|
|
var pk = dispositivo_base_para_inclusao[0].value |
|
|
if (dispositivo_base_para_inclusao.length == 0) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
var pk = dispositivo_base_para_inclusao[0].value; |
|
|
|
|
|
var form_data = { |
|
|
var form_data = { |
|
|
'action': 'get_actions_allowed_inserts_registro_inclusao', |
|
|
'action': 'get_actions_allowed_inserts_registro_inclusao', |
|
|
'pk_bloco': params.pk_bloco |
|
|
'pk_bloco': params.pk_bloco |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
var url = pk+'/refresh'; |
|
|
var url = pk + '/refresh' |
|
|
instance.waitShow(); |
|
|
instance.waitShow() |
|
|
|
|
|
|
|
|
$.get(url, form_data).done(function (data) { |
|
|
$.get(url, form_data).done(function (data) { |
|
|
$(".allowed_inserts").html(data); |
|
|
$('.allowed_inserts').html(data) |
|
|
$(".allowed_inserts").find('.btn-action').on('click', instance.bindActionsClick); |
|
|
$('.allowed_inserts').find('.btn-action').on('click', instance.bindActionsClick) |
|
|
}).fail(instance.waitHide).always(instance.waitHide); |
|
|
}).fail(instance.waitHide).always(instance.waitHide) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.loadActionsEdit = function (dpt) { |
|
|
instance.loadActionsEdit = function (dpt) { |
|
|
var pk = dpt.attr('pk'); |
|
|
var pk = dpt.attr('pk') |
|
|
var url = pk+'/refresh?action=get_actions'; |
|
|
var url = pk + '/refresh?action=get_actions' |
|
|
$.get(url).done(function (data) { |
|
|
$.get(url).done(function (data) { |
|
|
dpt.find('.dpt-actions').first().html(data); |
|
|
dpt.find('.dpt-actions').first().html(data) |
|
|
dpt.find('.btn-action').on('click', instance.bindActionsClick); |
|
|
dpt.find('.btn-action').on('click', instance.bindActionsClick) |
|
|
// dpt.find('.btn-perfis').on('click', instance.bindActionsClick);
|
|
|
// dpt.find('.btn-perfis').on('click', instance.bindActionsClick);
|
|
|
dpt.find('.btn-compila').on('click', instance.loadFormsCompilacao); |
|
|
dpt.find('.btn-compila').on('click', instance.loadFormsCompilacao) |
|
|
dpt.find('.btn-editor-type').on('click', instance.bindActionsEditorType); |
|
|
dpt.find('.btn-editor-type').on('click', instance.bindActionsEditorType) |
|
|
|
|
|
|
|
|
if (editortype == 'construct') |
|
|
if (editortype == 'construct') { dpt.find('.btn-group-inserts').first().addClass('open') } |
|
|
dpt.find('.btn-group-inserts').first().addClass('open'); |
|
|
|
|
|
|
|
|
|
|
|
dpt.find('.btn-group-inserts button').mouseenter(function (event) { |
|
|
dpt.find('.btn-group-inserts button').mouseenter(function (event) { |
|
|
dpt.find('.btn-group-inserts').removeClass('open'); |
|
|
dpt.find('.btn-group-inserts').removeClass('open') |
|
|
$(this.parentElement).addClass('open') |
|
|
$(this.parentElement).addClass('open') |
|
|
}); |
|
|
}) |
|
|
|
|
|
|
|
|
instance.gc(); |
|
|
instance.gc() |
|
|
}); |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.loadForm = function (dpt, trigger) { |
|
|
instance.loadForm = function (dpt, trigger) { |
|
|
var pk = dpt.attr('pk'); |
|
|
var pk = dpt.attr('pk') |
|
|
var dpt_form = dpt.children().filter('.dpt-form'); |
|
|
var dpt_form = dpt.children().filter('.dpt-form') |
|
|
if (dpt_form.length == 1) { |
|
|
if (dpt_form.length == 1) { |
|
|
var url = pk+'/refresh?action='+trigger; |
|
|
var url = pk + '/refresh?action=' + trigger |
|
|
$.get(url).done(function (data) { |
|
|
$.get(url).done(function (data) { |
|
|
if (editortype != "construct") { |
|
|
if (editortype != 'construct') { |
|
|
dpt_form.html(data); |
|
|
dpt_form.html(data) |
|
|
if (editortype == 'tinymce') { |
|
|
if (editortype == 'tinymce') { |
|
|
initTextRichEditor(); |
|
|
initTextRichEditor() |
|
|
} |
|
|
} |
|
|
//OptionalCustomFrontEnd().init();
|
|
|
OptionalCustomFrontEnd().init() |
|
|
} |
|
|
} |
|
|
dpt.trigger(trigger); |
|
|
dpt.trigger(trigger) |
|
|
}).always(function () { |
|
|
}).always(function () { |
|
|
instance.waitHide(); |
|
|
instance.waitHide() |
|
|
}); |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.loadFormsCompilacao = function (event) { |
|
|
instance.loadFormsCompilacao = function (event) { |
|
|
var dpt = $(this).closest('.dpt'); |
|
|
var dpt = $(this).closest('.dpt') |
|
|
var formtype = this.getAttribute('action'); |
|
|
var formtype = this.getAttribute('action') |
|
|
dpt.on(formtype, instance[formtype]); |
|
|
dpt.on(formtype, instance[formtype]) |
|
|
instance.loadForm(dpt, formtype); |
|
|
instance.loadForm(dpt, formtype) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.modalMessage = function (message, alert, closeFunction) { |
|
|
instance.modalMessage = function (message, alert, closeFunction) { |
|
|
if (message != null && message != '') { |
|
|
if (message != null && message != '') { |
|
|
$('#modal-message #message').html(message); |
|
|
$('#modal-message #message').html(message) |
|
|
$('#modal-message').modal('show'); |
|
|
$('#modal-message').modal('show') |
|
|
$('#modal-message, #modal-message .alert button').off(); |
|
|
$('#modal-message, #modal-message .alert button').off() |
|
|
$('#modal-message .alert').removeClass('alert-success alert-info alert-warning alert-danger alert-danger'); |
|
|
$('#modal-message .alert').removeClass('alert-success alert-info alert-warning alert-danger alert-danger') |
|
|
$('#modal-message .alert').addClass(alert); |
|
|
$('#modal-message .alert').addClass(alert) |
|
|
|
|
|
|
|
|
if (closeFunction != null) |
|
|
if (closeFunction != null) { $('#modal-message').on('hidden.bs.modal', closeFunction) } |
|
|
$('#modal-message').on('hidden.bs.modal', closeFunction); |
|
|
|
|
|
|
|
|
|
|
|
$('#modal-message .alert button').on('click', function () { |
|
|
$('#modal-message .alert button').on('click', function () { |
|
|
$('#modal-message').modal('hide'); |
|
|
$('#modal-message').modal('hide') |
|
|
}); |
|
|
}) |
|
|
return true; |
|
|
return true |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.message = function (data) { |
|
|
instance.message = function (data) { |
|
|
if (data.message !== undefined) { |
|
|
if (data.message !== undefined) { |
|
|
if (data.message.modal) { |
|
|
if (data.message.modal) { |
|
|
instance.modalMessage(data.message.value, 'alert-' + data.message.type, function () { |
|
|
instance.modalMessage(data.message.value, 'alert-' + data.message.type, function () { |
|
|
instance.waitShow(); |
|
|
instance.waitShow() |
|
|
instance.refreshScreenFocusPk(data); |
|
|
instance.refreshScreenFocusPk(data) |
|
|
}); |
|
|
}) |
|
|
return; |
|
|
} else { |
|
|
} |
|
|
instance.refreshScreenFocusPk(data) |
|
|
else { |
|
|
if (!('message' in data)) { return } |
|
|
instance.refreshScreenFocusPk(data); |
|
|
var cp_notify = $('.cp-notify') |
|
|
if (!('message' in data)) |
|
|
|
|
|
return; |
|
|
|
|
|
var cp_notify = $(".cp-notify") |
|
|
|
|
|
cp_notify.removeClass('hide') |
|
|
cp_notify.removeClass('hide') |
|
|
var msg = cp_notify.find('.message'); |
|
|
var msg = cp_notify.find('.message') |
|
|
msg.text(data.message.value); |
|
|
msg.text(data.message.value) |
|
|
msg.removeClass('bg-primary bg-success bg-info bg-warning bg-danger').addClass('bg-'+data.message.type); |
|
|
msg.removeClass('bg-primary bg-success bg-info bg-warning bg-danger').addClass('bg-' + data.message.type) |
|
|
setTimeout(function () { |
|
|
setTimeout(function () { |
|
|
cp_notify.addClass('hide'); |
|
|
cp_notify.addClass('hide') |
|
|
}, (data.message.time?data.message.time: 3000)); |
|
|
}, (data.message.time ? data.message.time : 3000)) |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
instance.refreshScreenFocusPk(data) |
|
|
instance.refreshScreenFocusPk(data); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
instance.offClicks = function () { |
|
|
instance.offClicks = function () { |
|
|
$('.btn-dpt-edit').off() |
|
|
$('.btn-dpt-edit').off() |
|
|
} |
|
|
} |
|
|
instance.onClicks = function (container) { |
|
|
instance.onClicks = function (container) { |
|
|
var objects; |
|
|
var objects |
|
|
if (container == null) |
|
|
if (container == null) { objects = $('.btn-dpt-edit') } else { objects = $(container).find('.btn-dpt-edit') } |
|
|
objects = $('.btn-dpt-edit'); |
|
|
objects.on('click', instance.editDispositivo) |
|
|
else |
|
|
|
|
|
objects = $(container).find('.btn-dpt-edit'); |
|
|
|
|
|
objects.on('click', instance.editDispositivo); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.onSubmitFormRegistraAlteracao = function (event) { |
|
|
instance.onSubmitFormRegistraAlteracao = function (event) { |
|
|
var _this = this; |
|
|
var _this = this |
|
|
|
|
|
|
|
|
if (this.dispositivo_alterado === undefined) { |
|
|
if (this.dispositivo_alterado === undefined) { |
|
|
instance.modalMessage('Nenhum dispositivo selecionado', 'alert-info') |
|
|
instance.modalMessage('Nenhum dispositivo selecionado', 'alert-info') |
|
|
if (event != null) |
|
|
if (event != null) { event.preventDefault() } |
|
|
event.preventDefault(); |
|
|
|
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
var dispositivo_alterado = this.dispositivo_alterado.length === undefined ? [this.dispositivo_alterado, ] : Array.from(this.dispositivo_alterado) |
|
|
var dispositivo_alterado = this.dispositivo_alterado.length === undefined ? [this.dispositivo_alterado ] : Array.from(this.dispositivo_alterado) |
|
|
var form_data = { |
|
|
var form_data = { |
|
|
'csrfmiddlewaretoken': this.csrfmiddlewaretoken.value, |
|
|
'csrfmiddlewaretoken': this.csrfmiddlewaretoken.value, |
|
|
'dispositivo_alterado': dispositivo_alterado.filter( |
|
|
'dispositivo_alterado': dispositivo_alterado.filter( |
|
|
@ -322,71 +307,63 @@ function DispositivoEdit() { |
|
|
).map(function (dsp) { |
|
|
).map(function (dsp) { |
|
|
return dsp.value |
|
|
return dsp.value |
|
|
}), |
|
|
}), |
|
|
'formtype': 'get_form_alteracao', |
|
|
'formtype': 'get_form_alteracao' |
|
|
}; |
|
|
} |
|
|
var url = $(this).closest('.dpt').attr( "pk" )+'/refresh'; |
|
|
var url = $(this).closest('.dpt').attr('pk') + '/refresh' |
|
|
|
|
|
|
|
|
instance.waitShow(); |
|
|
instance.waitShow() |
|
|
|
|
|
|
|
|
$.post(url, form_data, dataType="json") |
|
|
$.post(url, form_data, dataType = 'json') |
|
|
.done(function (data) { |
|
|
.done(function (data) { |
|
|
instance.clearEditSelected(); |
|
|
instance.clearEditSelected() |
|
|
|
|
|
|
|
|
if (data.pk != null) { |
|
|
if (data.pk != null) { |
|
|
instance.message(data); |
|
|
instance.message(data) |
|
|
|
|
|
} else { |
|
|
|
|
|
alert('Erro na resposta!') |
|
|
} |
|
|
} |
|
|
else { |
|
|
|
|
|
alert('Erro na resposta!'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}).always(function () { |
|
|
}).always(function () { |
|
|
instance.waitHide(); |
|
|
instance.waitHide() |
|
|
}); |
|
|
}) |
|
|
if (event != null) |
|
|
if (event != null) { event.preventDefault() } |
|
|
event.preventDefault(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.onSubmitFormRegistraInclusao = function (event) { |
|
|
instance.onSubmitFormRegistraInclusao = function (event) { |
|
|
var _this = this; |
|
|
var _this = this |
|
|
|
|
|
|
|
|
var form_data = { |
|
|
var form_data = { |
|
|
'csrfmiddlewaretoken': this['csrfmiddlewaretoken'].value, |
|
|
'csrfmiddlewaretoken': this['csrfmiddlewaretoken'].value, |
|
|
'dispositivo_base_para_inclusao': this['dispositivo_base_para_inclusao'].value, |
|
|
'dispositivo_base_para_inclusao': this['dispositivo_base_para_inclusao'].value, |
|
|
'formtype': 'get_form_inclusao', |
|
|
'formtype': 'get_form_inclusao' |
|
|
}; |
|
|
} |
|
|
var url = $(this).closest('.dpt').attr( "pk" )+'/refresh'; |
|
|
var url = $(this).closest('.dpt').attr('pk') + '/refresh' |
|
|
|
|
|
|
|
|
instance.waitShow(); |
|
|
instance.waitShow() |
|
|
|
|
|
|
|
|
$.post(url, form_data) |
|
|
$.post(url, form_data) |
|
|
.done(function (data) { |
|
|
.done(function (data) { |
|
|
instance.clearEditSelected(); |
|
|
instance.clearEditSelected() |
|
|
|
|
|
|
|
|
if (data.pk != null) { |
|
|
if (data.pk != null) { |
|
|
instance.message(data); |
|
|
instance.message(data) |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
alert('Erro na resposta!') |
|
|
alert('Erro na resposta!'); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}).always(function () { |
|
|
}).always(function () { |
|
|
instance.waitHide(); |
|
|
instance.waitHide() |
|
|
}); |
|
|
}) |
|
|
if (event != null) |
|
|
if (event != null) { event.preventDefault() } |
|
|
event.preventDefault(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.onSubmitFormRegistraRevogacao = function (event) { |
|
|
instance.onSubmitFormRegistraRevogacao = function (event) { |
|
|
var _this = this; |
|
|
var _this = this |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.dispositivo_revogado === undefined) { |
|
|
if (this.dispositivo_revogado === undefined) { |
|
|
instance.modalMessage('Nenhum dispositivo selecionado', 'alert-info') |
|
|
instance.modalMessage('Nenhum dispositivo selecionado', 'alert-info') |
|
|
if (event != null) |
|
|
if (event != null) { event.preventDefault() } |
|
|
event.preventDefault(); |
|
|
|
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
var dispositivo_revogado = this.dispositivo_revogado.length === undefined ? [this.dispositivo_revogado, ] : Array.from(this.dispositivo_revogado) |
|
|
var dispositivo_revogado = this.dispositivo_revogado.length === undefined ? [this.dispositivo_revogado ] : Array.from(this.dispositivo_revogado) |
|
|
var form_data = { |
|
|
var form_data = { |
|
|
'csrfmiddlewaretoken': this.csrfmiddlewaretoken.value, |
|
|
'csrfmiddlewaretoken': this.csrfmiddlewaretoken.value, |
|
|
'dispositivo_revogado': dispositivo_revogado.filter( |
|
|
'dispositivo_revogado': dispositivo_revogado.filter( |
|
|
@ -397,119 +374,103 @@ function DispositivoEdit() { |
|
|
return dsp.value |
|
|
return dsp.value |
|
|
}), |
|
|
}), |
|
|
'revogacao_em_bloco': this.revogacao_em_bloco.value, |
|
|
'revogacao_em_bloco': this.revogacao_em_bloco.value, |
|
|
'formtype': 'get_form_revogacao', |
|
|
'formtype': 'get_form_revogacao' |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
var url = $(this).closest('.dpt').attr( "pk" )+'/refresh'; |
|
|
var url = $(this).closest('.dpt').attr('pk') + '/refresh' |
|
|
|
|
|
|
|
|
instance.waitShow(); |
|
|
instance.waitShow() |
|
|
|
|
|
|
|
|
$.post(url, form_data) |
|
|
$.post(url, form_data) |
|
|
.done(function (data) { |
|
|
.done(function (data) { |
|
|
instance.clearEditSelected(); |
|
|
instance.clearEditSelected() |
|
|
|
|
|
|
|
|
if (data.pk != null) { |
|
|
if (data.pk != null) { |
|
|
instance.message(data); |
|
|
instance.message(data) |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
alert('Erro na resposta!') |
|
|
alert('Erro na resposta!'); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}).always(function () { |
|
|
}).always(function () { |
|
|
instance.waitHide(); |
|
|
instance.waitHide() |
|
|
}); |
|
|
}) |
|
|
if (event != null) |
|
|
if (event != null) { event.preventDefault() } |
|
|
event.preventDefault(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.onSubmitEditFormBase = function (event) { |
|
|
instance.onSubmitEditFormBase = function (event) { |
|
|
|
|
|
var _this = this |
|
|
|
|
|
var texto = '' |
|
|
|
|
|
var texto_atualizador = '' |
|
|
|
|
|
var visibilidade = '' |
|
|
|
|
|
var editor_tiny_texto = tinymce.get('id_texto') |
|
|
|
|
|
var editor_tiny_texto_atualizador = tinymce.get('id_texto_atualizador') |
|
|
|
|
|
|
|
|
var _this = this; |
|
|
if (editor_tiny_texto != null) { texto = editor_tiny_texto.getContent() } else { texto = this['id_texto'].value } |
|
|
var texto = ''; |
|
|
|
|
|
var texto_atualizador = ''; |
|
|
|
|
|
var visibilidade = ''; |
|
|
|
|
|
var editor_tiny_texto = tinymce.get('id_texto'); |
|
|
|
|
|
var editor_tiny_texto_atualizador = tinymce.get('id_texto_atualizador'); |
|
|
|
|
|
|
|
|
|
|
|
if (editor_tiny_texto != null) |
|
|
|
|
|
texto = editor_tiny_texto.getContent(); |
|
|
|
|
|
else |
|
|
|
|
|
texto = this['id_texto'].value; |
|
|
|
|
|
|
|
|
|
|
|
if (editor_tiny_texto_atualizador != null) |
|
|
if (editor_tiny_texto_atualizador != null) { texto_atualizador = editor_tiny_texto_atualizador.getContent() } else if ('id_texto_atualizador' in this) { texto_atualizador = this['id_texto_atualizador'].value } |
|
|
texto_atualizador = editor_tiny_texto_atualizador.getContent(); |
|
|
|
|
|
else if ('id_texto_atualizador' in this) |
|
|
|
|
|
texto_atualizador = this['id_texto_atualizador'].value; |
|
|
|
|
|
|
|
|
|
|
|
if ('visibilidade' in this) |
|
|
if ('visibilidade' in this) { visibilidade = this['visibilidade'].value } |
|
|
visibilidade = this['visibilidade'].value; |
|
|
|
|
|
|
|
|
|
|
|
var form_data = { |
|
|
var form_data = { |
|
|
'csrfmiddlewaretoken': this['csrfmiddlewaretoken'].value, |
|
|
'csrfmiddlewaretoken': this['csrfmiddlewaretoken'].value, |
|
|
'texto': texto, |
|
|
'texto': texto, |
|
|
'texto_atualizador': texto_atualizador, |
|
|
'texto_atualizador': texto_atualizador, |
|
|
'visibilidade': visibilidade, |
|
|
'visibilidade': visibilidade, |
|
|
'formtype': 'get_form_base', |
|
|
'formtype': 'get_form_base' |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
var url = $(this).closest('.dpt').attr( "pk" )+'/refresh'; |
|
|
var url = $(this).closest('.dpt').attr('pk') + '/refresh' |
|
|
|
|
|
|
|
|
instance.waitShow(); |
|
|
instance.waitShow() |
|
|
|
|
|
|
|
|
$.post(url, form_data) |
|
|
$.post(url, form_data) |
|
|
.done(function (data) { |
|
|
.done(function (data) { |
|
|
if (typeof data == "string") { /* if obsoleto */ |
|
|
if (typeof data === 'string') { /* if obsoleto */ |
|
|
var dpt = $(_this).closest('.dpt'); |
|
|
var dpt = $(_this).closest('.dpt') |
|
|
dpt = $('#'+dpt.replaceWith(data).attr('id')); |
|
|
dpt = $('#' + dpt.replaceWith(data).attr('id')) |
|
|
instance.onClicks(dpt); |
|
|
instance.onClicks(dpt) |
|
|
instance.waitHide(); |
|
|
instance.waitHide() |
|
|
return; |
|
|
return |
|
|
} |
|
|
} |
|
|
instance.clearEditSelected(); |
|
|
instance.clearEditSelected() |
|
|
|
|
|
|
|
|
if (data.pk != null) { |
|
|
if (data.pk != null) { |
|
|
instance.message(data); |
|
|
instance.message(data) |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
alert('Erro na resposta!') |
|
|
alert('Erro na resposta!'); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}).always(function () { |
|
|
}).always(function () { |
|
|
instance.waitHide(); |
|
|
instance.waitHide() |
|
|
}); |
|
|
}) |
|
|
if (event != null) |
|
|
if (event != null) { event.preventDefault() } |
|
|
event.preventDefault(); |
|
|
|
|
|
} |
|
|
} |
|
|
instance.refreshContent = function (pais, trigger_edit_pk) { |
|
|
instance.refreshContent = function (pais, trigger_edit_pk) { |
|
|
if (pais.length == 0) { |
|
|
if (pais.length == 0) { |
|
|
instance.waitHide(); |
|
|
instance.waitHide() |
|
|
return; |
|
|
return |
|
|
} |
|
|
} |
|
|
var pk = pais.shift(); |
|
|
var pk = pais.shift() |
|
|
var url = pk+'/refresh'; |
|
|
var url = pk + '/refresh' |
|
|
|
|
|
|
|
|
$.get(url).done(function (data) { |
|
|
$.get(url).done(function (data) { |
|
|
var dpt = $('#id'+pk).closest('.dpt'); |
|
|
var dpt = $('#id' + pk).closest('.dpt') |
|
|
dpt = $('#'+dpt.replaceWith(data).attr('id')); |
|
|
dpt = $('#' + dpt.replaceWith(data).attr('id')) |
|
|
instance.onClicks(dpt); |
|
|
instance.onClicks(dpt) |
|
|
instance.reloadFunctionsDraggables(); |
|
|
instance.reloadFunctionsDraggables() |
|
|
|
|
|
|
|
|
if (trigger_edit_pk > 0) |
|
|
if (trigger_edit_pk > 0) { instance.triggerBtnDptEdit(trigger_edit_pk) } |
|
|
instance.triggerBtnDptEdit(trigger_edit_pk) |
|
|
|
|
|
|
|
|
|
|
|
instance.refreshContent(pais); |
|
|
instance.refreshContent(pais) |
|
|
}); |
|
|
}) |
|
|
} |
|
|
} |
|
|
instance.refreshScreenFocusPk = function (data) { |
|
|
instance.refreshScreenFocusPk = function (data) { |
|
|
instance.waitShow(); |
|
|
instance.waitShow() |
|
|
if (data.pai[0] == -1) { |
|
|
if (data.pai[0] == -1) { |
|
|
instance.waitShow() |
|
|
instance.waitShow() |
|
|
href = location.href.split('#')[0] |
|
|
href = location.href.split('#')[0] |
|
|
location.href = href+'#'+data.pk; |
|
|
location.href = href + '#' + data.pk |
|
|
location.reload(true) |
|
|
location.reload(true) |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
instance.refreshContent(data.pai, data.pk) |
|
|
instance.refreshContent(data.pai, data.pk); |
|
|
|
|
|
|
|
|
|
|
|
/* setTimeout(function() { |
|
|
/* setTimeout(function() { |
|
|
for (var pai = 1; pai < data.pai.length; pai++) |
|
|
for (var pai = 1; pai < data.pai.length; pai++) |
|
|
@ -520,91 +481,83 @@ function DispositivoEdit() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance.reloadFunctionsDraggables = function () { |
|
|
instance.reloadFunctionsDraggables = function () { |
|
|
$( ".dpt-alts" ).sortable({ |
|
|
$('.dpt-alts').sortable({ |
|
|
revert: true, |
|
|
revert: true, |
|
|
distance: 15, |
|
|
distance: 15, |
|
|
start: function (event, ui) { |
|
|
start: function (event, ui) { |
|
|
} |
|
|
}, |
|
|
, |
|
|
|
|
|
stop: function (event, ui) { |
|
|
stop: function (event, ui) { |
|
|
var pk = ui.item.attr('pk'); |
|
|
var pk = ui.item.attr('pk') |
|
|
var bloco_pk = ui.item.closest('.dpt-alts').closest('.dpt').attr('pk'); |
|
|
var bloco_pk = ui.item.closest('.dpt-alts').closest('.dpt').attr('pk') |
|
|
|
|
|
|
|
|
var url = pk+'/refresh?action=json_drag_move_dpt_alterado&index='+ui.item.index()+'&bloco_pk='+bloco_pk; |
|
|
var url = pk + '/refresh?action=json_drag_move_dpt_alterado&index=' + ui.item.index() + '&bloco_pk=' + bloco_pk |
|
|
$.get(url).done(function (data) { |
|
|
$.get(url).done(function (data) { |
|
|
console.log(pk+ ' - '+ bloco_pk); |
|
|
console.log(pk + ' - ' + bloco_pk) |
|
|
// reloadFunctionsForObjectsOfCompilacao();
|
|
|
// reloadFunctionsForObjectsOfCompilacao();
|
|
|
}); |
|
|
}) |
|
|
} |
|
|
} |
|
|
}); |
|
|
}) |
|
|
|
|
|
|
|
|
$( ".dpt-alts .dpt" ).draggable({ |
|
|
$('.dpt-alts .dpt').draggable({ |
|
|
connectToSortable: ".dpt-alts", |
|
|
connectToSortable: '.dpt-alts', |
|
|
revert: 'invalid', |
|
|
revert: 'invalid', |
|
|
zIndex: 1, |
|
|
zIndex: 1, |
|
|
distance: 15, |
|
|
distance: 15, |
|
|
drag: function (event, ui) { |
|
|
drag: function (event, ui) { |
|
|
// $('.dpt-comp-selected').removeClass('dpt-comp-selected');
|
|
|
// $('.dpt-comp-selected').removeClass('dpt-comp-selected');
|
|
|
$(".dpt-alts").addClass('drag'); |
|
|
$('.dpt-alts').addClass('drag') |
|
|
}, |
|
|
}, |
|
|
stop: function (event, ui) { |
|
|
stop: function (event, ui) { |
|
|
$(".dpt-alts").removeClass('drag'); |
|
|
$('.dpt-alts').removeClass('drag') |
|
|
}, |
|
|
} |
|
|
}); |
|
|
}) |
|
|
|
|
|
|
|
|
$(".dpt-alts").disableSelection(); |
|
|
$('.dpt-alts').disableSelection() |
|
|
} |
|
|
} |
|
|
instance.scrollTo = function (dpt) { |
|
|
instance.scrollTo = function (dpt) { |
|
|
try { |
|
|
try { |
|
|
$('html, body').animate({ |
|
|
$('html, body').animate({ |
|
|
scrollTop: dpt.offset().top - window.innerHeight / 9 |
|
|
scrollTop: dpt.offset().top - window.innerHeight / 9 |
|
|
}, 100); |
|
|
}, 100) |
|
|
} |
|
|
} catch (err) { |
|
|
catch(err) { |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
instance.triggerBtnDptEdit = function (pk) { |
|
|
instance.triggerBtnDptEdit = function (pk) { |
|
|
var btn_dpt_edit = $('#id'+pk + ' > .dpt-text.btn-dpt-edit'); |
|
|
var btn_dpt_edit = $('#id' + pk + ' > .dpt-text.btn-dpt-edit') |
|
|
if (btn_dpt_edit.length == 0) |
|
|
if (btn_dpt_edit.length == 0) { btn_dpt_edit = $('#id' + pk + ' > .dpt-actions-fixed > .btn-dpt-edit') } |
|
|
btn_dpt_edit = $('#id'+pk + ' > .dpt-actions-fixed > .btn-dpt-edit'); |
|
|
btn_dpt_edit.trigger('click') |
|
|
btn_dpt_edit.trigger( "click" ); |
|
|
|
|
|
} |
|
|
} |
|
|
instance.waitHide = function () { |
|
|
instance.waitHide = function () { |
|
|
$("#wait_message").addClass("displaynone"); |
|
|
$('#wait_message').addClass('displaynone') |
|
|
} |
|
|
} |
|
|
instance.waitShow = function () { |
|
|
instance.waitShow = function () { |
|
|
$("#wait_message").removeClass("displaynone"); |
|
|
$('#wait_message').removeClass('displaynone') |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
instance.init = function () { |
|
|
instance.init = function () { |
|
|
$('.dpt-actions-fixed').first().css('opacity','1'); |
|
|
$('.dpt-actions-fixed').first().css('opacity', '1') |
|
|
editortype = ReadCookie("editortype"); |
|
|
editortype = ReadCookie('editortype') |
|
|
if (editortype == null || editortype == '') { |
|
|
if (editortype == null || editortype == '') { |
|
|
editortype = "textarea" |
|
|
editortype = 'textarea' |
|
|
SetCookie("editortype", editortype, 30) |
|
|
SetCookie('editortype', editortype, 30) |
|
|
} |
|
|
} |
|
|
// editortype = "textarea";
|
|
|
// editortype = "textarea";
|
|
|
instance.offClicks(); |
|
|
instance.offClicks() |
|
|
instance.onClicks(); |
|
|
instance.onClicks() |
|
|
instance.reloadFunctionsDraggables(); |
|
|
instance.reloadFunctionsDraggables() |
|
|
|
|
|
|
|
|
href = location.href.split('#') |
|
|
href = location.href.split('#') |
|
|
if (href.length == 2 && href[1] != '') { |
|
|
if (href.length == 2 && href[1] != '') { |
|
|
instance.triggerBtnDptEdit(href[1]) |
|
|
instance.triggerBtnDptEdit(href[1]) |
|
|
} |
|
|
} |
|
|
$('main').click(function (event) { |
|
|
$('main').click(function (event) { |
|
|
if (event.target == this || event.target == this.firstElementChild) |
|
|
if (event.target == this || event.target == this.firstElementChild) { instance.clearEditSelected() } |
|
|
instance.clearEditSelected(); |
|
|
}) |
|
|
}); |
|
|
instance.waitHide() |
|
|
instance.waitHide(); |
|
|
|
|
|
} |
|
|
} |
|
|
instance.init(); |
|
|
instance.init() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () { |
|
|
$(document).ready(function () { |
|
|
|
|
|
DispositivoEdit() |
|
|
DispositivoEdit(); |
|
|
}) |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|