fix(cobranza): recuerda la sección activa al refrescar la página
setView ahora persiste la vista en localStorage y marca la pestaña activa por data-view (sin depender del botón clickeado). Al cargar, restaurarVista() reabre la última sección (tarjetas/tabla/directorio/mensaje) en vez de caer siempre en "tarjetas". Solo frontend. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
0d33390570
commit
c991ed7779
1 file changed
+21
-6
+21
-6
@@ -347,10 +347,10 @@
|
||||
</div>
|
||||
|
||||
<div class="tabs">
|
||||
<button class="tab active" onclick="setView('tarjetas', this)">Tarjetas</button>
|
||||
<button class="tab" onclick="setView('tabla', this)">Tabla</button>
|
||||
<button class="tab" onclick="setView('directorio', this)">Directorio</button>
|
||||
<button class="tab" onclick="setView('mensaje', this)">Mensaje</button>
|
||||
<button class="tab active" data-view="tarjetas" onclick="setView('tarjetas')">Tarjetas</button>
|
||||
<button class="tab" data-view="tabla" onclick="setView('tabla')">Tabla</button>
|
||||
<button class="tab" data-view="directorio" onclick="setView('directorio')">Directorio</button>
|
||||
<button class="tab" data-view="mensaje" onclick="setView('mensaje')">Mensaje</button>
|
||||
</div>
|
||||
|
||||
<div class="dup-banner" id="dup-banner">
|
||||
@@ -1548,15 +1548,28 @@ function cerrar(){
|
||||
document.getElementById("modal").classList.remove("open");
|
||||
document.getElementById("modal-inner").classList.remove("lote");
|
||||
}
|
||||
function setView(v, btn){
|
||||
const VISTAS_VALIDAS = ["tarjetas", "tabla", "directorio", "mensaje"];
|
||||
const VIEW_KEY = "cobranza_view";
|
||||
|
||||
function setView(v){
|
||||
if(!VISTAS_VALIDAS.includes(v)) v = "tarjetas";
|
||||
document.querySelectorAll(".view").forEach(e => e.classList.remove("active"));
|
||||
document.getElementById("view-"+v).classList.add("active");
|
||||
document.querySelectorAll(".tab").forEach(t => t.classList.remove("active"));
|
||||
if(btn) btn.classList.add("active");
|
||||
const tab = document.querySelector('.tab[data-view="'+v+'"]');
|
||||
if(tab) tab.classList.add("active");
|
||||
try { localStorage.setItem(VIEW_KEY, v); } catch(e){}
|
||||
if(v === "directorio") cargarDirectorio();
|
||||
if(v === "mensaje") cargarConfigGlobal();
|
||||
}
|
||||
|
||||
// Restaura la última sección visitada (persistida en localStorage).
|
||||
function restaurarVista(){
|
||||
let v = "tarjetas";
|
||||
try { v = localStorage.getItem(VIEW_KEY) || "tarjetas"; } catch(e){}
|
||||
setView(v);
|
||||
}
|
||||
|
||||
// ── Config GLOBAL: cuentas SPEI + plantilla ───────────────────
|
||||
async function cargarConfigGlobal(){
|
||||
try {
|
||||
@@ -1790,6 +1803,8 @@ document.getElementById("modal").addEventListener("click", e => { if(e.target.id
|
||||
// En paralelo: renglones (tarjetas/tabla), directorio (modal teléfono),
|
||||
// config global (cuentas SPEI + plantilla para vía SPEI del cobro).
|
||||
await Promise.all([cargarRenglones(), cargarDirectorio(), cargarConfigGlobal()]);
|
||||
// Restaura la sección activa que el usuario tenía antes de refrescar.
|
||||
restaurarVista();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in new issue
Block a user