@topconsultnpm/sdkui-react 6.20.0-dev2.66 → 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.
@@ -51,6 +51,7 @@ interface ITMSearchResultProps {
51
51
  showTodoDcmtForm?: boolean;
52
52
  showToppyDraggableHelpCenter?: boolean;
53
53
  toppyHelpCenterUsePortal?: boolean;
54
+ showNoDcmtFoundMessage?: boolean;
54
55
  onReferenceClick?: (ref: ObjectRef) => void;
55
56
  }
56
57
  declare const TMSearchResult: React.FC<ITMSearchResultProps>;
@@ -68,7 +68,7 @@ const orderByName = (array) => {
68
68
  return 1;
69
69
  } return 0; });
70
70
  };
71
- const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTaskCallback, editTaskCallback, handleNavigateToWGs, handleNavigateToDossiers, context = SearchResultContext.METADATA_SEARCH, isVisible = true, allowRelations = true, openDcmtFormAsModal = false, searchResults = [], showSearchResultSidebar = true, showDcmtFormSidebar = true, showSelector = false, groupId, title, isClosable = false, allowFloatingBar = true, showToolbarHeader = true, showBackButton = true, selectedSearchResultTID, workingGroupContext = undefined, disableAccordionIfSingleCategory = false, floatingActionConfig, openInOffice, onRefreshAfterAddDcmtToFavs, onRefreshSearchAsync, onSelectedTIDChanged, onWFOperationCompleted, onClose, onFileOpened, onTaskCreateRequest, openWGsCopyMoveForm, editPdfForm = false, openEditPdf, openCommentFormCallback, openAddDocumentForm, openS4TViewer = false, onOpenS4TViewerRequest, passToArchiveCallback, showTodoDcmtForm = false, showToppyDraggableHelpCenter = true, toppyHelpCenterUsePortal = false, onReferenceClick, }) => {
71
+ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTaskCallback, editTaskCallback, handleNavigateToWGs, handleNavigateToDossiers, context = SearchResultContext.METADATA_SEARCH, isVisible = true, allowRelations = true, openDcmtFormAsModal = false, searchResults = [], showSearchResultSidebar = true, showDcmtFormSidebar = true, showSelector = false, groupId, title, isClosable = false, allowFloatingBar = true, showToolbarHeader = true, showBackButton = true, selectedSearchResultTID, workingGroupContext = undefined, disableAccordionIfSingleCategory = false, floatingActionConfig, openInOffice, onRefreshAfterAddDcmtToFavs, onRefreshSearchAsync, onSelectedTIDChanged, onWFOperationCompleted, onClose, onFileOpened, onTaskCreateRequest, openWGsCopyMoveForm, editPdfForm = false, openEditPdf, openCommentFormCallback, openAddDocumentForm, openS4TViewer = false, onOpenS4TViewerRequest, passToArchiveCallback, showTodoDcmtForm = false, showToppyDraggableHelpCenter = true, toppyHelpCenterUsePortal = false, showNoDcmtFoundMessage = true, onReferenceClick, }) => {
72
72
  const [id, setID] = useState('');
73
73
  const [showApprovePopup, setShowApprovePopup] = useState(false);
74
74
  const [showRejectPopup, setShowRejectPopup] = useState(false);
@@ -146,7 +146,18 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
146
146
  setSelectedSearchResult(searchResults[0]);
147
147
  return;
148
148
  }
149
- // Seleziona sempre il primo risultato ordinato, sia su mobile che desktop
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(() => {
@@ -611,7 +622,7 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
611
622
  const searchResutlToolbar = _jsxs(_Fragment, { children: [(dcmtsReturned != dcmtsFound) && _jsx("p", { style: { textAlign: 'center', padding: '1px 4px', borderRadius: '3px', display: 'flex' }, children: `${dcmtsReturned}/${dcmtsFound} restituiti` }), context === SearchResultContext.FAVORITES_AND_RECENTS &&
612
623
  _jsx("div", { style: { display: 'flex', alignItems: 'center', gap: '5px' }, children: _jsx(TMButton, { btnStyle: 'icon', icon: _jsx(IconDelete, { color: 'white' }), caption: "Rimuovi da " + (selectedSearchResult?.category === "Favorites" ? '"Preferiti"' : '"Recenti"'), disabled: getSelectedDcmtsOrFocused(selectedItems, focusedItem).length <= 0, onClick: removeDcmtFromFavsOrRecents }) }), _jsx(TMButton, { btnStyle: 'icon', icon: _jsx(IconRefresh, { color: 'white' }), caption: SDKUI_Localizator.Refresh, onClick: onRefreshSearchAsync }), _jsx(TMContextMenu, { items: floatingMenuItems, trigger: "left", children: _jsx(IconMenuVertical, { color: 'white', cursor: 'pointer' }) })] });
613
624
  const tmSearchResult = useMemo(() => (!searchResults || searchResults.length <= 0)
614
- ? _jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100%', width: '100%' }, children: [_jsx(IconBoard, { fontSize: 96 }), openAddDocumentForm && _jsx("div", { style: { marginTop: "10px" }, children: _jsx(TMButton, { fontSize: "15px", icon: _jsx("i", { className: 'dx-icon-share' }), caption: SDKUI_Localizator.Share, onClick: openAddDocumentForm }) })] })
625
+ ? _jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100%', width: '100%' }, children: [_jsx(IconBoard, { fontSize: 96 }), showNoDcmtFoundMessage && _jsx("div", { style: { fontSize: "15px", marginTop: "10px" }, children: SDKUI_Localizator.NoDcmtFound }), openAddDocumentForm && _jsx("div", { style: { marginTop: "10px" }, children: _jsx(TMButton, { fontSize: "15px", icon: _jsx("i", { className: 'dx-icon-share' }), caption: SDKUI_Localizator.Share, onClick: openAddDocumentForm }) })] })
615
626
  :
616
627
  _jsxs(_Fragment, { children: [_jsxs(TMLayoutItem, { height: '100%', children: [_jsxs("div", { ref: floatingBarContainerRef, style: { position: 'relative', height: '100%', width: '100%' }, children: [_jsxs(TMSplitterLayout, { direction: 'horizontal', overflow: 'visible', separatorSize: Gutters.getGutters(), separatorActiveColor: 'transparent', separatorColor: 'transparent', min: ['0', '0'], showSeparator: showSelector && deviceType !== DeviceType.MOBILE, start: showSelector ? deviceType !== DeviceType.MOBILE ? ['30%', '70%'] : splitterSize : ['0%', '100%'], children: [showSelector ?
617
628
  _jsx(TMLayoutItem, { children: _jsx(TMSearchResultSelector, { searchResults: currentSearchResults, disableAccordionIfSingleCategory: disableAccordionIfSingleCategory, selectedTID: selectedSearchResultTID, selectedSearchResult: selectedSearchResult, autoSelectFirst: !isMobile || currentSearchResults.length === 1, onSelectionChanged: onSearchResultSelectionChanged }) })
@@ -730,7 +741,8 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
730
741
  onRefreshSearchAsync,
731
742
  handleNavigateToWGs,
732
743
  handleNavigateToDossiers,
733
- editPdfForm
744
+ editPdfForm,
745
+ showNoDcmtFoundMessage
734
746
  ]);
735
747
  const tmBlog = useMemo(() => _jsx(TMDcmtBlog, { tid: focusedItem?.TID, did: focusedItem?.DID, fetchBlogDataTrigger: refreshBlogTrigger, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), [focusedItem, allTasks, refreshBlogTrigger, handleNavigateToWGs, handleNavigateToDossiers]);
736
748
  const tmSysMetadata = useMemo(() => _jsx(TMMetadataValues, { layoutMode: LayoutModes.Update, openChooserBySingleClick: true, TID: focusedItem?.TID, isReadOnly: true, deviceType: deviceType, metadataValues: currentMetadataValues.filter(o => (o.mid != undefined && o.mid <= 100)), metadataValuesOrig: currentMetadataValues.filter(o => (o.mid != undefined && o.mid <= 100)), validationItems: [] }), [focusedItem, currentMetadataValues, deviceType]);
@@ -886,6 +898,7 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, allUsers, inputFocusedItem,
886
898
  const [visibleItems, setVisibleItems] = useState([]);
887
899
  const [pageSize, setPageSize] = useState(SDKUI_Globals.userSettings.searchSettings?.pageSize ?? TMDataGridPageSize.Large);
888
900
  const [isDataGridReady, setIsDataGridReady] = useState(false);
901
+ const dataGridRef = useRef(null);
889
902
  const { loadDataListsAsync, renderDataListCell, dataListsCache } = useDataListItem();
890
903
  const { loadUsersAsync, renderUserIdViewer, usersCache } = useDataUserIdItem();
891
904
  useEffect(() => {
@@ -1156,6 +1169,19 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, allUsers, inputFocusedItem,
1156
1169
  ]);
1157
1170
  // Genera colonne con cache popolate per garantire headerFilter completi
1158
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
+ }
1159
1185
  setColumns(cols);
1160
1186
  // Converte i risultati di ricerca in un array semplice per la griglia
1161
1187
  let newDataSource = searchResultDescriptorToSimpleArray(searchResult);
@@ -1235,7 +1261,7 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, allUsers, inputFocusedItem,
1235
1261
  setVisibleItems(visibleRows.map((row) => { return row.data; }));
1236
1262
  }, []);
1237
1263
  useEffect(() => { onVisibleItemChanged?.(visibleItems); }, [visibleItems]);
1238
- 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 })] });
1239
1265
  };
1240
1266
  //#region TMSearchResultSelector
1241
1267
  const StyledItemTemplate = styled.div `
@@ -1267,13 +1293,21 @@ const TMSearchResultSelector = ({ searchResults = [], disableAccordionIfSingleCa
1267
1293
  sortedCategories.forEach((category) => {
1268
1294
  groupedResults[category].sort((a, b) => (a.fromName ?? '').localeCompare(b.fromName ?? ''));
1269
1295
  });
1270
- // Reset internal selection when parent sets selectedSearchResult to undefined
1271
- // (this happens on mobile when clicking back to return to the list)
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.
1272
1300
  useEffect(() => {
1273
1301
  if (selectedSearchResult === undefined) {
1274
1302
  setSelectedResult(undefined);
1275
1303
  }
1276
- }, [selectedSearchResult]);
1304
+ else {
1305
+ const found = searchResults.find(r => r.fromTID === selectedSearchResult.fromTID);
1306
+ if (found) {
1307
+ setSelectedResult(found);
1308
+ }
1309
+ }
1310
+ }, [selectedSearchResult, searchResults]);
1277
1311
  // Auto-seleziona il primo risultato di ricerca solo se autoSelectFirst è true.
1278
1312
  // Su mobile con più risultati, autoSelectFirst è false per permettere all'utente
1279
1313
  // di vedere prima la lista dei tipi documento e scegliere manualmente.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.20.0-dev2.66",
3
+ "version": "6.20.0-dev2.68",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",