Debug: log docBody children count y fix listener para checkbox/radio en _c8j2g16

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-10 12:02:16 -05:00
co-authored by Claude Sonnet 4.6
parent d12b605afd
commit f22553391c
+14 -5
View File
@@ -1319,9 +1319,13 @@ function _mpApplyExamVisibility(selectedExam) {
// 3. Recorrer hijos directos de doc-body en orden
// (no querySelectorAll — así capturamos section-title y otros sin data-campo-id)
var docBody = document.querySelector('.doc-body');
if (!docBody) return;
if (!docBody) { console.warn('[tomas] .doc-body no encontrado'); return; }
var children = Array.from(docBody.children);
console.log('[tomas] docBody.children.length:', children.length,
'| seps en children:', children.filter(function(c){return c.classList.contains('esquema-sep');}).length);
var inHidden = false;
Array.from(docBody.children).forEach(function(child) {
var hiddenCount = 0;
children.forEach(function(child) {
if (child.classList.contains('esquema-sep')) {
var cid = child.getAttribute('data-campo-id') || '';
if (allTomaSeps[cid] !== undefined) {
@@ -1330,19 +1334,24 @@ function _mpApplyExamVisibility(selectedExam) {
inHidden = false; // separador genérico — siempre visible
}
child.style.display = inHidden ? 'none' : '';
if (inHidden) hiddenCount++;
} else {
// campo, section-title, firma-pro-widget, etc.
child.style.display = inHidden ? 'none' : '';
if (inHidden) hiddenCount++;
}
});
console.log('[tomas] elementos ocultados:', hiddenCount);
}
// Escuchar selección de tipo de examen
// Escuchar selección de tipo de examen
document.addEventListener('change', function(e) {
if (!_mpModoTurnero) return;
var el = e.target;
if (el.type !== 'radio' || el.name !== '_c8j2g16') return;
var examName = el.value;
if (el.name !== '_c8j2g16') return;
console.log('[tomas] change _c8j2g16 type:', el.type, 'value:', el.value, 'checked:', el.checked);
var examName = (el.type === 'checkbox' && !el.checked) ? null : el.value;
_mpApplyExamVisibility(examName);
if (_mpTomasConfig !== null) return; // ya configurado, no mostrar panel
var groups = _mpGetGroupsForExam(examName);