@topconsultnpm/sdkui-react 6.20.0-dev2.67 → 6.20.0-dev2.68
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.
|
@@ -146,7 +146,18 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
146
146
|
setSelectedSearchResult(searchResults[0]);
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
//
|
|
149
|
+
// Se il TID precedentemente selezionato esiste ancora nei nuovi risultati, mantienilo.
|
|
150
|
+
// Questo evita l'errore E1047 in modalità multi-TID: cambiando TID cambiano le colonne
|
|
151
|
+
// e il filtro applicato potrebbe riferire campi non più presenti.
|
|
152
|
+
const prevTID = selectedSearchResult?.fromTID;
|
|
153
|
+
if (prevTID !== undefined) {
|
|
154
|
+
const found = searchResults.find(r => r.fromTID === prevTID);
|
|
155
|
+
if (found) {
|
|
156
|
+
setSelectedSearchResult(found);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Altrimenti seleziona il primo risultato ordinato
|
|
150
161
|
setSelectedSearchResult(orderByName(searchResults)[0]);
|
|
151
162
|
}, [searchResults]);
|
|
152
163
|
useEffect(() => {
|
|
@@ -887,6 +898,7 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, allUsers, inputFocusedItem,
|
|
|
887
898
|
const [visibleItems, setVisibleItems] = useState([]);
|
|
888
899
|
const [pageSize, setPageSize] = useState(SDKUI_Globals.userSettings.searchSettings?.pageSize ?? TMDataGridPageSize.Large);
|
|
889
900
|
const [isDataGridReady, setIsDataGridReady] = useState(false);
|
|
901
|
+
const dataGridRef = useRef(null);
|
|
890
902
|
const { loadDataListsAsync, renderDataListCell, dataListsCache } = useDataListItem();
|
|
891
903
|
const { loadUsersAsync, renderUserIdViewer, usersCache } = useDataUserIdItem();
|
|
892
904
|
useEffect(() => {
|
|
@@ -1157,6 +1169,19 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, allUsers, inputFocusedItem,
|
|
|
1157
1169
|
]);
|
|
1158
1170
|
// Genera colonne con cache popolate per garantire headerFilter completi
|
|
1159
1171
|
const cols = generateColumns();
|
|
1172
|
+
// Cancella i filtri SOLO se le colonne sono cambiate (es. cambio TID).
|
|
1173
|
+
// Se le colonne restano le stesse (es. refresh sullo stesso TID), il filtro resta valido.
|
|
1174
|
+
// Previene l'errore E1047 quando il filtro riferisce campi non più presenti nelle nuove colonne.
|
|
1175
|
+
const oldFields = columns.map(c => c.dataField);
|
|
1176
|
+
const newFields = cols.map(c => c.dataField);
|
|
1177
|
+
const columnsChanged = oldFields.length !== newFields.length ||
|
|
1178
|
+
oldFields.some((f, i) => f !== newFields[i]);
|
|
1179
|
+
if (columnsChanged) {
|
|
1180
|
+
const gridInstance = dataGridRef.current?.instance();
|
|
1181
|
+
if (gridInstance) {
|
|
1182
|
+
gridInstance.clearFilter();
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1160
1185
|
setColumns(cols);
|
|
1161
1186
|
// Converte i risultati di ricerca in un array semplice per la griglia
|
|
1162
1187
|
let newDataSource = searchResultDescriptorToSimpleArray(searchResult);
|
|
@@ -1236,7 +1261,7 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, allUsers, inputFocusedItem,
|
|
|
1236
1261
|
setVisibleItems(visibleRows.map((row) => { return row.data; }));
|
|
1237
1262
|
}, []);
|
|
1238
1263
|
useEffect(() => { onVisibleItemChanged?.(visibleItems); }, [visibleItems]);
|
|
1239
|
-
return _jsxs("div", { style: { width: "100%", height: "100%" }, children: [!isDataGridReady && (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100%', width: '100%', gap: '10px' }, children: [_jsx(LoadIndicator, { height: 60, width: 60 }), _jsx("div", { children: SDKUI_Localizator.Loading })] })), isDataGridReady && _jsx(TMDataGrid, { id: "tm-search-result", keyExpr: "rowIndex", dataColumns: dataColumns, dataSource: dataSource, repaintChangesOnly: true, selectedRowKeys: selectedRowKeys, focusedRowKey: Number(focusedItem?.rowIndex ?? 0), showSearchPanel: showSearch, showFilterPanel: true, sorting: { mode: "multiple" }, selection: { mode: allowMultipleSelection ? 'multiple' : 'single' }, pageSize: pageSize, onSelectionChanged: handleSelectionChange, onFocusedRowChanged: handleFocusedRowChange, onRowDblClick: onRowDblClick, onContentReady: onContentReady, showHeaderColumnChooser: true, onKeyDown: onKeyDown, customContextMenuItems: floatingMenuItems, counterConfig: { show: true } }), (showExportForm && searchResult && onCloseExportForm) && _jsx(TMDataGridExportForm, { dataColumns: dataColumns, dataSource: dataSource, selectedRowKeys: selectedRowKeys, onCloseExportForm: onCloseExportForm, searchResult: searchResult })] });
|
|
1264
|
+
return _jsxs("div", { style: { width: "100%", height: "100%" }, children: [!isDataGridReady && (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100%', width: '100%', gap: '10px' }, children: [_jsx(LoadIndicator, { height: 60, width: 60 }), _jsx("div", { children: SDKUI_Localizator.Loading })] })), isDataGridReady && _jsx(TMDataGrid, { ref: dataGridRef, id: "tm-search-result", keyExpr: "rowIndex", dataColumns: dataColumns, dataSource: dataSource, repaintChangesOnly: true, selectedRowKeys: selectedRowKeys, focusedRowKey: Number(focusedItem?.rowIndex ?? 0), showSearchPanel: showSearch, showFilterPanel: true, sorting: { mode: "multiple" }, selection: { mode: allowMultipleSelection ? 'multiple' : 'single' }, pageSize: pageSize, onSelectionChanged: handleSelectionChange, onFocusedRowChanged: handleFocusedRowChange, onRowDblClick: onRowDblClick, onContentReady: onContentReady, showHeaderColumnChooser: true, onKeyDown: onKeyDown, customContextMenuItems: floatingMenuItems, counterConfig: { show: true } }), (showExportForm && searchResult && onCloseExportForm) && _jsx(TMDataGridExportForm, { dataColumns: dataColumns, dataSource: dataSource, selectedRowKeys: selectedRowKeys, onCloseExportForm: onCloseExportForm, searchResult: searchResult })] });
|
|
1240
1265
|
};
|
|
1241
1266
|
//#region TMSearchResultSelector
|
|
1242
1267
|
const StyledItemTemplate = styled.div `
|
|
@@ -1268,13 +1293,21 @@ const TMSearchResultSelector = ({ searchResults = [], disableAccordionIfSingleCa
|
|
|
1268
1293
|
sortedCategories.forEach((category) => {
|
|
1269
1294
|
groupedResults[category].sort((a, b) => (a.fromName ?? '').localeCompare(b.fromName ?? ''));
|
|
1270
1295
|
});
|
|
1271
|
-
//
|
|
1272
|
-
//
|
|
1296
|
+
// Sincronizza la selezione interna con quella del parent.
|
|
1297
|
+
// Quando selectedSearchResult è undefined (es. mobile back) resetta.
|
|
1298
|
+
// Quando selectedSearchResult cambia (es. refresh dopo WF operation), cerca il corrispondente
|
|
1299
|
+
// nel nuovo searchResults per aggiornare il reference e mantenere lo stile di selezione.
|
|
1273
1300
|
useEffect(() => {
|
|
1274
1301
|
if (selectedSearchResult === undefined) {
|
|
1275
1302
|
setSelectedResult(undefined);
|
|
1276
1303
|
}
|
|
1277
|
-
|
|
1304
|
+
else {
|
|
1305
|
+
const found = searchResults.find(r => r.fromTID === selectedSearchResult.fromTID);
|
|
1306
|
+
if (found) {
|
|
1307
|
+
setSelectedResult(found);
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}, [selectedSearchResult, searchResults]);
|
|
1278
1311
|
// Auto-seleziona il primo risultato di ricerca solo se autoSelectFirst è true.
|
|
1279
1312
|
// Su mobile con più risultati, autoSelectFirst è false per permettere all'utente
|
|
1280
1313
|
// di vedere prima la lista dei tipi documento e scegliere manualmente.
|