@topconsultnpm/sdkui-react 6.22.0-dev2.25 → 6.22.0-dev2.27
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.
|
@@ -122,7 +122,12 @@ const TMMultiMasterDetailDcmtsForm = (props) => {
|
|
|
122
122
|
// Un nuovo riferimento a ogni render farebbe rifare a DevExtreme il setup di selezione/editing
|
|
123
123
|
const gridSelection = useMemo(() => ({ mode: 'single', showCheckBoxesMode: 'none' }), []);
|
|
124
124
|
const gridEditing = useMemo(() => ({
|
|
125
|
-
mode: 'cell',
|
|
125
|
+
mode: 'cell',
|
|
126
|
+
allowUpdating: true,
|
|
127
|
+
allowAdding: false,
|
|
128
|
+
allowDeleting: false,
|
|
129
|
+
startEditAction: 'click',
|
|
130
|
+
selectTextOnEditStart: false,
|
|
126
131
|
}), []);
|
|
127
132
|
const handleSelectionChanged = useCallback((e) => {
|
|
128
133
|
setSelectedRowKeys(e.selectedRowKeys ?? []);
|
|
@@ -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) => {
|