From 7a4413e1737b9419a48f7bded2858a45c09ea73e Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Thu, 16 Jul 2026 13:05:26 -0500 Subject: [PATCH] fix: banner toma no se cierra al abrir directamente por 'Siguiente toma' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit El banner de alerta solo se cerraba vía 'Ver paciente'. Si el profesional hacía clic en 'Siguiente toma' directamente, el banner seguía parpadeando y sonando aunque el formulario ya estuviera abierto. - abrirTomaProgresiva() ahora llama cerrarBannerToma() + _tomaAlertados.delete() - renderConsentimientos() preserva alertado:true si la siguiente_toma_at no cambió, evitando beep doble al re-sincronizar después de firmar Co-Authored-By: Claude Sonnet 4.6 --- modules/turnero/views/lugar.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/turnero/views/lugar.php b/modules/turnero/views/lugar.php index e0bbf90..ef6942e 100644 --- a/modules/turnero/views/lugar.php +++ b/modules/turnero/views/lugar.php @@ -1363,13 +1363,18 @@ function renderConsentimientos(lista) { sinEl.classList.add('d-none'); banner.classList.toggle('d-none', !hayPendientes); - // Actualizar mapa de timers para tomas progresivas + // Actualizar mapa de timers para tomas progresivas (preservar alertado si ya sonó) + const _prevTimers = _tomaTimers; _tomaTimers = {}; lista.forEach(c => { if (c.es_toma_progresiva && c.estado === 'en_progreso') { + const prev = _prevTimers[c.id]; + const newAt = c.siguiente_toma_at ? new Date(c.siguiente_toma_at.replace(' ', 'T')).getTime() : null; + // Si la siguiente_toma_at cambió (firmó una toma), resetear alertado para el nuevo tiempo + const sameTime = prev && prev.siguiente_toma_at === newAt; _tomaTimers[c.id] = { - siguiente_toma_at: c.siguiente_toma_at ? new Date(c.siguiente_toma_at.replace(' ', 'T')).getTime() : null, - alertado: false, + siguiente_toma_at: newAt, + alertado: sameTime ? (prev.alertado || false) : false, }; } }); @@ -1497,6 +1502,8 @@ function abrirModalConsentimientoPorToken(token) { // ── Toma progresiva: abre el modal con modo especial ────────── function abrirTomaProgresiva(token, turnoId, formularioId) { + cerrarBannerToma(); + _tomaAlertados.delete(turnoId); const modal = document.getElementById('modal-consentimiento'); const iframe = document.getElementById('modal-consent-iframe'); const load = document.getElementById('modal-consent-loading');