@topconsultnpm/sdkui-react 6.22.0-dev2.24 → 6.22.0-dev2.26
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.
|
@@ -119,6 +119,14 @@ const TMMasterInfoFields = ({ dtd, dcmt, getValuesByMidAsync, reloadToken, isExp
|
|
|
119
119
|
loadAsync();
|
|
120
120
|
return () => { cancelled = true; };
|
|
121
121
|
}, [dtd?.id, dcmt?.TID, dcmt?.DID, reloadToken]);
|
|
122
|
+
// La barra di ricerca esiste solo nella vista ingrandita: tornando in linea il filtro non è più
|
|
123
|
+
// visibile e resterebbe attivo, nascondendo i primi metadati dell'anteprima
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (isExpandedView)
|
|
126
|
+
return;
|
|
127
|
+
setFilter('');
|
|
128
|
+
setShowAll(false);
|
|
129
|
+
}, [isExpandedView]);
|
|
122
130
|
// Testo su cui cerca il filtro: valore visualizzato del metadato (per le liste dati il nome dell'item)
|
|
123
131
|
const getSearchText = (item) => {
|
|
124
132
|
if (item.value === undefined || item.value === null || item.value === '')
|
|
@@ -61,6 +61,9 @@ export const useMultiMasterDetailDcmts = ({ dtd, masterDcmt, onClose }) => {
|
|
|
61
61
|
const [masterInfoReloadToken, setMasterInfoReloadToken] = useState(0);
|
|
62
62
|
// Righe del riepilogo
|
|
63
63
|
const [archiveRows, setArchiveRows] = useState([]);
|
|
64
|
+
// La modifica in cella aggiorna la riga fuori dallo stato (vedi updateRowValues)
|
|
65
|
+
const archiveRowsRef = useRef(archiveRows);
|
|
66
|
+
archiveRowsRef.current = archiveRows;
|
|
64
67
|
const rowIdRef = useRef(0);
|
|
65
68
|
const [focusedRowKey, setFocusedRowKey] = useState(undefined);
|
|
66
69
|
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
@@ -354,36 +357,35 @@ export const useMultiMasterDetailDcmts = ({ dtd, masterDcmt, onClose }) => {
|
|
|
354
357
|
};
|
|
355
358
|
/**
|
|
356
359
|
* Modifica diretta in griglia di uno o più metadati testuali o numerici (changes: mid -> valore).
|
|
357
|
-
* La riga
|
|
358
|
-
*
|
|
360
|
+
* La riga è aggiornata sul posto e non con setArchiveRows: un nuovo riferimento all'array
|
|
361
|
+
* ricaricherebbe la griglia a ogni cella confermata, perdendo il clic sulla cella successiva.
|
|
362
|
+
* L'array __values è sostituito, non modificato: il duplicato, che lo condivide, resta invariato
|
|
359
363
|
*/
|
|
360
364
|
const updateRowValues = useCallback((rowId, changes) => {
|
|
361
365
|
const changedMids = Object.keys(changes);
|
|
362
366
|
if (changedMids.length === 0)
|
|
363
367
|
return;
|
|
368
|
+
const row = archiveRowsRef.current.find(r => r.id === rowId);
|
|
369
|
+
if (!row)
|
|
370
|
+
return;
|
|
364
371
|
// I __values vanno a sistema come stringhe, anche quelli che in griglia sono numeri. La griglia
|
|
365
372
|
// restituisce null sull'editor svuotato: a sistema il metadato va vuoto, non nullo
|
|
366
373
|
const normalized = {};
|
|
367
374
|
changedMids.forEach(mid => { normalized[mid] = changes[mid] === null || changes[mid] === undefined ? '' : String(changes[mid]); });
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
const updated = { ...r, __values: values };
|
|
383
|
-
// In cella il numero resta un numero, come lo vuole il suo editor
|
|
384
|
-
changedMids.forEach(mid => { updated[mid] = numericMidsRef.current.has(Number(mid)) ? toGridNumber(normalized[mid]) : normalized[mid]; });
|
|
385
|
-
return updated;
|
|
386
|
-
}));
|
|
375
|
+
const values = row.__values.map(v => (v.mid !== undefined && normalized[String(v.mid)] !== undefined
|
|
376
|
+
? { ...v, value: normalized[String(v.mid)] }
|
|
377
|
+
: v));
|
|
378
|
+
// Un metadato assente dai valori del form non arriverebbe all'archiviazione
|
|
379
|
+
changedMids.filter(mid => !values.some(v => String(v.mid) === mid)).forEach(mid => {
|
|
380
|
+
const added = new MetadataValueDescriptorEx();
|
|
381
|
+
added.tid = row.__tid;
|
|
382
|
+
added.mid = Number(mid);
|
|
383
|
+
added.value = normalized[mid];
|
|
384
|
+
values.push(added);
|
|
385
|
+
});
|
|
386
|
+
row.__values = values;
|
|
387
|
+
// In cella il numero resta un numero, come lo vuole il suo editor
|
|
388
|
+
changedMids.forEach(mid => { row[mid] = numericMidsRef.current.has(Number(mid)) ? toGridNumber(normalized[mid]) : normalized[mid]; });
|
|
387
389
|
}, []);
|
|
388
390
|
// I __values sono condivisi per riferimento: la modifica sostituisce l'intero array, quindi non intacca il duplicato
|
|
389
391
|
const duplicateRow = useCallback((row) => {
|