fix(ui): make all form and writing modals persistent and protect unsaved input
This commit is contained in:
+8
-8
@@ -2545,7 +2545,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- MODAL: REGISTRAR NUEVO ESTUDIANTE (ADMIN) -->
|
<!-- MODAL: REGISTRAR NUEVO ESTUDIANTE (ADMIN) -->
|
||||||
<div class="modal-qr-backdrop" id="modalNewStudent" style="display: none;" onclick="closeNewStudentModal(event)">
|
<div class="modal-qr-backdrop" id="modalNewStudent" style="display: none;">
|
||||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 460px; text-align: left;">
|
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 460px; text-align: left;">
|
||||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 14px;">
|
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 14px;">
|
||||||
<div>
|
<div>
|
||||||
@@ -2629,7 +2629,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- MODAL: CREAR / EDITAR PRODUCTO (ADMIN) -->
|
<!-- MODAL: CREAR / EDITAR PRODUCTO (ADMIN) -->
|
||||||
<div class="modal-qr-backdrop" id="modalAdminProduct" style="display: none;" onclick="closeAdminProductModal(event)">
|
<div class="modal-qr-backdrop" id="modalAdminProduct" style="display: none;">
|
||||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 480px; text-align: left; max-height: 90vh; overflow-y: auto;">
|
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 480px; text-align: left; max-height: 90vh; overflow-y: auto;">
|
||||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px;">
|
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px;">
|
||||||
<div>
|
<div>
|
||||||
@@ -2714,7 +2714,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- MODAL: CREAR / EDITAR EMPLEADO O CAJERO (ADMIN) -->
|
<!-- MODAL: CREAR / EDITAR EMPLEADO O CAJERO (ADMIN) -->
|
||||||
<div class="modal-qr-backdrop" id="modalAdminStaff" style="display: none;" onclick="closeAdminStaffModal(event)">
|
<div class="modal-qr-backdrop" id="modalAdminStaff" style="display: none;">
|
||||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 460px; text-align: left;">
|
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 460px; text-align: left;">
|
||||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px;">
|
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px;">
|
||||||
<div>
|
<div>
|
||||||
@@ -2777,7 +2777,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- MODAL: RECREOTRANSFER (PASAR PLATA A UN COMPAÑERO ESCANEANDO SU QR O CARNÉ) -->
|
<!-- MODAL: RECREOTRANSFER (PASAR PLATA A UN COMPAÑERO ESCANEANDO SU QR O CARNÉ) -->
|
||||||
<div class="modal-qr-backdrop" id="modalTransfer" style="display: none;" onclick="closeTransferModal(event)">
|
<div class="modal-qr-backdrop" id="modalTransfer" style="display: none;">
|
||||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left;">
|
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left;">
|
||||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 12px;">
|
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 12px;">
|
||||||
<div>
|
<div>
|
||||||
@@ -3077,7 +3077,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- MODAL: CREAR / EDITAR USUARIO (DEVELOPER) -->
|
<!-- MODAL: CREAR / EDITAR USUARIO (DEVELOPER) -->
|
||||||
<div class="modal-qr-backdrop" id="modalDevUser" style="display: none;" onclick="closeModalDevUser(event)">
|
<div class="modal-qr-backdrop" id="modalDevUser" style="display: none;">
|
||||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 500px; text-align: left; padding: 22px;">
|
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 500px; text-align: left; padding: 22px;">
|
||||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1.5px solid var(--border); padding-bottom: 12px; margin-bottom: 16px;">
|
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1.5px solid var(--border); padding-bottom: 12px; margin-bottom: 16px;">
|
||||||
<div style="display: flex; align-items: center; gap: 10px;">
|
<div style="display: flex; align-items: center; gap: 10px;">
|
||||||
@@ -3161,7 +3161,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- MODAL: CAMBIO RÁPIDO DE CONTRASEÑA (DEVELOPER) -->
|
<!-- MODAL: CAMBIO RÁPIDO DE CONTRASEÑA (DEVELOPER) -->
|
||||||
<div class="modal-qr-backdrop" id="modalDevPassword" style="display: none;" onclick="closeModalDevPassword(event)">
|
<div class="modal-qr-backdrop" id="modalDevPassword" style="display: none;">
|
||||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left; padding: 22px;">
|
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left; padding: 22px;">
|
||||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1.5px solid var(--border); padding-bottom: 12px; margin-bottom: 16px;">
|
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1.5px solid var(--border); padding-bottom: 12px; margin-bottom: 16px;">
|
||||||
<div style="display: flex; align-items: center; gap: 10px;">
|
<div style="display: flex; align-items: center; gap: 10px;">
|
||||||
@@ -3197,7 +3197,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- MODAL: CREAR NUEVA ESCUELA / SEDE MULTI-TENANT (DEVELOPER) -->
|
<!-- MODAL: CREAR NUEVA ESCUELA / SEDE MULTI-TENANT (DEVELOPER) -->
|
||||||
<div class="modal-qr-backdrop" id="modalDevEscuela" style="display: none;" onclick="closeModalDevEscuela(event)">
|
<div class="modal-qr-backdrop" id="modalDevEscuela" style="display: none;">
|
||||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 540px; text-align: left; padding: 24px;">
|
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 540px; text-align: left; padding: 24px;">
|
||||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1.5px solid var(--border); padding-bottom: 12px; margin-bottom: 16px;">
|
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1.5px solid var(--border); padding-bottom: 12px; margin-bottom: 16px;">
|
||||||
<div style="display: flex; align-items: center; gap: 10px;">
|
<div style="display: flex; align-items: center; gap: 10px;">
|
||||||
@@ -3558,7 +3558,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- MODAL: RECHAZAR RECARGA SINPE CON MOTIVO Y TRAZABILIDAD -->
|
<!-- MODAL: RECHAZAR RECARGA SINPE CON MOTIVO Y TRAZABILIDAD -->
|
||||||
<div class="modal-qr-backdrop" id="modalRechazarSinpe" style="display: none; z-index: 99999;" onclick="cerrarModalRechazoSinpe(event)">
|
<div class="modal-qr-backdrop" id="modalRechazarSinpe" style="display: none; z-index: 99999;">
|
||||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: left; padding: 22px; border-radius: 18px;">
|
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: left; padding: 22px; border-radius: 18px;">
|
||||||
|
|
||||||
<!-- Encabezado -->
|
<!-- Encabezado -->
|
||||||
|
|||||||
+169
-21
@@ -1806,8 +1806,17 @@ function openTransferModal() {
|
|||||||
renderQuickTransferFriends();
|
renderQuickTransferFriends();
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeTransferModal(e) {
|
function closeTransferModal(force = false) {
|
||||||
if (e && e.target !== e.currentTarget) return;
|
if (force && force.target && force.target.classList && force.target.classList.contains('modal-qr-backdrop')) {
|
||||||
|
return; // Ignorar clics y arrastres sobre el fondo oscuro
|
||||||
|
}
|
||||||
|
const stepConfirm = document.getElementById('transferStepConfirm');
|
||||||
|
const isConfirming = stepConfirm && stepConfirm.style.display !== 'none';
|
||||||
|
if (force !== true && isConfirming) {
|
||||||
|
if (!confirm('¿Deseas cancelar la transferencia en curso?')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
stopTransferCamera();
|
stopTransferCamera();
|
||||||
const modal = document.getElementById('modalTransfer');
|
const modal = document.getElementById('modalTransfer');
|
||||||
if (modal) modal.style.display = 'none';
|
if (modal) modal.style.display = 'none';
|
||||||
@@ -5459,6 +5468,74 @@ async function toggleBlockCard(studentId, newBlocked) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==========================================
|
||||||
|
// GESTOR DE MODALES Y FORMULARIOS PERSISTENTES
|
||||||
|
// ==========================================
|
||||||
|
function snapshotFormInitialValues(formEl) {
|
||||||
|
if (!formEl) return;
|
||||||
|
const elements = formEl.querySelectorAll('input:not([type="hidden"]):not([type="submit"]):not([type="button"]), textarea, select');
|
||||||
|
elements.forEach(el => {
|
||||||
|
if (el.type === 'checkbox' || el.type === 'radio') {
|
||||||
|
el.dataset.initialChecked = el.checked ? 'true' : 'false';
|
||||||
|
} else {
|
||||||
|
el.dataset.initialVal = el.value || '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
window.snapshotFormInitialValues = snapshotFormInitialValues;
|
||||||
|
|
||||||
|
function isFormDirty(formEl) {
|
||||||
|
if (!formEl) return false;
|
||||||
|
const elements = formEl.querySelectorAll('input:not([type="hidden"]):not([type="submit"]):not([type="button"]), textarea, select');
|
||||||
|
for (const el of elements) {
|
||||||
|
if (el.type === 'checkbox' || el.type === 'radio') {
|
||||||
|
const init = el.dataset.initialChecked === 'true';
|
||||||
|
if (el.checked !== init) return true;
|
||||||
|
} else {
|
||||||
|
const initVal = el.dataset.initialVal !== undefined ? el.dataset.initialVal : '';
|
||||||
|
const currVal = el.value || '';
|
||||||
|
if (currVal.trim() !== initVal.trim() && currVal.trim().length > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
window.isFormDirty = isFormDirty;
|
||||||
|
|
||||||
|
// Manejador inteligente de la tecla ESC para modales de escritura / formularios
|
||||||
|
window.addEventListener('keydown', (e) => {
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
const activeFormModals = [
|
||||||
|
{ id: 'modalDevUser', close: () => closeModalDevUser(true), formId: 'formDevUser' },
|
||||||
|
{ id: 'modalNewStudent', close: () => closeNewStudentModal(true), formId: 'formNewStudent' },
|
||||||
|
{ id: 'modalAdminProduct', close: () => closeAdminProductModal(true), formId: 'formAdminProduct' },
|
||||||
|
{ id: 'modalAdminStaff', close: () => closeAdminStaffModal(true), formId: 'formAdminStaff' },
|
||||||
|
{ id: 'modalDevPassword', close: () => closeModalDevPassword(true), formId: 'formDevPassword' },
|
||||||
|
{ id: 'modalDevEscuela', close: () => closeModalDevEscuela(true), formId: 'formDevEscuela' },
|
||||||
|
{ id: 'modalTransfer', close: () => closeTransferModal(true), formId: null },
|
||||||
|
{ id: 'modalRechazarSinpe', close: () => (typeof window.cerrarModalRechazoSinpe === 'function' ? window.cerrarModalRechazoSinpe(true) : null), formId: null }
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const m of activeFormModals) {
|
||||||
|
const modalEl = document.getElementById(m.id);
|
||||||
|
if (modalEl && modalEl.style.display !== 'none' && getComputedStyle(modalEl).display !== 'none') {
|
||||||
|
const formEl = m.formId ? document.getElementById(m.formId) : null;
|
||||||
|
if (formEl && isFormDirty(formEl)) {
|
||||||
|
// Bloquear Escape si el usuario ya escribió datos para evitar pérdidas accidentales
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Si el formulario está vacío o sin cambios, cerrar con Escape
|
||||||
|
e.preventDefault();
|
||||||
|
if (typeof m.close === 'function') m.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function openNewStudentModal() {
|
function openNewStudentModal() {
|
||||||
window.newStudentFromDev = false;
|
window.newStudentFromDev = false;
|
||||||
const escContainer = document.getElementById('newEstEscuelaContainer');
|
const escContainer = document.getElementById('newEstEscuelaContainer');
|
||||||
@@ -5467,6 +5544,8 @@ function openNewStudentModal() {
|
|||||||
if (title) title.textContent = 'Registrar Nuevo Alumno';
|
if (title) title.textContent = 'Registrar Nuevo Alumno';
|
||||||
const modal = document.getElementById('modalNewStudent');
|
const modal = document.getElementById('modalNewStudent');
|
||||||
if (modal) modal.style.display = 'flex';
|
if (modal) modal.style.display = 'flex';
|
||||||
|
const form = document.getElementById('formNewStudent');
|
||||||
|
if (form) snapshotFormInitialValues(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openNewStudentModalFromDev() {
|
async function openNewStudentModalFromDev() {
|
||||||
@@ -5501,14 +5580,25 @@ async function openNewStudentModalFromDev() {
|
|||||||
|
|
||||||
const modal = document.getElementById('modalNewStudent');
|
const modal = document.getElementById('modalNewStudent');
|
||||||
if (modal) modal.style.display = 'flex';
|
if (modal) modal.style.display = 'flex';
|
||||||
|
const form = document.getElementById('formNewStudent');
|
||||||
|
if (form) snapshotFormInitialValues(form);
|
||||||
}
|
}
|
||||||
window.openNewStudentModalFromDev = openNewStudentModalFromDev;
|
window.openNewStudentModalFromDev = openNewStudentModalFromDev;
|
||||||
|
|
||||||
function closeNewStudentModal(event) {
|
function closeNewStudentModal(force = false) {
|
||||||
if (event && event.target !== event.currentTarget) return;
|
if (force && force.target && force.target.classList && force.target.classList.contains('modal-qr-backdrop')) {
|
||||||
|
return; // Ignorar clics y arrastres sobre el fondo oscuro
|
||||||
|
}
|
||||||
|
const form = document.getElementById('formNewStudent');
|
||||||
|
if (force !== true && isFormDirty(form)) {
|
||||||
|
if (!confirm('¿Deseas salir? Hay datos del estudiante sin guardar.')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
const modal = document.getElementById('modalNewStudent');
|
const modal = document.getElementById('modalNewStudent');
|
||||||
if (modal) modal.style.display = 'none';
|
if (modal) modal.style.display = 'none';
|
||||||
window.newStudentFromDev = false;
|
window.newStudentFromDev = false;
|
||||||
|
if (form) form.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitNewStudent(event) {
|
async function submitNewStudent(event) {
|
||||||
@@ -5566,7 +5656,7 @@ async function submitNewStudent(event) {
|
|||||||
const credsMsg = data.username_creado ? `\n\nCredenciales de Acceso:\nUsuario: ${data.username_creado}\nPIN temporal: ${data.pin_creado || '1234'}` : '';
|
const credsMsg = data.username_creado ? `\n\nCredenciales de Acceso:\nUsuario: ${data.username_creado}\nPIN temporal: ${data.pin_creado || '1234'}` : '';
|
||||||
alert(`¡Estudiante Creado con Éxito!\n\nNombre: ${data.nombre_completo}\nCódigo Estudiante: ${data.codigo_estudiante}\nQR Token: ${data.qr_token}${credsMsg}`);
|
alert(`¡Estudiante Creado con Éxito!\n\nNombre: ${data.nombre_completo}\nCódigo Estudiante: ${data.codigo_estudiante}\nQR Token: ${data.qr_token}${credsMsg}`);
|
||||||
|
|
||||||
closeNewStudentModal();
|
closeNewStudentModal(true);
|
||||||
document.getElementById('formNewStudent').reset();
|
document.getElementById('formNewStudent').reset();
|
||||||
|
|
||||||
// Actualizar vistas correspondientes
|
// Actualizar vistas correspondientes
|
||||||
@@ -6879,6 +6969,8 @@ function openCreateProductModal() {
|
|||||||
|
|
||||||
populateCategorySelect();
|
populateCategorySelect();
|
||||||
modal.style.display = 'flex';
|
modal.style.display = 'flex';
|
||||||
|
const form = document.getElementById('formAdminProduct');
|
||||||
|
if (form) snapshotFormInitialValues(form);
|
||||||
if (window.sounds) window.sounds.playTap();
|
if (window.sounds) window.sounds.playTap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6917,13 +7009,24 @@ function openEditProductModal(prodId) {
|
|||||||
|
|
||||||
populateCategorySelect(prod.categoria_id);
|
populateCategorySelect(prod.categoria_id);
|
||||||
modal.style.display = 'flex';
|
modal.style.display = 'flex';
|
||||||
|
const form = document.getElementById('formAdminProduct');
|
||||||
|
if (form) snapshotFormInitialValues(form);
|
||||||
if (window.sounds) window.sounds.playTap();
|
if (window.sounds) window.sounds.playTap();
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeAdminProductModal(event) {
|
function closeAdminProductModal(force = false) {
|
||||||
if (event && event.target !== event.currentTarget) return;
|
if (force && force.target && force.target.classList && force.target.classList.contains('modal-qr-backdrop')) {
|
||||||
|
return; // Ignorar clics y arrastres sobre el fondo oscuro
|
||||||
|
}
|
||||||
|
const form = document.getElementById('formAdminProduct');
|
||||||
|
if (force !== true && isFormDirty(form)) {
|
||||||
|
if (!confirm('¿Deseas descartar los cambios? Hay datos del producto sin guardar.')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
const modal = document.getElementById('modalAdminProduct');
|
const modal = document.getElementById('modalAdminProduct');
|
||||||
if (modal) modal.style.display = 'none';
|
if (modal) modal.style.display = 'none';
|
||||||
|
if (form) form.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitAdminProduct(e) {
|
async function submitAdminProduct(e) {
|
||||||
@@ -6970,7 +7073,7 @@ async function submitAdminProduct(e) {
|
|||||||
if (!res.ok) throw new Error(data.error || 'Error al guardar producto');
|
if (!res.ok) throw new Error(data.error || 'Error al guardar producto');
|
||||||
|
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
if (window.sounds) window.sounds.playSuccess();
|
||||||
closeAdminProductModal();
|
closeAdminProductModal(true);
|
||||||
await loadAdminData();
|
await loadAdminData();
|
||||||
|
|
||||||
if (typeof loadInitialData === 'function') {
|
if (typeof loadInitialData === 'function') {
|
||||||
@@ -7000,7 +7103,7 @@ async function handleDeleteProduct() {
|
|||||||
if (!res.ok) throw new Error(data.error || 'Error al eliminar producto');
|
if (!res.ok) throw new Error(data.error || 'Error al eliminar producto');
|
||||||
|
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
if (window.sounds) window.sounds.playSuccess();
|
||||||
closeAdminProductModal();
|
closeAdminProductModal(true);
|
||||||
await loadAdminData();
|
await loadAdminData();
|
||||||
if (typeof loadInitialData === 'function') {
|
if (typeof loadInitialData === 'function') {
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
@@ -7166,6 +7269,8 @@ function openCreateStaffModal() {
|
|||||||
if (btnSubmit) btnSubmit.innerHTML = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg> <span>Guardar Empleado</span>';
|
if (btnSubmit) btnSubmit.innerHTML = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg> <span>Guardar Empleado</span>';
|
||||||
|
|
||||||
modal.style.display = 'flex';
|
modal.style.display = 'flex';
|
||||||
|
const form = document.getElementById('formAdminStaff');
|
||||||
|
if (form) snapshotFormInitialValues(form);
|
||||||
if (window.sounds) window.sounds.playTap();
|
if (window.sounds) window.sounds.playTap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7206,13 +7311,24 @@ function openEditStaffModal(staffId) {
|
|||||||
if (btnSubmit) btnSubmit.innerHTML = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg> <span>Actualizar Datos</span>';
|
if (btnSubmit) btnSubmit.innerHTML = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg> <span>Actualizar Datos</span>';
|
||||||
|
|
||||||
modal.style.display = 'flex';
|
modal.style.display = 'flex';
|
||||||
|
const form = document.getElementById('formAdminStaff');
|
||||||
|
if (form) snapshotFormInitialValues(form);
|
||||||
if (window.sounds) window.sounds.playTap();
|
if (window.sounds) window.sounds.playTap();
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeAdminStaffModal(event) {
|
function closeAdminStaffModal(force = false) {
|
||||||
if (event && event.target !== event.currentTarget) return;
|
if (force && force.target && force.target.classList && force.target.classList.contains('modal-qr-backdrop')) {
|
||||||
|
return; // Ignorar clics y arrastres sobre el fondo oscuro
|
||||||
|
}
|
||||||
|
const form = document.getElementById('formAdminStaff');
|
||||||
|
if (force !== true && isFormDirty(form)) {
|
||||||
|
if (!confirm('¿Deseas descartar los cambios? Hay datos del empleado sin guardar.')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
const modal = document.getElementById('modalAdminStaff');
|
const modal = document.getElementById('modalAdminStaff');
|
||||||
if (modal) modal.style.display = 'none';
|
if (modal) modal.style.display = 'none';
|
||||||
|
if (form) form.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitAdminStaff(e) {
|
async function submitAdminStaff(e) {
|
||||||
@@ -7265,7 +7381,7 @@ async function submitAdminStaff(e) {
|
|||||||
if (!res.ok) throw new Error(data.error || 'Error al procesar empleado');
|
if (!res.ok) throw new Error(data.error || 'Error al procesar empleado');
|
||||||
|
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
if (window.sounds) window.sounds.playSuccess();
|
||||||
closeAdminStaffModal();
|
closeAdminStaffModal(true);
|
||||||
await loadAdminStaff();
|
await loadAdminStaff();
|
||||||
alert(isEdit ? 'Datos de empleado actualizados correctamente.' : 'Empleado creado exitosamente con credenciales de acceso.');
|
alert(isEdit ? 'Datos de empleado actualizados correctamente.' : 'Empleado creado exitosamente con credenciales de acceso.');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -7827,14 +7943,25 @@ function openModalDevUser(userId = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modal.style.display = 'flex';
|
modal.style.display = 'flex';
|
||||||
|
const form = document.getElementById('formDevUser');
|
||||||
|
if (form) snapshotFormInitialValues(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeModalDevUser(event) {
|
function closeModalDevUser(force = false) {
|
||||||
if (event && event.target !== event.currentTarget) return;
|
if (force && force.target && force.target.classList && force.target.classList.contains('modal-qr-backdrop')) {
|
||||||
|
return; // Ignorar clics y arrastres sobre el fondo oscuro
|
||||||
|
}
|
||||||
|
const form = document.getElementById('formDevUser');
|
||||||
|
if (force !== true && isFormDirty(form)) {
|
||||||
|
if (!confirm('¿Deseas descartar los cambios? Hay información sin guardar en el formulario de usuario.')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
const modal = document.getElementById('modalDevUser');
|
const modal = document.getElementById('modalDevUser');
|
||||||
if (modal) modal.style.display = 'none';
|
if (modal) modal.style.display = 'none';
|
||||||
const tip = document.getElementById('devStudentRoleTip');
|
const tip = document.getElementById('devStudentRoleTip');
|
||||||
if (tip) tip.style.display = 'none';
|
if (tip) tip.style.display = 'none';
|
||||||
|
if (form) form.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveDevUser(e) {
|
async function saveDevUser(e) {
|
||||||
@@ -7873,7 +8000,7 @@ async function saveDevUser(e) {
|
|||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (!res.ok) throw new Error(data.error || 'Error al guardar usuario');
|
if (!res.ok) throw new Error(data.error || 'Error al guardar usuario');
|
||||||
|
|
||||||
closeModalDevUser();
|
closeModalDevUser(true);
|
||||||
await loadDevUsuarios();
|
await loadDevUsuarios();
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
if (window.sounds) window.sounds.playSuccess();
|
||||||
alert(userId ? 'Usuario actualizado con éxito' : 'Usuario creado con éxito');
|
alert(userId ? 'Usuario actualizado con éxito' : 'Usuario creado con éxito');
|
||||||
@@ -7894,12 +8021,23 @@ function openModalDevPassword(userId, username) {
|
|||||||
targetLabel.textContent = `Usuario: ${username}`;
|
targetLabel.textContent = `Usuario: ${username}`;
|
||||||
pwdInput.value = '';
|
pwdInput.value = '';
|
||||||
modal.style.display = 'flex';
|
modal.style.display = 'flex';
|
||||||
|
const form = document.getElementById('formDevPassword');
|
||||||
|
if (form) snapshotFormInitialValues(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeModalDevPassword(event) {
|
function closeModalDevPassword(force = false) {
|
||||||
if (event && event.target !== event.currentTarget) return;
|
if (force && force.target && force.target.classList && force.target.classList.contains('modal-qr-backdrop')) {
|
||||||
|
return; // Ignorar clics y arrastres sobre el fondo oscuro
|
||||||
|
}
|
||||||
|
const form = document.getElementById('formDevPassword');
|
||||||
|
if (force !== true && isFormDirty(form)) {
|
||||||
|
if (!confirm('¿Deseas cancelar el cambio de contraseña?')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
const modal = document.getElementById('modalDevPassword');
|
const modal = document.getElementById('modalDevPassword');
|
||||||
if (modal) modal.style.display = 'none';
|
if (modal) modal.style.display = 'none';
|
||||||
|
if (form) form.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveDevPassword(e) {
|
async function saveDevPassword(e) {
|
||||||
@@ -7922,7 +8060,7 @@ async function saveDevPassword(e) {
|
|||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (!res.ok) throw new Error(data.error || 'Error al cambiar contraseña');
|
if (!res.ok) throw new Error(data.error || 'Error al cambiar contraseña');
|
||||||
|
|
||||||
closeModalDevPassword();
|
closeModalDevPassword(true);
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
if (window.sounds) window.sounds.playSuccess();
|
||||||
alert('Contraseña actualizada correctamente');
|
alert('Contraseña actualizada correctamente');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -8416,13 +8554,23 @@ function openModalDevEscuela() {
|
|||||||
if (form) form.reset();
|
if (form) form.reset();
|
||||||
const modal = document.getElementById('modalDevEscuela');
|
const modal = document.getElementById('modalDevEscuela');
|
||||||
if (modal) modal.style.display = 'flex';
|
if (modal) modal.style.display = 'flex';
|
||||||
|
if (form) snapshotFormInitialValues(form);
|
||||||
setTimeout(() => document.getElementById('devEscuelaCodigo')?.focus(), 50);
|
setTimeout(() => document.getElementById('devEscuelaCodigo')?.focus(), 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeModalDevEscuela(e) {
|
function closeModalDevEscuela(force = false) {
|
||||||
if (e && e.target !== e.currentTarget && !e.target.classList.contains('modal-qr-backdrop')) return;
|
if (force && force.target && force.target.classList && force.target.classList.contains('modal-qr-backdrop')) {
|
||||||
|
return; // Ignorar clics y arrastres sobre el fondo oscuro
|
||||||
|
}
|
||||||
|
const form = document.getElementById('formDevEscuela');
|
||||||
|
if (force !== true && isFormDirty(form)) {
|
||||||
|
if (!confirm('¿Deseas salir? Hay datos de la nueva escuela sin guardar.')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
const modal = document.getElementById('modalDevEscuela');
|
const modal = document.getElementById('modalDevEscuela');
|
||||||
if (modal) modal.style.display = 'none';
|
if (modal) modal.style.display = 'none';
|
||||||
|
if (form) form.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
function verCredencialesEscuela(codigo, nombre) {
|
function verCredencialesEscuela(codigo, nombre) {
|
||||||
@@ -8464,7 +8612,7 @@ async function guardarDevEscuela(e) {
|
|||||||
|
|
||||||
if (window.sounds) window.sounds.playCoin();
|
if (window.sounds) window.sounds.playCoin();
|
||||||
|
|
||||||
closeModalDevEscuela();
|
closeModalDevEscuela(true);
|
||||||
alert(`¡Éxito al dar de alta la escuela!\n\n` +
|
alert(`¡Éxito al dar de alta la escuela!\n\n` +
|
||||||
`Sede: ${data.nombre} (${data.codigo})\n\n` +
|
`Sede: ${data.nombre} (${data.codigo})\n\n` +
|
||||||
`Se creó el catálogo de productos y las siguientes cuentas operativas:\n` +
|
`Se creó el catálogo de productos y las siguientes cuentas operativas:\n` +
|
||||||
|
|||||||
+10
-3
@@ -168,7 +168,6 @@
|
|||||||
modal.className = 'modal-qr-backdrop';
|
modal.className = 'modal-qr-backdrop';
|
||||||
modal.id = 'modalRechazarSinpe';
|
modal.id = 'modalRechazarSinpe';
|
||||||
modal.style.cssText = 'display: none; z-index: 99999;';
|
modal.style.cssText = 'display: none; z-index: 99999;';
|
||||||
modal.setAttribute('onclick', 'cerrarModalRechazoSinpe(event)');
|
|
||||||
modal.innerHTML = `
|
modal.innerHTML = `
|
||||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: left; padding: 22px; border-radius: 18px;">
|
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: left; padding: 22px; border-radius: 18px;">
|
||||||
<!-- Encabezado -->
|
<!-- Encabezado -->
|
||||||
@@ -295,10 +294,18 @@
|
|||||||
modal.style.display = 'flex';
|
modal.style.display = 'flex';
|
||||||
};
|
};
|
||||||
|
|
||||||
window.cerrarModalRechazoSinpe = function(event) {
|
window.cerrarModalRechazoSinpe = function(force = false) {
|
||||||
if (event && event.target && event.target !== document.getElementById('modalRechazarSinpe')) {
|
if (force && force.target && force.target.classList && force.target.classList.contains('modal-qr-backdrop')) {
|
||||||
|
return; // Ignorar clic/arrastre sobre el fondo
|
||||||
|
}
|
||||||
|
const note = document.getElementById('sinpeRejectNotaAdmin');
|
||||||
|
const customTxt = document.getElementById('sinpeRejectMotivoCustom');
|
||||||
|
const isDirty = (note && note.value.trim().length > 0) || (customTxt && customTxt.value.trim().length > 0);
|
||||||
|
if (force !== true && isDirty) {
|
||||||
|
if (!confirm('¿Deseas cancelar el rechazo de la recarga? Se perderá la nota escrita.')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const modal = document.getElementById('modalRechazarSinpe');
|
const modal = document.getElementById('modalRechazarSinpe');
|
||||||
if (modal) modal.style.display = 'none';
|
if (modal) modal.style.display = 'none';
|
||||||
currentSinpeRejectData = null;
|
currentSinpeRejectData = null;
|
||||||
|
|||||||
+1
-1
@@ -583,7 +583,7 @@
|
|||||||
<div id="posThermalReceipt" style="display: none;"></div>
|
<div id="posThermalReceipt" style="display: none;"></div>
|
||||||
|
|
||||||
<!-- MODAL: RECHAZAR RECARGA SINPE CON MOTIVO Y TRAZABILIDAD -->
|
<!-- MODAL: RECHAZAR RECARGA SINPE CON MOTIVO Y TRAZABILIDAD -->
|
||||||
<div class="modal-qr-backdrop" id="modalRechazarSinpe" style="display: none; z-index: 99999;" onclick="cerrarModalRechazoSinpe(event)">
|
<div class="modal-qr-backdrop" id="modalRechazarSinpe" style="display: none; z-index: 99999;">
|
||||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: left; padding: 22px; border-radius: 18px;">
|
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: left; padding: 22px; border-radius: 18px;">
|
||||||
|
|
||||||
<!-- Encabezado -->
|
<!-- Encabezado -->
|
||||||
|
|||||||
Reference in New Issue
Block a user