modificacion finalizada y testeada

This commit is contained in:
Jaime Jiménez
2023-08-22 09:45:10 +02:00
parent 4b1cb72ec0
commit ed018c3364
4 changed files with 51 additions and 35 deletions

View File

@ -183,6 +183,35 @@
cache: true
}
});
// Delete row
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
if($(this).closest('table').attr('id').includes('margenes')){
$(".btn-remove").attr('table', "margenes");
}
else if($(this).closest('table').attr('id').includes('tipologias')){
$(".btn-remove").attr('table', "tipologias");
}
else{
$(".btn-remove").attr('table', );
}
});
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
if($(this).attr('table').includes('margenes')){
remove_margenes(dataId, row);
}
else if ($(this).attr('table').includes('tipologias')){
remove_tipologias(dataId, row);
}
}
});
<?= $this->endSection() ?>
@ -302,7 +331,7 @@
// Activate an inline edit on click of a table cell
$(document).on('click', '.btn-edit2', function(e) {
editor.inline(
editor3.inline(
theTable3.cells(this.parentNode.parentNode.parentNode, '*').nodes(),
{
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
@ -341,32 +370,23 @@
});
/*
// Delete row
function remove_margenes(dataId, row){
// Borrar registro
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
});
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
$.ajax({
url: `/configuracion/papelimpresiontipologias/delete/${dataId}`,
$.ajax({
url: `/configuracion/papelimpresionmargenes/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
$('#confirm2delete').modal('toggle');
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
theTable3.clearPipeline();
theTable3.row($(row)).invalidate().draw();
popSuccessAlert(data.msg ?? jqXHR.statusText);
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
}
});
*/
});
}
<?= $this->endSection() ?>
<!------------------------------------------->
@ -507,6 +527,7 @@
// Notificar que no se pueden añadir más tipologías
editor.on( 'initCreate', function () {
if ( $('#tableOfPapelimpresiontipologias').DataTable().data().count() >= 3 ){
editor.close();
popErrorAlert('<?= lang('Basic.global.sweet.maxRowsReached') ?>');
}
});
@ -553,16 +574,10 @@
});
// Borrar registro
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
});
// Delete row
function remove_tipologias(dataId, row){
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
$.ajax({
$.ajax({
url: `/configuracion/papelimpresiontipologias/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
@ -572,9 +587,9 @@
popSuccessAlert(data.msg ?? jqXHR.statusText);
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
}
});
});
}
<?= $this->endSection() ?>