feat(toma-progresiva): resumen visible 10s con barra y cuenta regresiva antes de cerrar

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-17 21:43:49 -05:00
co-authored by Claude Sonnet 4.6
parent 5a5e4b17ba
commit 18c683ed9b
+22 -5
View File
@@ -2048,13 +2048,13 @@ function _guardarFirmaMP(widget, svg, msgEl, entry, campoId) {
_mpRefreshCards(campoId, data.completado ? null : entry.next_firma_id);
if (data.completado) {
// Toma completada: mostrar resumen de tomas y cerrar modal
// Toma completada: mostrar resumen 10 s y luego cerrar modal
var cd = document.getElementById('mp-countdown');
if (cd) { clearInterval(cd._mpTick); cd.remove(); }
_mpMostrarResumen(entry.exam_type || 'Examen');
_mpMostrarResumen(entry.exam_type || 'Examen', 10);
setTimeout(function() {
try { window.parent.postMessage({ type: 'turneroFirmado' }, '*'); } catch(e) {}
}, 2000);
}, 10000);
} else if (data.siguiente_toma_at) {
// Fix 2: pasar timestamp exacto; evita el redondeo de Math.round
var targetMs = new Date(data.siguiente_toma_at.replace(' ', 'T')).getTime();
@@ -2169,8 +2169,9 @@ function _mpIniciarCountdown(targetMsOrMins, nextLabel, nextFirmaId) {
}, 1000);
}
function _mpMostrarResumen(examType) {
function _mpMostrarResumen(examType, segs) {
if (document.getElementById('mp-resumen')) return;
segs = segs || 10;
// Recopilar horas y resultados de las tomas visibles
var rows = [];
if (window._muestrasMap) {
@@ -2199,8 +2200,24 @@ function _mpMostrarResumen(examType) {
}).join('') + '</tbody></table>' : '';
wrap.innerHTML = '<div class="d-flex align-items-center gap-2"><i class="fas fa-check-double fs-5"></i>'
+ '<div><strong>' + (examType || 'Examen') + ' completado.</strong><br>'
+ '<small>Todas las tomas registradas. Cerrando...</small></div></div>' + rowsHtml;
+ '<small>Todas las tomas registradas. Cerrando en <span id="mp-resumen-seg">' + segs + '</span>s…</small></div></div>'
+ rowsHtml
+ '<div style="margin-top:10px;height:5px;background:#c3e6cb;border-radius:3px">'
+ '<div id="mp-resumen-bar" style="height:100%;width:100%;background:#198754;border-radius:3px;'
+ 'transition:width ' + segs + 's linear"></div></div>';
document.querySelector('.doc-body').appendChild(wrap);
// Animar barra y cuenta regresiva
requestAnimationFrame(function() { requestAnimationFrame(function() {
var bar = document.getElementById('mp-resumen-bar');
if (bar) bar.style.width = '0%';
}); });
var left = segs;
var tick = setInterval(function() {
left--;
var el = document.getElementById('mp-resumen-seg');
if (el) el.textContent = left;
if (left <= 0) clearInterval(tick);
}, 1000);
// Ocultar countdown si queda
var cd = document.getElementById('mp-countdown');
if (cd) { clearInterval(cd._mpTick); cd.remove(); }