@topconsultnpm/sdkui-react-beta 6.14.30 → 6.14.32

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.
@@ -13,6 +13,7 @@ import { DeviceType, useDeviceType } from './TMDeviceProvider';
13
13
  import TMFileManagerThumbnailItems from './TMFileManagerThumbnailItems';
14
14
  import TMTooltip from './TMTooltip';
15
15
  import TMPanel from './TMPanel';
16
+ import { findFileItems, setFolderTreeViewItems } from './TMFileManagerUtils';
16
17
  export var TMFileManagerPageSize;
17
18
  (function (TMFileManagerPageSize) {
18
19
  TMFileManagerPageSize[TMFileManagerPageSize["Small"] = 30] = "Small";
@@ -112,37 +113,6 @@ const TMFileManager = (props) => {
112
113
  };
113
114
  filterItems();
114
115
  }, [searchText, selectedFolder]);
115
- // Function to recursively transform file items into directory format for TreeView
116
- const setFolderTreeViewItems = (items) => {
117
- return items
118
- .filter(item => item.isDirectory)
119
- .map((item) => {
120
- const el = {
121
- id: item.id,
122
- text: item.name,
123
- expanded: true,
124
- subFileFolderCount: item.items.filter(item => !item.isDirectory).length,
125
- items: item.items && item.items.length > 0 ? setFolderTreeViewItems(item.items) : [],
126
- };
127
- return el;
128
- });
129
- };
130
- // Function to find a specific file or folder based on its ID (used for finding nested items)
131
- const findFileItems = (items, id) => {
132
- for (let item of items) {
133
- if (item.id === id) {
134
- return item; // Return the found item
135
- }
136
- // Recursively search in sub-items if any
137
- if (item.items) {
138
- const found = findFileItems(item.items, id);
139
- if (found) {
140
- return found; // Return the found item from recursive call
141
- }
142
- }
143
- }
144
- return undefined; // Return undefined if not found
145
- };
146
116
  // Render each TreeView item (directories) with custom styling/icons
147
117
  const renderTreeViewItem = (itemData) => {
148
118
  const isSelected = selectedFolder && selectedFolder.id === itemData.id;
@@ -54,13 +54,25 @@ const TMFileManagerThumbnailItems = (props) => {
54
54
  }, [selectedFiles]);
55
55
  const handleKeyDown = (event) => {
56
56
  event.preventDefault();
57
- if (event.key === 'ArrowDown' && selectedFiles && selectedFiles.length === 1) {
58
- const currentIndex = items.findIndex(element => element.id === selectedFiles[0].id);
59
- if (items[currentIndex + 1]) {
60
- if (handleSelectedFiles)
61
- handleSelectedFiles([items[currentIndex + 1]]);
62
- }
63
- ;
57
+ if (!selectedFiles || selectedFiles.length !== 1)
58
+ return;
59
+ const currentIndex = items.findIndex(item => item.id === selectedFiles[0].id);
60
+ if (currentIndex === -1)
61
+ return;
62
+ switch (event.key) {
63
+ case 'ArrowDown':
64
+ const nextItem = items[currentIndex + 1];
65
+ if (nextItem && handleSelectedFiles) {
66
+ handleSelectedFiles([nextItem]);
67
+ }
68
+ break;
69
+ case 'Enter':
70
+ if (onDoubleClick) {
71
+ onDoubleClick(items[currentIndex]);
72
+ }
73
+ break;
74
+ default:
75
+ break;
64
76
  }
65
77
  };
66
78
  const handleKeyUp = (event) => {
@@ -0,0 +1,3 @@
1
+ import { FileItem, TMFileManagerTreeViewDirectory } from "./TMFileManager";
2
+ export declare const findFileItems: (items: Array<FileItem>, id: number) => FileItem | undefined;
3
+ export declare const setFolderTreeViewItems: (items: Array<FileItem>) => Array<TMFileManagerTreeViewDirectory>;
@@ -0,0 +1,31 @@
1
+ // Function to find a specific file or folder based on its ID (used for finding nested items)
2
+ export const findFileItems = (items, id) => {
3
+ for (let item of items) {
4
+ if (item.id === id) {
5
+ return item; // Return the found item
6
+ }
7
+ // Recursively search in sub-items if any
8
+ if (item.items) {
9
+ const found = findFileItems(item.items, id);
10
+ if (found) {
11
+ return found; // Return the found item from recursive call
12
+ }
13
+ }
14
+ }
15
+ return undefined; // Return undefined if not found
16
+ };
17
+ // Function to recursively transform file items into directory format for TreeView
18
+ export const setFolderTreeViewItems = (items) => {
19
+ return items
20
+ .filter(item => item.isDirectory)
21
+ .map((item) => {
22
+ const el = {
23
+ id: item.id,
24
+ text: item.name,
25
+ expanded: true,
26
+ subFileFolderCount: item.items.filter(item => !item.isDirectory).length,
27
+ items: item.items && item.items.length > 0 ? setFolderTreeViewItems(item.items) : [],
28
+ };
29
+ return el;
30
+ });
31
+ };
@@ -69,6 +69,7 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
69
69
  const { openConfirmAttachmentsDialog, ConfirmAttachmentsDialog } = useInputAttachmentsDialog();
70
70
  const { abortController, showWaitPanel, waitPanelTitle, showPrimary, waitPanelTextPrimary, waitPanelValuePrimary, waitPanelMaxValuePrimary, showSecondary, waitPanelTextSecondary, waitPanelValueSecondary, waitPanelMaxValueSecondary, downloadDcmtsAsync } = useDcmtOperations();
71
71
  const deviceType = useDeviceType();
72
+ const getDcmts = () => { return [{ TID: currentDcmt?.tid, DID: currentDcmt?.did, FILEEXT: currentDcmt?.fileExt }]; };
72
73
  const retrieveMetadataAsync = async () => {
73
74
  try {
74
75
  await DcmtTypeListCacheService.GetAsync(TID).then(async (dtd) => {
@@ -151,7 +152,6 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
151
152
  const isSysMetadataDisabled = layoutMode !== LayoutModes.Update;
152
153
  const isDetailsDisabled = layoutMode !== LayoutModes.Update || !DID;
153
154
  const isMasterDisabled = layoutMode !== LayoutModes.Update || !DID;
154
- const getDcmts = () => { return [{ TID: currentDcmt?.tid, DID: currentDcmt?.did, FILEEXT: currentDcmt?.fileExt }]; };
155
155
  const commandsMenuItems = [
156
156
  { icon: svgToString(_jsx(IconDownload, {})), operationType: 'singleRow', disabled: fromDTD?.perm?.canRetrieveFile !== AccessLevels.Yes, text: "Download file", onClick: async () => await downloadDcmtsAsync(getDcmts(), DownloadTypes.Dcmt, "download") },
157
157
  { icon: svgToString(_jsx(IconDownload, {})), operationType: 'singleRow', disabled: !isXMLFileExt(currentDcmt?.fileExt), text: "Download allegati XML", onClick: async () => await downloadDcmtsAsync(getDcmts(), DownloadTypes.Attachment, "download", undefined, openConfirmAttachmentsDialog) },
@@ -430,7 +430,7 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
430
430
  _jsxs(_Fragment, { children: [_jsx(TMButton, { disabled: archiveBtnDisabled, btnStyle: 'advanced', icon: _jsx(IconBoxArchiveIn, {}), width: 'auto', showTooltip: false, caption: SDKUI_Localizator.Archive, advancedColor: TMColors.success, onClick: confirmActionPopup }), _jsx(TMButton, { disabled: !clearFormBtnDisabled, btnStyle: 'advanced', icon: _jsx(IconClear, {}), width: 'auto', showTooltip: false, caption: SDKUI_Localizator.Clear, advancedColor: TMColors.tertiary, onClick: clearFormHandler }), DID && _jsx(TMButton, { disabled: undoBtnDisabled, btnStyle: 'advanced', icon: _jsx(IconUndo, {}), width: '150px', showTooltip: false, caption: SDKUI_Localizator.Undo, advancedColor: TMColors.tertiary, onClick: onUndoHandler })] }) }) }), totalItems > listMaxItems && _jsx(TMShowAllOrMaxItemsButton, { showAll: showAll, dataSourceLength: totalItems, onClick: () => { setShowAll(!showAll); } })] }), showApprovePopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, TID: TID, DID: DID, isReject: 0, onClose: () => setShowApprovePopup(false) }), showRejectPopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, TID: TID, DID: DID, isReject: 1, onClose: () => setShowRejectPopup(false) }), showReAssignPopup && _jsx(WorkFlowReAssignPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, TID: TID, DID: DID, onClose: () => setShowReAssignPopup(false) }), _jsx(ConfirmAttachmentsDialog, {})] }) }), [TID, DID, formData, formDataOrig, dcmtFile, focusedMetadataValue, isOpenDistinctValues, isOpenFormulaEditor, validationItems, showAll, showApprovePopup, showRejectPopup, showReAssignPopup, fileFromConnector]);
431
431
  const tmBlog = useMemo(() => _jsx(TMDcmtBlog, { tid: TID, did: DID }), [TID, DID]);
432
432
  const tmSysMetadata = useMemo(() => _jsx(TMMetadataValues, { layoutMode: layoutMode, openChooserBySingleClick: !isOpenDistinctValues, TID: TID, isReadOnly: true, deviceType: deviceType, metadataValues: formData.filter(o => (o.mid != undefined && o.mid <= 100)), metadataValuesOrig: formData.filter(o => (o.mid != undefined && o.mid <= 100)), validationItems: [] }), [TID, layoutMode, formData, deviceType]);
433
- const tmDcmtPreview = useMemo(() => _jsx(TMDcmtPreviewWrapper, { currentDcmt: currentDcmt, dcmtFile: dcmtFile, deviceType: deviceType, fromDTD: fromDTD, layoutMode: layoutMode, onFileUpload: (setFile) => {
433
+ const tmDcmtPreview = useMemo(() => _jsx(TMDcmtPreviewWrapper, { currentDcmt: currentDcmt, dcmtFile: dcmtFile ?? fileFromConnector, deviceType: deviceType, fromDTD: fromDTD, layoutMode: layoutMode, onFileUpload: (setFile) => {
434
434
  setDcmtFile(setFile);
435
435
  } }), [currentDcmt, dcmtFile, deviceType, fromDTD, layoutMode, fileFromConnector]);
436
436
  const normalizedTID = TID !== undefined ? Number(TID) : undefined;
@@ -487,7 +487,7 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
487
487
  contentOptions: { component: tmDcmtPreview },
488
488
  toolbarOptions: { icon: _jsx(IconShow, { fontSize: 24 }), disabled: isPreviewDisabled, visible: true, orderNumber: 4, isActive: allInitialPanelVisibility['tmDcmtPreview'] }
489
489
  }
490
- ], [tmDcmtForm, tmBlog, tmSysMetadata, tmDcmtPreview, isPreviewDisabled, isBoardDisabled, isSysMetadataDisabled, isClosable]);
490
+ ], [tmDcmtForm, tmBlog, tmSysMetadata, tmDcmtPreview, isPreviewDisabled, isBoardDisabled, isSysMetadataDisabled, fileFromConnector, isClosable]);
491
491
  // Retrieves the current document form setting based on the normalized TID
492
492
  const getCurrentDcmtFormSetting = () => {
493
493
  const settings = SDKUI_Globals.userSettings.dcmtFormSettings;
@@ -92,15 +92,35 @@ export const WorkFlowReAssignPopUp = ({ DID = 0, TID = 0, deviceType = DeviceTyp
92
92
  TMSpinner.hide();
93
93
  }
94
94
  };
95
+ // Determina il TID da usare
96
+ const tidToUse = selectedItems?.[0]?.TID ?? TID;
95
97
  useEffect(() => {
96
- const items = selectedItems.length > 0
97
- ? selectedItems.map(({ TID, DID }) => ({ TID, DID }))
98
- : [{ TID, DID }];
99
- SDK_Globals.tmSession?.NewWorkflowEngine().WFApprGetWFInfoAsync(items?.[0].TID).then(async (w) => {
100
- let users = await UserListCacheService.GetAllAsync();
101
- setParticipants(users.filter((u) => w?.participants?.some((p) => p.userID === u.id)));
102
- }).catch(err => TMExceptionBoxManager.show({ exception: err }));
103
- }, [selectedItems]);
98
+ let isMounted = true;
99
+ const fetchData = async () => {
100
+ TMSpinner.show({ description: "Caricamento dei partecipanti" });
101
+ try {
102
+ if (!tidToUse)
103
+ return;
104
+ // Recupera info workflow
105
+ const wf = await SDK_Globals.tmSession?.NewWorkflowEngine().WFApprGetWFInfoAsync(tidToUse);
106
+ // Recupera tutti gli utenti
107
+ const allUsers = await UserListCacheService.GetAllAsync();
108
+ // Filtra utenti partecipanti
109
+ const participantIds = wf?.participants?.map(p => p.userID);
110
+ const participantUsers = allUsers.filter(u => participantIds?.includes(u.id));
111
+ if (isMounted)
112
+ setParticipants(participantUsers);
113
+ }
114
+ catch (e) {
115
+ TMExceptionBoxManager.show({ exception: e });
116
+ }
117
+ finally {
118
+ TMSpinner.hide();
119
+ }
120
+ };
121
+ fetchData();
122
+ return () => { isMounted = false; };
123
+ }, [tidToUse]);
104
124
  return (_jsx(TMModal, { toolbar: _jsx(TMButton, { btnStyle: 'advanced', showTooltip: false, icon: _jsx(IconUser, { fontSize: 16 }), caption: 'Riassegna', disabled: disable, onClick: () => !disable && reAssignWorkFlowAsync(), advancedColor: TMColors.tertiary }), onClose: onClose, width: deviceType === DeviceType.MOBILE ? '95%' : '60%', height: '60%', isModal: true, title: 'Riassegna workflow ' + (selectedItems.length > 0 ? '(' + count() + ')' : ''), children: _jsxs("div", { style: { width: '100%', height: '100%', padding: '10px', display: 'flex', flexDirection: 'column', gap: 5 }, children: [_jsx(TMUserChooser, { dataSource: participants, values: selectedUserID, onValueChanged: (IDs) => {
105
125
  setSelectedUserID(IDs ?? []);
106
126
  } }), _jsxs("p", { style: { color: commentValue.length === 0 ? TMColors.error : 'black' }, children: ["Commento ", commentValue.length === 0 && _jsx("span", { children: ' (Campo obbligatorio)' }), " "] }), _jsx(StyledTextArea, { "$isValid": commentValue.length !== 0, value: commentValue, onChange: (e) => setCommentValue(e.target.value) })] }) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.14.30",
3
+ "version": "6.14.32",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",