edit templtae lingue e colori

This commit is contained in:
2026-05-04 11:21:30 +02:00
parent 3a7dd266c8
commit ce00247d1c
17 changed files with 1805 additions and 154 deletions
+23 -3
View File
@@ -57,7 +57,20 @@
// ── Client data (AJAX Select2, no bulk loading) ──────────────────────
function formatClientLabel(client) {
return (client.Nominativo || "").trim();
const nome = client.Nominativo || client.text || "Nome non disponibile";
const id = client.IdCliente || client.id || "";
const codiceCliente = (
client.CodiceCliente ??
client.codiceCliente ??
""
)
.toString()
.trim();
const suffix = (codiceCliente.split("_")[1] || "").trim();
const shortCode =
suffix || (codiceCliente ? codiceCliente.charAt(0) : "--");
return `${nome.trim()} - ${shortCode} (ID: ${id})`;
}
// Cache of resolved client names: id → name
@@ -102,7 +115,9 @@
);
const json = await resp.json();
const item = (json.results || [])[0];
if (item) clientNameCache[id] = item.text;
if (item) {
clientNameCache[id] = formatClientLabel(item);
}
} catch (e) {
/* ignore */
}
@@ -125,7 +140,12 @@
return { q: params.term || "", limit: 20 };
},
processResults: function (data) {
return { results: data.results || [] };
const results = (data.results || []).map((item) => ({
...item,
text: formatClientLabel(item),
}));
return { results: results };
},
cache: true,
},