feat: user personalization, role-exact UI hierarchy and spotlight auto-expand (v3.8.29)

This commit is contained in:
2026-10-27 09:13:15 -03:00
parent 7668c3d92f
commit 96d8618157
15 changed files with 381 additions and 157 deletions
+48 -20
View File
@@ -189,39 +189,67 @@
el.addEventListener('click', handleUserAction, { once: true });
}
function revealElementIfHidden(el) {
if (!el) return;
// Desplegar menú Bootstrap si está en un collapse
const collapseParent = el.closest('.collapse');
if (collapseParent && !collapseParent.classList.contains('show')) {
collapseParent.classList.add('show');
const trigger = document.querySelector(`[href="#${collapseParent.id}"], [data-bs-target="#${collapseParent.id}"]`);
if (trigger) trigger.setAttribute('aria-expanded', 'true');
}
// Expandir sidebar si está colapsado
const sidebar = document.getElementById('sidebar');
if (sidebar && sidebar.classList.contains('collapsed')) {
sidebar.classList.remove('collapsed');
}
// En móvil, abrir sidebar si el elemento está en el sidebar
if (window.innerWidth < 992 && el.closest('#sidebar')) {
if (sidebar) sidebar.classList.add('show');
const backdrop = document.getElementById('sidebarBackdrop');
if (backdrop) backdrop.classList.add('show');
}
}
function startStep(step) {
if (!step || !step.selector) return;
currentStepData = step;
// 1. Primero intentar encontrar el elemento en la página actual (ej. sidebar o vista activa)
let targetEl = document.querySelector(step.selector);
if (targetEl) {
revealElementIfHidden(targetEl);
setTimeout(() => {
highlightElement(targetEl, step);
}, 150);
return;
}
const currentPath = window.location.pathname;
const targetPath = step.target_url;
// Si el usuario está en otra pantalla, sugerir redirección
// 2. Si no está en la página actual y estamos en otra ruta, ofrecer redirección
if (targetPath && !currentPath.includes(targetPath) && !targetPath.includes(currentPath)) {
showRedirectBanner(targetPath, step.message);
return;
}
// Si ya estamos en la pantalla, buscar selector
let targetEl = document.querySelector(step.selector);
// Si no lo encuentra de inmediato (por modales o carga diferida), reintentar brevemente
if (!targetEl) {
let attempts = 0;
const timer = setInterval(() => {
attempts++;
targetEl = document.querySelector(step.selector);
if (targetEl) {
clearInterval(timer);
// 3. Reintentos si se está cargando la página o un modal dinámico
let attempts = 0;
const timer = setInterval(() => {
attempts++;
targetEl = document.querySelector(step.selector);
if (targetEl) {
clearInterval(timer);
revealElementIfHidden(targetEl);
setTimeout(() => {
highlightElement(targetEl, step);
} else if (attempts >= 8) {
clearInterval(timer);
console.warn(`[WalkthroughEngine] Elemento no encontrado: ${step.selector}`);
}
}, 250);
} else {
highlightElement(targetEl, step);
}
}, 100);
} else if (attempts >= 8) {
clearInterval(timer);
console.warn(`[WalkthroughEngine] Elemento no encontrado: ${step.selector}`);
}
}, 250);
}
function checkPendingStep() {