feat(nexxa): textos de los eventos como fuente única en el servidor (/usos y /resumen), nexxa-web solo pone los íconos (P337/F3)
Tests ADN / test (push) Canceled after 0s
Tests ADN / test (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: GEMMA <noreply@gemma.dtic>
This commit is contained in:
co-authored by
Claude Opus 5.5
GEMMA
parent
9af0de60d1
commit
e193a496c1
@@ -19,6 +19,13 @@ module Nexxa
|
|||||||
# Registro COMPLETO de lo que pasa con cada key (P337/Fase 1). Códigos estables (hay filas guardadas con ellos);
|
# Registro COMPLETO de lo que pasa con cada key (P337/Fase 1). Códigos estables (hay filas guardadas con ellos);
|
||||||
# nexxa-web los traduce a palabras:
|
# nexxa-web los traduce a palabras:
|
||||||
EVENTOS = %w[dispensada liberada renovada pausada agotada revertida liberada-admin alta editada renombrada baja].freeze
|
EVENTOS = %w[dispensada liberada renovada pausada agotada revertida liberada-admin alta editada renombrada baja].freeze
|
||||||
|
# Qué significa cada evento en palabras: fuente ÚNICA para nexxa-web y GEMMA (viaja en /usos y /resumen)
|
||||||
|
TEXTOS = {
|
||||||
|
'dispensada' => 'entregada', 'liberada' => 'devuelta', 'renovada' => 'reserva renovada',
|
||||||
|
'pausada' => 'en pausa por límite del proveedor', 'agotada' => 'agotada (cuota)', 'revertida' => 'reporte deshecho',
|
||||||
|
'liberada-admin' => 'liberada por admin', 'alta' => 'dada de alta', 'editada' => 'editada',
|
||||||
|
'renombrada' => 'renombrada', 'baja' => 'dada de baja'
|
||||||
|
}.freeze
|
||||||
|
|
||||||
# motivo: lo que contestó el proveedor (pausada/agotada), qué cambió (editada) o el nombre anterior (renombrada).
|
# motivo: lo que contestó el proveedor (pausada/agotada), qué cambió (editada) o el nombre anterior (renombrada).
|
||||||
# hasta: hasta cuándo queda así (fin de la reserva o del bloqueo). Nunca valores de keys.
|
# hasta: hasta cuándo queda así (fin de la reserva o del bloqueo). Nunca valores de keys.
|
||||||
@@ -39,6 +46,7 @@ module Nexxa
|
|||||||
def self.historial(provider: nil, identificador: nil, individuo: nil, evento: nil, horas: nil, limit: 100)
|
def self.historial(provider: nil, identificador: nil, individuo: nil, evento: nil, horas: nil, limit: 100)
|
||||||
Estado.usos_historial(provider: provider, identificador: identificador, individuo: individuo, evento: evento,
|
Estado.usos_historial(provider: provider, identificador: identificador, individuo: individuo, evento: evento,
|
||||||
desde: horas && (Time.now - (horas.to_f * 3600)), limit: limit)
|
desde: horas && (Time.now - (horas.to_f * 3600)), limit: limit)
|
||||||
|
.map { |u| u.merge('texto' => TEXTOS.fetch(u['evento'], u['evento'])) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Lo que muestra el Dashboard (P337/Fase 1): cuántas keys en cada estado AHORA (todos los estados, también los
|
# Lo que muestra el Dashboard (P337/Fase 1): cuántas keys en cada estado AHORA (todos los estados, también los
|
||||||
@@ -54,6 +62,7 @@ module Nexxa
|
|||||||
end
|
end
|
||||||
{
|
{
|
||||||
'horas' => horas,
|
'horas' => horas,
|
||||||
|
'textos' => TEXTOS,
|
||||||
'ahora' => Nexxa::Registro::ESTADOS.to_h { |e| [e, keys.count { |k| k['estado'] == e }] },
|
'ahora' => Nexxa::Registro::ESTADOS.to_h { |e| [e, keys.count { |k| k['estado'] == e }] },
|
||||||
'eventos' => contar.call(eventos),
|
'eventos' => contar.call(eventos),
|
||||||
'por_key' => por_key.sort_by { |k| [k['provider'].to_s, k['identificador'].to_s] }
|
'por_key' => por_key.sort_by { |k| [k['provider'].to_s, k['identificador'].to_s] }
|
||||||
|
|||||||
@@ -195,24 +195,16 @@
|
|||||||
(d ? '<div class="timing-sub">' + d + '</div>' : '');
|
(d ? '<div class="timing-sub">' + d + '</div>' : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eventos del registro en palabras (P337/Fase 2): UNA tabla. Los códigos son los que guarda el servidor.
|
// Eventos del registro (P337/Fase 3): el TEXTO lo manda el servidor (Usos::TEXTOS, fuente única con GEMMA, llega en
|
||||||
var EVENTO_UI = {
|
// /resumen); acá solo el ícono, que es presentación.
|
||||||
dispensada: ['🟢', 'entregada'],
|
var EVENTO_ICONO = {
|
||||||
liberada: ['⚪', 'devuelta'],
|
dispensada: '🟢', liberada: '⚪', renovada: '🔄', pausada: '🟡', agotada: '🔴', revertida: '↩️',
|
||||||
renovada: ['🔄', 'reserva renovada'],
|
'liberada-admin': '🛠', alta: '➕', editada: '✏️', renombrada: '🏷', baja: '🗑'
|
||||||
pausada: ['🟡', 'en pausa por límite del proveedor'],
|
|
||||||
agotada: ['🔴', 'agotada (cuota)'],
|
|
||||||
revertida: ['↩️', 'reporte deshecho'],
|
|
||||||
'liberada-admin': ['🛠', 'liberada por admin'],
|
|
||||||
alta: ['➕', 'dada de alta'],
|
|
||||||
editada: ['✏️', 'editada'],
|
|
||||||
renombrada: ['🏷', 'renombrada'],
|
|
||||||
baja: ['🗑', 'dada de baja']
|
|
||||||
};
|
};
|
||||||
|
var TEXTOS_EVENTO = {};
|
||||||
|
|
||||||
function eventoTexto(e) {
|
function eventoTexto(e) {
|
||||||
var u = EVENTO_UI[e] || ['•', e];
|
return (EVENTO_ICONO[e] || '•') + ' ' + (TEXTOS_EVENTO[e] || e);
|
||||||
return u[0] + ' ' + u[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function actionsHtml(k, keyId, activo, bloqueada) {
|
function actionsHtml(k, keyId, activo, bloqueada) {
|
||||||
@@ -1018,6 +1010,7 @@
|
|||||||
// Dashboard desde /resumen (P337/Fase 2): estados AHORA (todos, también en 0) y lo que pasó en 24 h
|
// Dashboard desde /resumen (P337/Fase 2): estados AHORA (todos, también en 0) y lo que pasó en 24 h
|
||||||
function cargarResumen() {
|
function cargarResumen() {
|
||||||
return pedirJson('/resumen?horas=24').then(function (r) {
|
return pedirJson('/resumen?horas=24').then(function (r) {
|
||||||
|
TEXTOS_EVENTO = r.textos || TEXTOS_EVENTO;
|
||||||
document.getElementById('stats-ahora').innerHTML = ESTADOS_ORDEN.map(function (e) {
|
document.getElementById('stats-ahora').innerHTML = ESTADOS_ORDEN.map(function (e) {
|
||||||
var u = ESTADO_UI[e];
|
var u = ESTADO_UI[e];
|
||||||
return statHtml('<span class="pill ' + u.clase + '"><span class="dot"></span>' + u.texto + '</span>', r.ahora[e] || 0);
|
return statHtml('<span class="pill ' + u.clase + '"><span class="dot"></span>' + u.texto + '</span>', r.ahora[e] || 0);
|
||||||
@@ -1079,8 +1072,8 @@
|
|||||||
// Sección Registro (P337/Fase 2): filtros que el SERVIDOR aplica (/usos); las opciones salen de los datos reales
|
// Sección Registro (P337/Fase 2): filtros que el SERVIDOR aplica (/usos); las opciones salen de los datos reales
|
||||||
function opcionesRegistro() {
|
function opcionesRegistro() {
|
||||||
var ev = document.getElementById('reg-evento');
|
var ev = document.getElementById('reg-evento');
|
||||||
if (ev.options.length === 1) {
|
if (ev.options.length === 1 && Object.keys(TEXTOS_EVENTO).length) {
|
||||||
Object.keys(EVENTO_UI).forEach(function (e) { ev.add(new Option(eventoTexto(e), e)); });
|
Object.keys(TEXTOS_EVENTO).forEach(function (e) { ev.add(new Option(eventoTexto(e), e)); });
|
||||||
}
|
}
|
||||||
var sel = document.getElementById('reg-key');
|
var sel = document.getElementById('reg-key');
|
||||||
var actual = sel.value;
|
var actual = sel.value;
|
||||||
@@ -1089,7 +1082,11 @@
|
|||||||
sel.value = actual;
|
sel.value = actual;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cargarRegistro() {
|
// reintento: los textos llegan con /resumen; si todavía no están se piden UNA vez (sin bucle si /resumen falla)
|
||||||
|
function cargarRegistro(reintento) {
|
||||||
|
if (!Object.keys(TEXTOS_EVENTO).length && reintento !== true) {
|
||||||
|
return cargarResumen().then(function () { return cargarRegistro(true); });
|
||||||
|
}
|
||||||
opcionesRegistro();
|
opcionesRegistro();
|
||||||
var q = ['horas=' + encodeURIComponent(document.getElementById('reg-horas').value), 'limit=500'];
|
var q = ['horas=' + encodeURIComponent(document.getElementById('reg-horas').value), 'limit=500'];
|
||||||
var ev = document.getElementById('reg-evento').value;
|
var ev = document.getElementById('reg-evento').value;
|
||||||
@@ -1110,7 +1107,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
['reg-horas', 'reg-evento', 'reg-key'].forEach(function (id) {
|
['reg-horas', 'reg-evento', 'reg-key'].forEach(function (id) {
|
||||||
document.getElementById(id).addEventListener('change', cargarRegistro);
|
document.getElementById(id).addEventListener('change', function () { cargarRegistro(); });
|
||||||
});
|
});
|
||||||
document.getElementById('reg-individuo').addEventListener('keydown', function (e) { if (e.key === 'Enter') cargarRegistro(); });
|
document.getElementById('reg-individuo').addEventListener('keydown', function (e) { if (e.key === 'Enter') cargarRegistro(); });
|
||||||
document.querySelector('[data-ir-registro]').addEventListener('click', function (e) { e.preventDefault(); selectSection('registro'); });
|
document.querySelector('[data-ir-registro]').addEventListener('click', function (e) { e.preventDefault(); selectSection('registro'); });
|
||||||
|
|||||||
Reference in New Issue
Block a user