mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminada pestaña cliente tarifas
This commit is contained in:
@ -205,21 +205,19 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
->on('preCreate', function ($editor, &$values) {
|
->on('preCreate', function ($editor, &$values) {
|
||||||
$session = session();
|
|
||||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||||
$editor
|
$editor
|
||||||
->field('user_updated_id')
|
->field('user_updated_id')
|
||||||
->setValue($session->id_user);
|
->setValue(auth()->user()->id);
|
||||||
$editor
|
$editor
|
||||||
->field('updated_at')
|
->field('updated_at')
|
||||||
->setValue($datetime->format('Y-m-d H:i:s'));
|
->setValue($datetime->format('Y-m-d H:i:s'));
|
||||||
})
|
})
|
||||||
->on('preEdit', function ($editor, &$values) {
|
->on('preEdit', function ($editor, &$values) {
|
||||||
$session = session();
|
|
||||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||||
$editor
|
$editor
|
||||||
->field('user_updated_id')
|
->field('user_updated_id')
|
||||||
->setValue($session->id_user);
|
->setValue(auth()->user()->id);
|
||||||
$editor
|
$editor
|
||||||
->field('updated_at')
|
->field('updated_at')
|
||||||
->setValue($datetime->format('Y-m-d H:i:s'));
|
->setValue($datetime->format('Y-m-d H:i:s'));
|
||||||
|
|||||||
@ -1,9 +1,16 @@
|
|||||||
class ConfirmDeleteModal {
|
class ConfirmDeleteModal {
|
||||||
|
|
||||||
constructor(alias = "") {
|
constructor(alias = "") {
|
||||||
this.modalId = 'confirm2delete';
|
|
||||||
|
this.modalId = alias !== "" ? `confirm2delete-${alias}`: 'confirm2delete';
|
||||||
|
|
||||||
const removeClass = alias !== "" ? `btn-remove-${alias}` : 'btn-remove';
|
const removeClass = alias !== "" ? `btn-remove-${alias}` : 'btn-remove';
|
||||||
|
|
||||||
|
this.btnCancelId = alias !== "" ? `btnCancelDelete-${alias}` : 'btnCancelDelete';
|
||||||
|
this.btnDeleteId = alias !== "" ? `btnConfirmDelete-${alias}` : 'btnConfirmDelete';
|
||||||
|
|
||||||
|
this.data = null;
|
||||||
|
|
||||||
this.modalHtml = `
|
this.modalHtml = `
|
||||||
<div class="modal fade" id="${this.modalId}" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="${this.modalId}Label" aria-hidden="true">
|
<div class="modal fade" id="${this.modalId}" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="${this.modalId}Label" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-centered">
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
@ -16,8 +23,8 @@ class ConfirmDeleteModal {
|
|||||||
Esta acción no se puede deshacer.
|
Esta acción no se puede deshacer.
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancelar</button>
|
<button id=${this.btnCancelId} type="button" class="btn btn-default" data-bs-dismiss="modal">Cancelar</button>
|
||||||
<a id="confirmDelete" href="javascript:void(0);" class="btn btn-danger btn-confirm ${removeClass}">Eliminar</a>
|
<a id=${this.btnDeleteId} href="javascript:void(0);" class="btn btn-danger btn-confirm ${removeClass}">Eliminar</a>
|
||||||
</div><!--//.modal-footer -->
|
</div><!--//.modal-footer -->
|
||||||
</div><!--//.modal-content -->
|
</div><!--//.modal-content -->
|
||||||
</div><!--//.modal-dialog -->
|
</div><!--//.modal-dialog -->
|
||||||
@ -25,19 +32,39 @@ class ConfirmDeleteModal {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Método para mostrar el modal
|
init() {
|
||||||
show(callback) {
|
|
||||||
// Insertar el modal en el body del documento si no existe
|
// Insertar el modal en el body del documento si no existe
|
||||||
if (!document.getElementById(this.modalId)) {
|
if (!document.getElementById(this.modalId)) {
|
||||||
document.body.insertAdjacentHTML('beforeend', this.modalHtml);
|
document.body.insertAdjacentHTML('beforeend', this.modalHtml);
|
||||||
}
|
}
|
||||||
|
document.getElementById(this.btnCancelId).addEventListener('click', () => {
|
||||||
|
const modal = new bootstrap.Modal(document.getElementById(this.modalId));
|
||||||
|
modal.hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getModalId() {
|
||||||
|
return '#' + this.modalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
setData(data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Método para mostrar el modal
|
||||||
|
show(callback) {
|
||||||
|
|
||||||
// Mostrar el modal usando Bootstrap
|
// Mostrar el modal usando Bootstrap
|
||||||
const modal = new bootstrap.Modal(document.getElementById(this.modalId));
|
const modal = new bootstrap.Modal(document.getElementById(this.modalId));
|
||||||
modal.show();
|
modal.show();
|
||||||
|
|
||||||
// Configurar el evento de confirmación de eliminación
|
// Configurar el evento de confirmación de eliminación
|
||||||
document.getElementById('confirmDelete').addEventListener('click', () => {
|
document.getElementById(this.btnDeleteId).addEventListener('click', () => {
|
||||||
callback(); // Llamar al callback que el usuario haya proporcionado
|
callback(); // Llamar al callback que el usuario haya proporcionado
|
||||||
modal.hide(); // Cerrar el modal
|
modal.hide(); // Cerrar el modal
|
||||||
});
|
});
|
||||||
@ -49,3 +76,6 @@ class ConfirmDeleteModal {
|
|||||||
modal.hide();
|
modal.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default ConfirmDeleteModal;
|
||||||
@ -23,15 +23,13 @@ let Table = function (
|
|||||||
dom = '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
|
dom = '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
|
||||||
actions = ['view', 'edit', 'delete', 'cancel'],
|
actions = ['view', 'edit', 'delete', 'cancel'],
|
||||||
order = [[0, 'asc']],
|
order = [[0, 'asc']],
|
||||||
deleteModal = null,
|
|
||||||
buttonsExport = true,
|
buttonsExport = true,
|
||||||
buttonNewWithEditor = false,
|
buttonNewWithEditor = false,
|
||||||
editor = null,
|
editor = null,
|
||||||
booleanColumns = [],
|
booleanColumns = [],
|
||||||
} = {}) {
|
} = {}) {
|
||||||
|
|
||||||
this.actions = actions; // Guardar actions como propiedad de la instancia
|
this.actions = actions;
|
||||||
this.deleteModal = deleteModal;
|
|
||||||
|
|
||||||
const lastColNr = this.domItem.find("tr:first th").length - 1;
|
const lastColNr = this.domItem.find("tr:first th").length - 1;
|
||||||
|
|
||||||
@ -124,6 +122,10 @@ let Table = function (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.getAlias = function () {
|
||||||
|
return this.alias;
|
||||||
|
}
|
||||||
|
|
||||||
this.setData = function (data) {
|
this.setData = function (data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
@ -165,7 +167,7 @@ let Table = function (
|
|||||||
btns += `<span class="cancel"></span>`;
|
btns += `<span class="cancel"></span>`;
|
||||||
}
|
}
|
||||||
if (this.actions.includes('delete')) {
|
if (this.actions.includes('delete')) {
|
||||||
btns += `<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-${this.alias} mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="${this.deleteModal}"></i></a>`;
|
btns += `<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-${this.alias} mx-2" data-id="${data.id}"></i></a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return btns;
|
return btns;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import Table from '../../components/table.js';
|
import Table from '../../components/table.js';
|
||||||
import TableEditor from '../../components/tableEditor.js';
|
import TableEditor from '../../components/tableEditor.js';
|
||||||
import Confirm2Delete from '../../components/confirm2delete.js';
|
import ConfirmDeleteModal from '../../components/ConfirmDeleteModal.js';
|
||||||
import { getToken } from '../../common/common.js';
|
import { getToken } from '../../common/common.js';
|
||||||
|
|
||||||
|
|
||||||
@ -21,12 +21,16 @@ class tarifasClienteView {
|
|||||||
this.tableTarifas = null;
|
this.tableTarifas = null;
|
||||||
this.editorTarifas = null;
|
this.editorTarifas = null;
|
||||||
this.confirmDeleteModal = null;
|
this.confirmDeleteModal = null;
|
||||||
|
this.deleteModal = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
this.deleteModal = new ConfirmDeleteModal('tarifascliente');
|
||||||
|
this.deleteModal.init();
|
||||||
|
|
||||||
this.#initEditor();
|
this.#initEditor();
|
||||||
|
|
||||||
this.#initTable();
|
this.#initTable();
|
||||||
@ -51,6 +55,21 @@ class tarifasClienteView {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
this.tableTarifas.table.on('click', '.btn-delete-' + this.tableTarifas.getAlias(), function (e) {
|
||||||
|
const row = $(this).closest('tr')[0]._DT_RowIndex;
|
||||||
|
self.deleteModal.setData($(this).attr('data-id'));
|
||||||
|
self.deleteModal.show(() =>{
|
||||||
|
if ($.isNumeric(self.deleteModal.getData())) {
|
||||||
|
self.editorTarifas.editor
|
||||||
|
.create( false )
|
||||||
|
.edit( self.tableTarifas.table.rows(row), false)
|
||||||
|
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
||||||
|
.set( 'is_deleted', 1 )
|
||||||
|
.submit();
|
||||||
|
self.deleteModal.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +265,6 @@ class tarifasClienteView {
|
|||||||
buttonNewWithEditor: true,
|
buttonNewWithEditor: true,
|
||||||
buttonsExport: true,
|
buttonsExport: true,
|
||||||
editor: this.editorTarifas.editor,
|
editor: this.editorTarifas.editor,
|
||||||
deleteModal: '#confirm2delete'
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -262,6 +280,8 @@ class tarifasClienteView {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
headerSearcher() {
|
headerSearcher() {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|||||||
Reference in New Issue
Block a user