From 2d5efe75a6cc3efa1b3c56a4b40d75684fa4c900 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Wed, 2 Aug 2023 12:44:05 +0200 Subject: [PATCH] modificados boton editar y borrar de la lista --- .../viewTarifaEncuadernacionList.php | 68 +++++++------------ 1 file changed, 26 insertions(+), 42 deletions(-) diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php index a9445187..6810c9af 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php @@ -1,5 +1,5 @@ include('themes/_commonPartialsBs/datatables') ?> -include('themes/_commonPartialsBs/sweetalert') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> extend('themes/backend/vuexy/main/defaultlayout') ?> section('content'); ?>
@@ -41,12 +41,13 @@ const lastColNr = $('#tableOfTarifasencuadernacion').find("tr:first th").length - 1; const actionBtns = function(data) { - return ` + return ` +
- - + +
- `; + `; }; theTable = $('#tableOfTarifasencuadernacion').DataTable({ @@ -94,46 +95,29 @@ $(document).on('click', '.btn-edit', function(e) { - //window.location.href = `/${$(this).attr('data-id')}/edit`; window.location.href = `/tarifas/tarifasencuadernacion/edit/${$(this).attr('data-id')}`; }); - + $(document).on('click', '.btn-delete', function(e) { - Swal.fire({ - title: '', - text: '', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#3085d6', - confirmButtonText: '', - cancelButtonText: '', - cancelButtonColor: '#d33' - }) - .then((result) => { - const dataId = $(this).data('id'); - const row = $(this).closest('tr'); - if (result.value) { - $.ajax({ - //url: `/${dataId}`, - //method: 'DELETE', - url: `/tarifas/tarifasencuadernacion/delete/${dataId}`, - method: 'GET', - }).done((data, textStatus, jqXHR) => { - Toast.fire({ - icon: 'success', - title: data.msg ?? jqXHR.statusText, - }); - - theTable.clearPipeline(); - theTable.row($(row)).invalidate().draw(); - }).fail((jqXHR, textStatus, errorThrown) => { - Toast.fire({ - icon: 'error', - title: jqXHR.responseJSON.messages.error, - }); - }) - } - }); + $(".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: `/tarifas/tarifasencuadernacion/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }) + } });