fix: contador y countdown de tomas prolongadas en lugar.php
- _guardarFirmaMP ahora llama guardar_toma.php en vez del draft POST, guardando la firma con clave campoId (sin _svg) que es la que lee get_consentimientos para el contador X/13. guardar_toma.php también actualiza estado→en_progreso y siguiente_toma_at, lo que activa el countdown en lugar.php via polling SSE. - Al completar la última toma envía postMessage turneroFirmado para cerrar el modal automáticamente. - Botón cerrar del modal siempre habilitado (el operador puede cerrar en cualquier momento durante el proceso). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
d2c1b58c2e
commit
4135e74d84
@@ -1391,7 +1391,7 @@ function abrirTomaProgresiva(token, turnoId, formularioId) {
|
||||
load.style.display = '';
|
||||
modal.style.display = 'flex';
|
||||
_tomaProgresivaActiva = true;
|
||||
_setBtnCerrarConsent(false);
|
||||
_setBtnCerrarConsent(true);
|
||||
setTimeout(() => {
|
||||
iframe.src = `${BASE_WA}ver_formulario_enviado.php?token=${encodeURIComponent(token)}&embed=1&compact=1&modo=toma_progresiva`;
|
||||
}, 80);
|
||||
@@ -1400,13 +1400,12 @@ function abrirTomaProgresiva(token, turnoId, formularioId) {
|
||||
function _setBtnCerrarConsent(habilitado) {
|
||||
const btn = document.getElementById('btn-cerrar-modal-consent');
|
||||
if (!btn) return;
|
||||
btn.disabled = !habilitado;
|
||||
btn.disabled = !habilitado;
|
||||
btn.style.opacity = habilitado ? '' : '.25';
|
||||
btn.title = habilitado ? 'Cerrar' : 'No puede cerrar durante una toma en progreso';
|
||||
btn.title = habilitado ? 'Cerrar' : 'Cerrando...';
|
||||
}
|
||||
|
||||
function cerrarModalConsentimiento(forzar) {
|
||||
if (!forzar && _tomaProgresivaActiva) return; // bloqueado hasta finalizar toma
|
||||
_tomaProgresivaActiva = false;
|
||||
_setBtnCerrarConsent(true);
|
||||
const modal = document.getElementById('modal-consentimiento');
|
||||
@@ -1421,13 +1420,13 @@ function cerrarModalConsentimiento(forzar) {
|
||||
window.addEventListener('message', function(e) {
|
||||
if (e.data && e.data.type === 'tomaProgresivaIniciada') {
|
||||
_tomaProgresivaActiva = true;
|
||||
_setBtnCerrarConsent(false);
|
||||
// Botón cerrar permanece habilitado; el operador puede cerrar en cualquier momento
|
||||
}
|
||||
if (e.data && e.data.type === 'turneroFirmado') {
|
||||
_tomaProgresivaActiva = false;
|
||||
_setBtnCerrarConsent(true);
|
||||
cerrarModalConsentimiento(true);
|
||||
mostrarToast('Consentimiento firmado ✓', 'success', 3000);
|
||||
mostrarToast('Tomas completadas ✓', 'success', 3000);
|
||||
if (turnoActivo) actualizarConsentimientos(turnoActivo.id);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user