@massimo-cassandro/minimo 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -369,27 +369,38 @@ class SimpleDatatableAdapter extends HTMLElement {
|
|
|
369
369
|
: (getNestedValue(row, col_item._sortValue) ?? '')
|
|
370
370
|
: null;
|
|
371
371
|
|
|
372
|
+
|
|
373
|
+
// _renderTpl: template per il rendering del valore
|
|
374
|
+
// se stringa contiene le chiavi da renderizzare in formato mustache-like ([[key]])
|
|
375
|
+
// se funzione ha come argomento la riga dati
|
|
372
376
|
if (col_item._renderTpl) {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
(
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
//
|
|
387
|
-
|
|
377
|
+
if(typeof col_item._renderTpl === 'string') {
|
|
378
|
+
|
|
379
|
+
value = decodeURIComponent(col_item._renderTpl).replace(
|
|
380
|
+
/\[\[(.*?)\]\]/g,
|
|
381
|
+
(match, key) => {
|
|
382
|
+
const resolved = getNestedValue(row, key);
|
|
383
|
+
const pathParts = key.split('.');
|
|
384
|
+
const parentObj = pathParts.length > 1
|
|
385
|
+
? getNestedValue(row, pathParts.slice(0, -1).join('.'))
|
|
386
|
+
: row;
|
|
387
|
+
|
|
388
|
+
// Segnala solo se il padre esiste ma la chiave foglia manca
|
|
389
|
+
// (errore di configurazione). Se il padre è null il dato è
|
|
390
|
+
// semplicemente assente (es. Symfony restituisce owner: null).
|
|
391
|
+
if (parentObj != null && !Object.prototype.hasOwnProperty.call(parentObj, pathParts.at(-1))) {
|
|
392
|
+
// eslint-disable-next-line no-console
|
|
393
|
+
console.error(`[s-datatable] Chiave "${key}" non trovata nella struttura dati (colonna ${col_idx})`);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return resolved ?? nullAs;
|
|
388
397
|
}
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
} else if (typeof col_item._renderTpl === 'function') {
|
|
401
|
+
value = col_item._renderTpl(row);
|
|
402
|
+
}
|
|
389
403
|
|
|
390
|
-
return resolved ?? nullAs;
|
|
391
|
-
}
|
|
392
|
-
);
|
|
393
404
|
} else if (col_item._renderMode === 'sf_datetime' && value != null) {
|
|
394
405
|
value = value.date.replace(' ', 'T') +
|
|
395
406
|
(value.timezone === 'UTC' ? 'Z' : '');
|