edit templtae lingue e colori
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user