@topconsultnpm/sdkui-react 6.20.0-test1 → 6.21.0-dev1.2

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.
Files changed (125) hide show
  1. package/lib/components/NewComponents/ContextMenu/styles.d.ts +3 -1
  2. package/lib/components/NewComponents/ContextMenu/styles.js +7 -5
  3. package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.js +7 -1
  4. package/lib/components/base/Styled.d.ts +4 -1
  5. package/lib/components/base/Styled.js +11 -3
  6. package/lib/components/base/TMPanel.js +6 -4
  7. package/lib/components/base/TMPopUp.js +4 -0
  8. package/lib/components/base/TMTreeView.d.ts +3 -1
  9. package/lib/components/base/TMTreeView.js +68 -21
  10. package/lib/components/base/TMWaitPanel.js +6 -5
  11. package/lib/components/choosers/TMDataListItemChooser.js +1 -1
  12. package/lib/components/choosers/TMDataListItemEditor.d.ts +11 -0
  13. package/lib/components/choosers/TMDataListItemEditor.js +130 -0
  14. package/lib/components/choosers/TMDataListItemFields.d.ts +11 -0
  15. package/lib/components/choosers/TMDataListItemFields.js +61 -0
  16. package/lib/components/choosers/TMDataListItemPicker.d.ts +2 -0
  17. package/lib/components/choosers/TMDataListItemPicker.js +182 -18
  18. package/lib/components/choosers/TMDynDataListItemChooser.js +11 -6
  19. package/lib/components/choosers/TMImageIDChooser.d.ts +16 -0
  20. package/lib/components/choosers/TMImageIDChooser.js +53 -0
  21. package/lib/components/choosers/TMMetadataChooser.js +1 -1
  22. package/lib/components/choosers/TMUserChooser.js +1 -1
  23. package/lib/components/editors/TMDateBox.js +1 -1
  24. package/lib/components/editors/TMHtmlEditor.js +1 -1
  25. package/lib/components/editors/TMLocalizedTextBox.d.ts +1 -0
  26. package/lib/components/editors/TMLocalizedTextBox.js +3 -3
  27. package/lib/components/editors/TMMetadataValues.js +203 -41
  28. package/lib/components/editors/TMTextArea.d.ts +1 -0
  29. package/lib/components/editors/TMTextArea.js +6 -6
  30. package/lib/components/editors/TMTextBox.js +9 -10
  31. package/lib/components/features/archive/TMArchive.d.ts +3 -1
  32. package/lib/components/features/archive/TMArchive.js +31 -44
  33. package/lib/components/features/blog/TMBlogCommentForm.d.ts +3 -0
  34. package/lib/components/features/blog/TMBlogCommentForm.js +42 -36
  35. package/lib/components/features/documents/TMDcmtBlog.d.ts +1 -0
  36. package/lib/components/features/documents/TMDcmtBlog.js +2 -1
  37. package/lib/components/features/documents/TMDcmtForm.d.ts +44 -34
  38. package/lib/components/features/documents/TMDcmtForm.js +365 -563
  39. package/lib/components/features/documents/TMDcmtFormActionButtons.d.ts +34 -0
  40. package/lib/components/features/documents/TMDcmtFormActionButtons.js +124 -0
  41. package/lib/components/features/documents/TMDcmtPreview.js +66 -13
  42. package/lib/components/features/documents/TMDcmtTasks.d.ts +3 -1
  43. package/lib/components/features/documents/TMDcmtTasks.js +2 -2
  44. package/lib/components/features/documents/TMFileUploader.d.ts +5 -0
  45. package/lib/components/features/documents/TMFileUploader.js +28 -6
  46. package/lib/components/features/documents/TMMasterDetailDcmts.js +31 -85
  47. package/lib/components/features/documents/TMRelationViewer.d.ts +7 -1
  48. package/lib/components/features/documents/TMRelationViewer.js +497 -111
  49. package/lib/components/features/search/TMSearch.d.ts +2 -2
  50. package/lib/components/features/search/TMSearch.js +3 -3
  51. package/lib/components/features/search/TMSearchQueryPanel.js +6 -6
  52. package/lib/components/features/search/TMSearchResult.d.ts +28 -25
  53. package/lib/components/features/search/TMSearchResult.js +445 -562
  54. package/lib/components/features/search/TMSignatureInfoContent.js +10 -6
  55. package/lib/components/features/search/TMTreeSelector.js +1 -1
  56. package/lib/components/features/tasks/TMTaskForm.d.ts +3 -1
  57. package/lib/components/features/tasks/TMTaskForm.js +61 -193
  58. package/lib/components/features/tasks/TMTaskFormUtils.d.ts +80 -0
  59. package/lib/components/features/tasks/TMTaskFormUtils.js +559 -0
  60. package/lib/components/features/tasks/TMTasksUtils.d.ts +3 -1
  61. package/lib/components/features/tasks/TMTasksUtils.js +46 -16
  62. package/lib/components/features/tasks/TMTasksUtilsView.d.ts +0 -7
  63. package/lib/components/features/tasks/TMTasksUtilsView.js +7 -14
  64. package/lib/components/features/tasks/TMTasksView.js +5 -3
  65. package/lib/components/features/workflow/TMWorkflowPopup.d.ts +20 -3
  66. package/lib/components/features/workflow/TMWorkflowPopup.js +21 -109
  67. package/lib/components/features/workflow/diagram/ConnectionComponent.d.ts +1 -0
  68. package/lib/components/features/workflow/diagram/ConnectionComponent.js +6 -2
  69. package/lib/components/features/workflow/diagram/DiagramItemForm.d.ts +2 -0
  70. package/lib/components/features/workflow/diagram/DiagramItemForm.js +32 -25
  71. package/lib/components/features/workflow/diagram/RecipientList.d.ts +3 -1
  72. package/lib/components/features/workflow/diagram/RecipientList.js +13 -9
  73. package/lib/components/features/workflow/diagram/WFDiagram.js +102 -5
  74. package/lib/components/features/workflow/diagram/workflowHelpers.js +31 -19
  75. package/lib/components/forms/Login/TMLoginForm.js +1 -1
  76. package/lib/components/forms/TMSaveForm.js +61 -13
  77. package/lib/components/grids/TMBlogsPost.js +8 -8
  78. package/lib/components/grids/TMBlogsPostUtils.js +2 -2
  79. package/lib/components/grids/TMRecentsManager.js +1 -1
  80. package/lib/components/index.d.ts +2 -0
  81. package/lib/components/index.js +2 -0
  82. package/lib/components/layout/panelManager/TMPanelManagerContainer.js +3 -2
  83. package/lib/components/pages/TMPage.js +4 -0
  84. package/lib/components/query/TMQueryEditor.d.ts +1 -0
  85. package/lib/components/query/TMQueryEditor.js +3 -3
  86. package/lib/components/viewers/TMMidViewer.js +2 -1
  87. package/lib/components/viewers/TMTidViewer.js +7 -3
  88. package/lib/helper/Enum_Localizator.js +5 -0
  89. package/lib/helper/GlobalStyles.js +3 -0
  90. package/lib/helper/SDKUI_Globals.d.ts +12 -0
  91. package/lib/helper/SDKUI_Globals.js +21 -1
  92. package/lib/helper/SDKUI_Localizator.d.ts +31 -7
  93. package/lib/helper/SDKUI_Localizator.js +286 -46
  94. package/lib/helper/TMIcons.d.ts +2 -1
  95. package/lib/helper/TMIcons.js +4 -1
  96. package/lib/helper/TMUtils.d.ts +33 -41
  97. package/lib/helper/TMUtils.js +157 -170
  98. package/lib/helper/checkinCheckoutManager.js +6 -2
  99. package/lib/helper/helpers.d.ts +6 -2
  100. package/lib/helper/helpers.js +24 -8
  101. package/lib/helper/index.d.ts +1 -0
  102. package/lib/helper/index.js +1 -0
  103. package/lib/helper/queryHelper.js +1 -1
  104. package/lib/hooks/useBetaFeatures.d.ts +1 -0
  105. package/lib/hooks/useBetaFeatures.js +41 -0
  106. package/lib/hooks/useCheckInOutOperations.d.ts +7 -6
  107. package/lib/hooks/useCheckInOutOperations.js +9 -16
  108. package/lib/hooks/useDataUserIdItem.js +2 -2
  109. package/lib/hooks/useDcmtOperations.d.ts +3 -2
  110. package/lib/hooks/useDcmtOperations.js +16 -4
  111. package/lib/hooks/useDocumentOperations.d.ts +139 -0
  112. package/lib/hooks/useDocumentOperations.js +1275 -0
  113. package/lib/hooks/useRelatedDocuments.d.ts +1 -1
  114. package/lib/hooks/useRelatedDocuments.js +64 -42
  115. package/lib/index.d.ts +1 -0
  116. package/lib/index.js +1 -0
  117. package/lib/services/platform_services.d.ts +1 -1
  118. package/lib/services/platform_services.js +4 -0
  119. package/lib/ts/types.d.ts +5 -1
  120. package/lib/ts/types.js +1 -0
  121. package/package.json +55 -55
  122. package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +0 -11
  123. package/lib/components/features/search/TMSearchResultsMenuItems.js +0 -770
  124. package/lib/components/features/search/TMSignSettingsForm.d.ts +0 -9
  125. package/lib/components/features/search/TMSignSettingsForm.js +0 -621
@@ -0,0 +1,1275 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { AccessLevels, AccessLevelsEx, AppModules, DcmtOpers, DcmtTypeListCacheService, FileFormats, GeneralRetrieveFormats, LayoutModes, RetrieveFileOptions, SDK_Globals } from "@topconsultnpm/sdk-ts";
4
+ import { DcmtOperationTypes, DownloadTypes, SearchResultContext } from "../ts";
5
+ import { ButtonNames, ShowAlert, StyledModalContainer, StyledMultiViewPanel, TMBlogCommentForm, TMChooserForm, TMExceptionBoxManager, TMMessageBoxManager, TMModal, TMSpinner, WorkFlowApproveRejectPopUp, WorkFlowMoreInfoPopUp, WorkFlowReAssignPopUp } from "../components";
6
+ import { useDeviceType, DeviceType } from '../components/base/TMDeviceProvider';
7
+ import TMCustomButton from "../components/base/TMCustomButton";
8
+ import TMDataGridExportForm from "../components/base/TMDataGridExportForm";
9
+ import TMArchive from "../components/features/archive/TMArchive";
10
+ import TMBatchUpdateForm from "../components/features/documents/TMBatchUpdateForm";
11
+ import TMDcmtForm from "../components/features/documents/TMDcmtForm";
12
+ import TMMasterDetailDcmts from "../components/features/documents/TMMasterDetailDcmts";
13
+ import TMDcmtCheckoutInfoForm from "../components/features/search/TMDcmtCheckoutInfoForm";
14
+ import TMSearch from "../components/features/search/TMSearch";
15
+ import TMSearchResult from "../components/features/search/TMSearchResult";
16
+ import TMSignatureInfoContent from "../components/features/search/TMSignatureInfoContent";
17
+ import TMViewHistoryDcmt from "../components/features/search/TMViewHistoryDcmt";
18
+ import TMFloatingMenuBar from "../components/NewComponents/FloatingMenuBar";
19
+ import { useCheckInOutOperations } from "./useCheckInOutOperations";
20
+ import { useDcmtOperations } from "./useDcmtOperations";
21
+ import useFloatingBarPinnedItems from "./useFloatingBarPinnedItems";
22
+ import { useInputAttachmentsDialog, useInputCvtFormatDialog } from "./useInputDialog";
23
+ import { useRelatedDocuments } from "./useRelatedDocuments";
24
+ import { convertSearchResultDescriptorToFileItems, dcmtsFileCachePreview, getDcmtCicoStatus, getMoreInfoTasksForDocument, IconActivity, IconArchiveDetail, IconArchiveDoc, IconArchiveMaster, IconBatchUpdate, IconCheck, IconCheckFile, IconCheckIn, IconCircleInfo, IconCloseCircle, IconConvertFilePdf, IconCopy, IconCustom, IconDelete, IconDetailDcmts, IconDotsVerticalCircleOutline, IconDownload, IconEdit, IconExportTo, IconFileDots, IconHide, IconInfo, IconMenuCAArchive, IconMoveToFolder, IconPair, IconPin, IconPlatform, IconPreview, IconRelation, IconSearch, IconShare, IconSharedDcmt, IconShow, IconSignaturePencil, IconStar, IconSubstFile, IconUndo, IconUnpair, IconUserGroupOutline, isPdfEditorAvailable, SDKUI_Localizator, searchResultToMetadataValues, TMImageLibrary } from '../helper';
25
+ import { isXMLFileExt } from "../helper/dcmtsHelper";
26
+ export const getSelectedDcmtsOrFocused = (selectedItems, focusedItem, fileFormat) => {
27
+ if (selectedItems.length <= 0 && !focusedItem)
28
+ return [];
29
+ if (selectedItems.length > 0) {
30
+ // Filtra solo gli item che hanno TID e DID validi
31
+ return selectedItems
32
+ .filter((item) => item.TID !== undefined && item.DID !== undefined)
33
+ .map((item) => { return { TID: item.TID, DID: item.DID, FILEEXT: item.FILEEXT, ISSIGNED: Number(item.ISSIGNED ?? 0), fileFormat: fileFormat, rowIndex: item.rowIndex }; });
34
+ }
35
+ else if (focusedItem !== undefined && focusedItem.TID !== undefined && focusedItem.DID !== undefined) {
36
+ return [{ TID: focusedItem.TID, DID: focusedItem.DID, FILEEXT: focusedItem.FILEEXT, ISSIGNED: Number(focusedItem.ISSIGNED ?? 0), fileFormat: fileFormat, rowIndex: focusedItem.rowIndex }];
37
+ }
38
+ return [];
39
+ };
40
+ export const getAllFieldSelectedDcmtsOrFocused = (selectedItems, focusedItem, fileFormat) => {
41
+ if (selectedItems.length <= 0 && !focusedItem)
42
+ return [];
43
+ if (selectedItems.length > 0) {
44
+ return selectedItems;
45
+ }
46
+ else if (focusedItem !== undefined) {
47
+ return [focusedItem];
48
+ }
49
+ return [];
50
+ };
51
+ export const useDocumentOperations = (props) => {
52
+ const { context, documentData, exportData, uiConfig, tasks, callbacks, } = props;
53
+ const { dtd, selectedItems, focusedItem, searchResult, currentSearchResults, currentMetadataValues, allUsers = [], datagridUtility, dcmtUtility, } = documentData;
54
+ /** State for managing the document(s) to process */
55
+ const [selectedDcmtInfos, setSelectedDcmtInfos] = useState([]);
56
+ const [selectedItemsFull, setSelectedItemsFull] = useState([]);
57
+ // Refs per evitare loop causati da nuove reference di array
58
+ const prevSelectedItemsRef = useRef([]);
59
+ const prevFocusedItemRef = useRef(undefined);
60
+ useEffect(() => {
61
+ // Confronto basato su TID/DID per evitare loop causati da nuove reference
62
+ const areItemsEqual = (a, b) => {
63
+ if (a.length !== b.length)
64
+ return false;
65
+ return a.every((item, index) => {
66
+ const other = b[index];
67
+ return item?.TID === other?.TID && item?.DID === other?.DID;
68
+ });
69
+ };
70
+ const selectedChanged = !areItemsEqual(selectedItems, prevSelectedItemsRef.current);
71
+ const focusedChanged = focusedItem?.TID !== prevFocusedItemRef.current?.TID || focusedItem?.DID !== prevFocusedItemRef.current?.DID;
72
+ if (selectedChanged || focusedChanged) {
73
+ prevSelectedItemsRef.current = selectedItems;
74
+ prevFocusedItemRef.current = focusedItem;
75
+ setSelectedDcmtInfos(getSelectedDcmtsOrFocused(selectedItems, focusedItem));
76
+ setSelectedItemsFull(getAllFieldSelectedDcmtsOrFocused(selectedItems, focusedItem));
77
+ }
78
+ }, [selectedItems, focusedItem]);
79
+ const onRefreshPreviewCallback = async () => {
80
+ await onRefreshPreviewForm?.();
81
+ await onRefreshPreviewDatagrid?.();
82
+ };
83
+ const { dataColumns, dataSource, selectedRowKeys, } = exportData ?? {};
84
+ const { visibleItems = [], onRefreshSearchAsyncDatagrid, onRefreshDataRowsAsync, refreshFocusedDataRowAsync, onRefreshBlogDatagrid, onRefreshPreviewDatagrid, refreshOperationsTrigger = 0, onRefreshOperationsDatagrid, } = datagridUtility ?? {};
85
+ const { approvalVID, dcmtDataRowForCicoStatus, selectedDcmtSearchResultRelations, dcmtTIDHasDetailRelations = false, dcmtTIDHasMasterRelations = false, updateCurrentDcmt, onCloseDcmtForm, onRefreshBlogForm, onRefreshPreviewForm, taskFormDialogComponent, s4TViewerDialogComponent } = dcmtUtility ?? {};
86
+ const { floatingBarContainerRef, customButtonsLayout, workingGroupContext, openS4TViewer = false, openDcmtFormAsModal = false, showDcmtFormSidebar = true, allowFloatingBar = true, enablePinIcons = true, allowRelations = true, showTodoDcmtForm = false, showToppyDraggableHelpCenter = true, toppyHelpCenterUsePortal = false, editPdfForm = false, inputDcmtFormLayoutMode = LayoutModes.Update, } = uiConfig;
87
+ const { allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTaskCallback, editTaskCallback } = tasks;
88
+ const {
89
+ // Refresh operations (data consistency)
90
+ onSavedAsyncCallback, onRefreshAfterAddDcmtToFavs,
91
+ // Workflow operations
92
+ onWFOperationCompleted,
93
+ // Navigation
94
+ canNavigateHandler, onNavigateHandler, handleNavigateToWGs, handleNavigateToDossiers, onReferenceClick,
95
+ // Document forms/operations
96
+ openAddDocumentForm, openCommentFormCallback, onFileOpened, passToArchiveCallback, openWGsCopyMoveForm, onOpenS4TViewerRequest, onOpenPdfEditorRequest,
97
+ // Task related
98
+ onTaskCreateRequest, openTaskFormHandler, } = callbacks;
99
+ // Force recalculation of selectedDcmtInfos when refreshOperationsTrigger changes (e.g., after file substitution where FILEEXT may change)
100
+ useEffect(() => {
101
+ if (refreshOperationsTrigger > 0) {
102
+ setSelectedDcmtInfos(getSelectedDcmtsOrFocused(selectedItems, focusedItem));
103
+ setSelectedItemsFull(getAllFieldSelectedDcmtsOrFocused(selectedItems, focusedItem));
104
+ }
105
+ }, [refreshOperationsTrigger]);
106
+ // Context helpers
107
+ const isDcmtFormContext = context === SearchResultContext.DCMT_FORM;
108
+ const { showHistory, showHistoryCallback, hideHistoryCallback, showCheckoutInformationForm, commentFormState, hideCommentFormCallback, showCheckoutInformationFormCallback, hideCheckoutInformationFormCallback, copyCheckoutPathToClipboardCallback, handleCheckOutCallback, handleCheckInCallback, showCicoWaitPanel, cicoWaitPanelTitle, showCicoPrimaryProgress, cicoPrimaryProgressText, cicoPrimaryProgressValue, cicoPrimaryProgressMax, } = useCheckInOutOperations({
109
+ onRefreshPreview: onRefreshPreviewCallback
110
+ });
111
+ const { abortController, showWaitPanel, waitPanelTitle, showPrimary, waitPanelTextPrimary, waitPanelValuePrimary, waitPanelMaxValuePrimary, showSecondary, waitPanelTextSecondary, waitPanelValueSecondary, waitPanelMaxValueSecondary, downloadDcmtsAsync, runOperationAsync, getDcmtFileAsync, clearDcmtsFileCache, removeDcmtsFileCache, isDcmtFileInCache } = useDcmtOperations();
112
+ const {
113
+ // Data
114
+ relatedDcmts, pairedSearchResults, manyToManyRelations, selectedManyToManyRelation, manyToManyChooserDataSource, relatedDcmtsChooserDataSource,
115
+ // Flags / State booleans
116
+ showRelatedDcmtsChooser, isOpenDetails, isOpenMaster, isOpenArchiveRelationForm, isPairingManyToMany, showManyToManyChooser, showPairSearchModal, currentTIDHasDetailRelations, currentTIDHasMasterRelations, canArchiveMasterRelation, canArchiveDetailRelation, hasManyToManyRelation, showPairDcmtsModal,
117
+ // Pair search modal state
118
+ pairSearchModalTargetTID, pairSearchModalParentTID, pairSearchModalParentDID, pairSearchModalRelation, pairSearchModalInputMids,
119
+ // Config
120
+ pairFloatingActionConfig, pairSearchModalFloatingActionConfig,
121
+ // Archive state
122
+ archiveRelatedDcmtFormTID, archiveRelatedDcmtFormMids, archiveType,
123
+ // Setters
124
+ setIsOpenDetails, setIsOpenMaster, setShowRelatedDcmtsChooser, setIsOpenArchiveRelationForm, setArchiveType, setArchiveRelatedDcmtFormTID, setArchiveRelatedDcmtFormMids, setShowManyToManyChooser, setShowPairDcmtsModal, setShowPairSearchModal,
125
+ // Logic / Helpers
126
+ checkRelatedDcmtsArchiveCapability, checkManyToManyCapability,
127
+ // Actions
128
+ pairManyToMany, executeManyToManyPairing, archiveDetailDocuments, archiveMasterDocuments, archiveRelatedDcmtHandler } = useRelatedDocuments({
129
+ selectedSearchResult: isDcmtFormContext ? selectedDcmtSearchResultRelations : searchResult,
130
+ focusedItem: focusedItem,
131
+ currentSearchResults
132
+ });
133
+ // Context-aware configuration for relations and other context-dependent logic
134
+ const contextConfig = {
135
+ hasMasterRelations: isDcmtFormContext ? dcmtTIDHasMasterRelations : currentTIDHasMasterRelations,
136
+ hasDetailRelations: isDcmtFormContext ? dcmtTIDHasDetailRelations : currentTIDHasDetailRelations,
137
+ canShowRelations: !isDcmtFormContext || inputDcmtFormLayoutMode === LayoutModes.Update,
138
+ approvalTID: isDcmtFormContext ? (approvalVID ?? focusedItem?.TID) : focusedItem?.TID,
139
+ };
140
+ const { openConfirmAttachmentsDialog, ConfirmAttachmentsDialog } = useInputAttachmentsDialog();
141
+ const [confirmFormat, ConfirmFormatDialog] = useInputCvtFormatDialog();
142
+ const MAX_DCMTS_FOR_SELECTION_REFRESH = 100;
143
+ const { pinnedItemIds, togglePin, setPinnedItemIds } = useFloatingBarPinnedItems();
144
+ const deviceType = useDeviceType();
145
+ const isMobile = deviceType === DeviceType.MOBILE;
146
+ const [showFloatingBar, setShowFloatingBar] = useState(allowFloatingBar);
147
+ const [isOpenDcmtForm, setIsOpenDcmtForm] = useState(false);
148
+ const [dcmtFormLayoutMode, setDcmtFormLayoutMode] = useState(LayoutModes.Update);
149
+ const [currentCustomButton, setCurrentCustomButton] = useState();
150
+ // State to control the visibility of the details form
151
+ const [showSearchTMDatagrid, setShowSearchTMDatagrid] = useState(false);
152
+ const [secondaryMasterDcmts, setSecondaryMasterDcmts] = useState([]);
153
+ const [isOpenSharedArchive, setIsOpenSharedArchive] = useState(false);
154
+ const [sharedDcmtFile, setSharedDcmtFile] = useState(undefined);
155
+ // State to control the shared document search results
156
+ const [sharedDcmtSearchResults, setSharedDcmtSearchResults] = useState([]);
157
+ /** Toppy Operations */
158
+ const [showApprovePopup, setShowApprovePopup] = useState(false);
159
+ const [showRejectPopup, setShowRejectPopup] = useState(false);
160
+ const [showReAssignPopup, setShowReAssignPopup] = useState(false);
161
+ const [showMoreInfoPopup, setShowMoreInfoPopup] = useState(false);
162
+ const [isOpenBatchUpdate, setIsOpenBatchUpdate] = useState(false);
163
+ const [isModifiedBatchUpdate, setIsModifiedBatchUpdate] = useState(false);
164
+ const openDetailDcmtsFormHandler = (value) => { setIsOpenDetails(value); };
165
+ const openMasterDcmtsFormHandler = (value) => { setIsOpenMaster(value); };
166
+ // State to control whether the export form (for exporting to Excel/CSV/txt and others) should be shown
167
+ const [showExportForm, setShowExportForm] = useState(false);
168
+ const updateShowApprovePopup = (value) => {
169
+ setShowApprovePopup(value);
170
+ };
171
+ const updateShowRejectPopup = (value) => {
172
+ setShowRejectPopup(value);
173
+ };
174
+ const updateShowReAssignPopup = (value) => {
175
+ setShowReAssignPopup(value);
176
+ };
177
+ const updateShowMoreInfoPopup = (value) => {
178
+ setShowMoreInfoPopup(value);
179
+ };
180
+ const onDcmtFormOpenChange = (isOpen, layoutMode) => {
181
+ setIsOpenDcmtForm(isOpen);
182
+ setDcmtFormLayoutMode(layoutMode);
183
+ };
184
+ const handleAddItem = (tid, did) => {
185
+ let newItem = { TID: tid ?? 0, DID: did ?? 0 };
186
+ setSecondaryMasterDcmts((prevItems) => [...prevItems, newItem]);
187
+ };
188
+ const handleRemoveItem = (tid, did) => {
189
+ setSecondaryMasterDcmts((prevItems) => prevItems.filter(item => item.TID !== tid && item.DID !== did));
190
+ };
191
+ const updateBatchUpdateForm = (value) => { setIsOpenBatchUpdate(value); };
192
+ // Disabilita se ci sono più documenti da processare o se non c'è un documento valido
193
+ const isDisabledForSingleRow = () => {
194
+ return selectedDcmtInfos.length !== 1 || selectedDcmtInfos[0]?.TID === undefined || selectedDcmtInfos[0]?.DID === undefined;
195
+ };
196
+ // Disabilita se non ci sono documenti validi da processare
197
+ const isDisabledForMultiRow = () => {
198
+ return selectedDcmtInfos.length === 0 || selectedDcmtInfos.every(d => d.TID === undefined || d.DID === undefined);
199
+ };
200
+ const onRefreshBlog = async () => {
201
+ await onRefreshBlogForm?.();
202
+ await onRefreshBlogDatagrid?.();
203
+ };
204
+ const signatureInformationCallback = async (isMobile, inputDcmts) => {
205
+ try {
206
+ TMSpinner.show({ description: SDKUI_Localizator.Loading });
207
+ if (!inputDcmts || inputDcmts.length === 0) {
208
+ ShowAlert({
209
+ message: SDKUI_Localizator.NoDcmtSelected,
210
+ mode: 'warning',
211
+ title: SDKUI_Localizator.SignatureInformation,
212
+ duration: 3000
213
+ });
214
+ return;
215
+ }
216
+ if (inputDcmts.length > 1) {
217
+ ShowAlert({
218
+ message: "Selezionare un solo documento per visualizzare le informazioni di firma",
219
+ mode: 'warning',
220
+ title: SDKUI_Localizator.SignatureInformation,
221
+ duration: 3000
222
+ });
223
+ return;
224
+ }
225
+ TMMessageBoxManager.show({
226
+ title: SDKUI_Localizator.SignatureInformation,
227
+ buttons: [ButtonNames.OK],
228
+ showToppy: false,
229
+ resizable: true,
230
+ initialWidth: !isMobile ? '700px' : undefined,
231
+ message: _jsx(TMSignatureInfoContent, { inputDcmt: inputDcmts[0] })
232
+ });
233
+ }
234
+ catch (error) {
235
+ console.error(error);
236
+ TMExceptionBoxManager.show({ exception: error });
237
+ }
238
+ finally {
239
+ TMSpinner.hide();
240
+ }
241
+ };
242
+ const openFormHandler = (layoutMode) => {
243
+ const currentDcmt = selectedDcmtInfos?.[0];
244
+ // Verifica che ci sia un documento selezionato con TID e DID validi
245
+ if (!currentDcmt || currentDcmt.TID === undefined || currentDcmt.DID === undefined) {
246
+ ShowAlert({
247
+ message: SDKUI_Localizator.InvalidDcmt,
248
+ mode: "warning",
249
+ title: layoutMode === LayoutModes.Ark ? SDKUI_Localizator.Archive : SDKUI_Localizator.OpenTheDocument,
250
+ duration: 3000
251
+ });
252
+ return;
253
+ }
254
+ onDcmtFormOpenChange(true, layoutMode);
255
+ };
256
+ const openSharedArchiveHandler = async () => {
257
+ if (selectedDcmtInfos.length === 0) {
258
+ ShowAlert({ message: "Nessun documento selezionato", mode: "warning", title: 'Archiviazione Condivisa', duration: 3000 });
259
+ return;
260
+ }
261
+ if (dtd?.perm?.canArchive !== AccessLevelsEx.Yes && dtd?.perm?.canArchive !== AccessLevelsEx.Mixed) {
262
+ ShowAlert({
263
+ message: "Non hai i permessi per archiviare documenti di questo tipo.",
264
+ mode: 'warning',
265
+ title: 'Archivio Condivisa',
266
+ duration: 5000
267
+ });
268
+ return;
269
+ }
270
+ try {
271
+ const rfo = new RetrieveFileOptions();
272
+ rfo.retrieveReason = DcmtOpers.None;
273
+ rfo.generalRetrieveFormat = GeneralRetrieveFormats.OriginalUnsigned;
274
+ const dcmt = selectedDcmtInfos[0];
275
+ let dcmtFile = await getDcmtFileAsync({ TID: dcmt?.TID, DID: dcmt?.DID }, rfo, 'Archiviazione Condivisa', false, true);
276
+ if (dcmtFile) {
277
+ setSharedDcmtFile(dcmtFile?.file);
278
+ }
279
+ setIsOpenSharedArchive(true);
280
+ }
281
+ catch (e) {
282
+ TMExceptionBoxManager.show({ exception: e });
283
+ }
284
+ };
285
+ const showSharedDcmtsHandler = async () => {
286
+ try {
287
+ if (selectedDcmtInfos.length === 0) {
288
+ ShowAlert({ message: "Nessun documento selezionato", mode: "warning", title: 'Documenti Condivisi', duration: 3000 });
289
+ return;
290
+ }
291
+ const dcmt = selectedDcmtInfos[0];
292
+ TMSpinner.show({ description: "Caricamento documenti condivisi..." });
293
+ const se = SDK_Globals.tmSession?.NewSearchEngine();
294
+ const sharedDcmts = await se?.GetSharedDcmtsAsync(dcmt.TID, dcmt.DID);
295
+ if (sharedDcmts && sharedDcmts.length > 0) {
296
+ setSharedDcmtSearchResults(sharedDcmts);
297
+ }
298
+ else {
299
+ ShowAlert({ message: "Nessun documento condiviso trovato.", mode: "info", title: 'Documenti Condivisi', duration: 5000 });
300
+ }
301
+ }
302
+ catch (e) {
303
+ TMExceptionBoxManager.show({ exception: e });
304
+ }
305
+ finally {
306
+ TMSpinner.hide();
307
+ }
308
+ };
309
+ const addPinIconToItems = (items) => {
310
+ if (isMobile || !enablePinIcons)
311
+ return items;
312
+ return items.map(item => {
313
+ const newItem = { ...item };
314
+ if (item.id && item.onClick && !item.submenu) {
315
+ newItem.rightIconProps = {
316
+ icon: _jsx(IconPin, {}),
317
+ activeColor: 'red',
318
+ inactiveColor: 'black',
319
+ isActive: pinnedItemIds?.includes(item.id) ?? false,
320
+ onClick: () => togglePin(item.id),
321
+ };
322
+ }
323
+ if (item.submenu && item.submenu.length > 0) {
324
+ newItem.submenu = addPinIconToItems(item.submenu);
325
+ }
326
+ return newItem;
327
+ });
328
+ };
329
+ const addToFavoriteOperation = () => {
330
+ return {
331
+ id: 'fav',
332
+ icon: _jsx(IconStar, {}),
333
+ name: SDKUI_Localizator.AddTo + ' ' + SDKUI_Localizator.Favorites,
334
+ operationType: 'multiRow',
335
+ disabled: context === SearchResultContext.FAVORITES_AND_RECENTS || isDisabledForMultiRow(),
336
+ onClick: async () => { await runOperationAsync(selectedDcmtInfos, DcmtOperationTypes.AddToFavs); onRefreshAfterAddDcmtToFavs?.(); },
337
+ };
338
+ };
339
+ const addReplaceFileOperation = () => {
340
+ return {
341
+ id: 'repl',
342
+ icon: _jsx(IconSubstFile, {}),
343
+ name: SDKUI_Localizator.AddOrSubstFile,
344
+ operationType: 'singleRow',
345
+ disabled: dtd?.perm?.canSubstFile !== AccessLevels.Yes ? true : isDisabledForSingleRow(),
346
+ onClick: async () => {
347
+ const currentDcmt = selectedDcmtInfos?.[0];
348
+ if (!currentDcmt || currentDcmt.TID === undefined || currentDcmt.DID === undefined) {
349
+ ShowAlert({
350
+ message: SDKUI_Localizator.InvalidDcmt,
351
+ mode: "warning",
352
+ });
353
+ return;
354
+ }
355
+ await runOperationAsync(selectedDcmtInfos, DcmtOperationTypes.SubstituteFile, async () => {
356
+ await refreshDocumentPreview();
357
+ await onRefreshOperationsDatagrid?.();
358
+ });
359
+ }
360
+ };
361
+ };
362
+ const openFormOperation = () => {
363
+ return {
364
+ id: 'open-form',
365
+ icon: _jsx(IconPreview, {}),
366
+ name: SDKUI_Localizator.OpenForm,
367
+ operationType: 'singleRow',
368
+ disabled: isDisabledForSingleRow(),
369
+ onClick: () => openFormHandler(LayoutModes.Update)
370
+ };
371
+ };
372
+ const deletetionMenuItem = () => {
373
+ return {
374
+ id: 'del',
375
+ icon: _jsx(IconDelete, {}),
376
+ name: SDKUI_Localizator.Deletion,
377
+ operationType: 'multiRow',
378
+ disabled: isDisabledForMultiRow(),
379
+ submenu: [
380
+ {
381
+ id: 'del-log',
382
+ icon: _jsx(IconDelete, {}),
383
+ name: SDKUI_Localizator.LogDelete,
384
+ operationType: 'multiRow',
385
+ disabled: dtd?.perm?.canLogicalDelete !== AccessLevels.Yes ? true : isDisabledForMultiRow(),
386
+ onClick: async () => {
387
+ await runOperationAsync(selectedDcmtInfos, DcmtOperationTypes.LogDelete, selectedDcmtInfos.length <= MAX_DCMTS_FOR_SELECTION_REFRESH ? onRefreshDataRowsAsync : onRefreshSearchAsyncDatagrid);
388
+ }
389
+ },
390
+ {
391
+ id: 'del-rest',
392
+ icon: _jsx(IconUndo, {}),
393
+ name: SDKUI_Localizator.Restore,
394
+ operationType: 'multiRow',
395
+ disabled: dtd?.perm?.canLogicalDelete !== AccessLevels.Yes ? true : isDisabledForMultiRow(),
396
+ onClick: async () => {
397
+ await runOperationAsync(selectedDcmtInfos, DcmtOperationTypes.Undelete, selectedDcmtInfos.length <= MAX_DCMTS_FOR_SELECTION_REFRESH ? onRefreshDataRowsAsync : onRefreshSearchAsyncDatagrid);
398
+ }
399
+ },
400
+ {
401
+ id: 'del-phys',
402
+ icon: _jsx(IconCloseCircle, {}),
403
+ name: SDKUI_Localizator.PhysDelete,
404
+ operationType: 'multiRow',
405
+ disabled: dtd?.perm?.canPhysicalDelete !== AccessLevels.Yes ? true : isDisabledForMultiRow(),
406
+ onClick: async () => { await runOperationAsync(selectedDcmtInfos, DcmtOperationTypes.PhysDelete, onRefreshSearchAsyncDatagrid); }
407
+ },
408
+ ]
409
+ };
410
+ };
411
+ const fileCheckMenuItem = () => {
412
+ return {
413
+ id: 'chk',
414
+ icon: _jsx(IconCheckFile, {}),
415
+ name: SDKUI_Localizator.FileCheck,
416
+ operationType: 'multiRow',
417
+ disabled: isDisabledForMultiRow(),
418
+ onClick: async () => { await runOperationAsync(selectedDcmtInfos, DcmtOperationTypes.CheckFile); }
419
+ };
420
+ };
421
+ const fileConversionsMenuItem = () => {
422
+ return {
423
+ id: 'conv',
424
+ icon: _jsx(IconConvertFilePdf, {}),
425
+ name: SDKUI_Localizator.FileConversion,
426
+ operationType: 'multiRow',
427
+ disabled: isDisabledForMultiRow(),
428
+ onClick: async () => {
429
+ let format = await confirmFormat();
430
+ if (format === FileFormats.None)
431
+ return;
432
+ const dcmts = selectedDcmtInfos.map(dcmt => {
433
+ const cacheKey = `${dcmt.TID}-${dcmt.DID}`;
434
+ if (dcmtsFileCachePreview.has(cacheKey)) {
435
+ removeDcmtsFileCache(cacheKey);
436
+ }
437
+ return { ...dcmt, fileFormat: format };
438
+ });
439
+ const refreshFn = async () => {
440
+ const baseRefreshFn = dcmts.length <= MAX_DCMTS_FOR_SELECTION_REFRESH ? onRefreshDataRowsAsync : onRefreshSearchAsyncDatagrid;
441
+ await onRefreshPreviewCallback();
442
+ await baseRefreshFn?.();
443
+ await onRefreshOperationsDatagrid?.();
444
+ };
445
+ await runOperationAsync(dcmts, DcmtOperationTypes.ConvertFile, refreshFn);
446
+ }
447
+ };
448
+ };
449
+ const createContextualTaskMenuItem = () => {
450
+ return {
451
+ id: 'task',
452
+ icon: _jsx(IconActivity, {}),
453
+ name: SDKUI_Localizator.CreateContextualTask,
454
+ operationType: 'singleRow',
455
+ disabled: isDisabledForSingleRow(),
456
+ onClick: () => { openTaskFormHandler?.(); }
457
+ };
458
+ };
459
+ const downloadFileMenuItem = () => {
460
+ return {
461
+ id: 'dl',
462
+ icon: _jsx(IconDownload, {}),
463
+ operationType: 'multiRow',
464
+ disabled: dtd?.perm?.canRetrieveFile !== AccessLevels.Yes ? true : isDisabledForMultiRow(),
465
+ name: SDKUI_Localizator.DownloadFile, onClick: () => downloadDcmtsAsync(selectedDcmtInfos, DownloadTypes.Dcmt, "download", undefined, undefined, true)
466
+ };
467
+ };
468
+ const downloadXMLAttachmentsMenuItem = () => {
469
+ return {
470
+ id: 'dl-xml',
471
+ icon: _jsx(IconDownload, {}),
472
+ operationType: 'singleRow',
473
+ disabled: !isXMLFileExt(selectedDcmtInfos?.[0]?.FILEEXT) ? true : isDisabledForSingleRow(),
474
+ name: SDKUI_Localizator.DownloadXMLAttachments, onClick: () => downloadDcmtsAsync(selectedDcmtInfos, DownloadTypes.Attachment, "download", undefined, openConfirmAttachmentsDialog, true)
475
+ };
476
+ };
477
+ const duplicateDocumentMenuItem = () => {
478
+ return {
479
+ id: 'dup',
480
+ icon: _jsx(IconArchiveDoc, {}),
481
+ name: SDKUI_Localizator.DuplicateDocument,
482
+ operationType: 'singleRow',
483
+ disabled: dtd?.perm?.canArchive !== AccessLevelsEx.Yes && dtd?.perm?.canArchive !== AccessLevelsEx.Mixed ? true : isDisabledForSingleRow(),
484
+ onClick: () => { openFormHandler(LayoutModes.Ark); }
485
+ };
486
+ };
487
+ const batchUpdateMenuItem = () => {
488
+ return {
489
+ id: 'batch',
490
+ icon: _jsx(IconBatchUpdate, {}),
491
+ name: SDKUI_Localizator.BatchUpdate,
492
+ operationType: 'multiRow',
493
+ disabled: dtd?.perm?.canUpdate !== AccessLevelsEx.Yes && dtd?.perm?.canUpdate !== AccessLevelsEx.Mixed ? true : isDisabledForMultiRow(),
494
+ onClick: () => updateBatchUpdateForm(true)
495
+ };
496
+ };
497
+ const passToArchive = () => {
498
+ return {
499
+ id: 'p2a',
500
+ icon: _jsx(IconMenuCAArchive, { fontSize: 16, viewBox: '11 11.5 26 27', strokeWidth: 2 }),
501
+ name: SDKUI_Localizator.PassToArchive,
502
+ operationType: 'singleRow',
503
+ disabled: dtd?.perm?.canArchive !== AccessLevelsEx.Yes && dtd?.perm?.canArchive !== AccessLevelsEx.Mixed ? true : isDisabledForSingleRow(),
504
+ onClick: async () => {
505
+ try {
506
+ const item = selectedDcmtInfos.length === 1 ? selectedDcmtInfos[0] : undefined;
507
+ if (!item?.TID || !item?.DID)
508
+ return;
509
+ TMSpinner.show({ description: SDKUI_Localizator.Loading });
510
+ const getMetadataResult = await SDK_Globals.tmSession?.NewSearchEngine().GetMetadataAsync(item.TID, item.DID, true);
511
+ const dtdFull = getMetadataResult?.dtdResult;
512
+ const rowsFull = dtdFull?.rows ? dtdFull.rows[0] : [];
513
+ const midsFull = getMetadataResult?.selectMIDs;
514
+ const dtdWithMetadata = await DcmtTypeListCacheService.GetWithNotGrantedAsync(item.TID, item.DID, getMetadataResult);
515
+ const allMetadataValues = searchResultToMetadataValues(item.TID, dtdFull, rowsFull, midsFull, dtdWithMetadata?.metadata, LayoutModes.Update);
516
+ const outputMids = allMetadataValues
517
+ ?.filter(md => md.mid && md.mid > 100 && md.value && md.value.length > 0)
518
+ .map(md => ({ mid: md.mid, value: md.value })) || [];
519
+ TMSpinner.hide();
520
+ passToArchiveCallback?.(outputMids, item.TID);
521
+ }
522
+ catch (error) {
523
+ TMSpinner.hide();
524
+ TMExceptionBoxManager.show({ exception: error });
525
+ }
526
+ }
527
+ };
528
+ };
529
+ const refreshDocumentPreview = async () => {
530
+ const currentDcmt = selectedDcmtInfos?.[0];
531
+ if (!currentDcmt)
532
+ return;
533
+ const cacheKey = `${currentDcmt.TID}-${currentDcmt.DID}`;
534
+ if (dcmtsFileCachePreview.has(cacheKey))
535
+ removeDcmtsFileCache(cacheKey);
536
+ await onRefreshPreviewCallback();
537
+ await onRefreshDataRowsAsync?.();
538
+ };
539
+ const pdfEditorMenuItem = (openEditPdfCallback) => {
540
+ // Take the first document (used for validation checks)
541
+ const firstDoc = selectedDcmtInfos?.[0];
542
+ // Check if the selected document is a PDF
543
+ const isPdf = firstDoc?.FILEEXT?.toLowerCase() === "pdf";
544
+ // Check if the document has been signed
545
+ const isSigned = firstDoc?.ISSIGNED === 1;
546
+ // Check if the user has permission to substitute files
547
+ const canSubstitute = dtd?.perm?.canSubstFile === AccessLevels.Yes;
548
+ // Determine whether the menu item should be disabled
549
+ const isDisabled = !canSubstitute || isDisabledForSingleRow() || !isPdf || isSigned;
550
+ return {
551
+ id: 'pdf-ed',
552
+ icon: _jsx(IconEdit, {}),
553
+ name: "PDF Editor",
554
+ operationType: 'singleRow',
555
+ disabled: isDisabled,
556
+ onClick: () => openEditPdfCallback(selectedDcmtInfos, refreshDocumentPreview),
557
+ };
558
+ };
559
+ const handleSignApprove = () => {
560
+ if (!onOpenS4TViewerRequest) {
561
+ ShowAlert({
562
+ message: "Non è stato possibile proseguire con la firma e l'approvazione.",
563
+ mode: "warning",
564
+ duration: 3000,
565
+ title: SDKUI_Localizator.SignatureAndApprove,
566
+ });
567
+ return;
568
+ }
569
+ onOpenS4TViewerRequest(selectedDcmtInfos, refreshDocumentPreview);
570
+ };
571
+ const signatureMenuItem = () => {
572
+ return {
573
+ id: 'sign',
574
+ icon: _jsx(IconSignaturePencil, {}),
575
+ name: SDKUI_Localizator.Signature,
576
+ disabled: isDisabledForSingleRow() && isDisabledForMultiRow(),
577
+ submenu: [
578
+ {
579
+ id: 'sign-do',
580
+ icon: _jsx(IconSignaturePencil, {}),
581
+ operationType: 'singleRow',
582
+ disabled: isDisabledForSingleRow(),
583
+ name: SDKUI_Localizator.Signature,
584
+ onClick: handleSignApprove
585
+ },
586
+ {
587
+ id: 'sign-info',
588
+ icon: _jsx(IconCircleInfo, {}),
589
+ name: SDKUI_Localizator.SignatureInformation,
590
+ operationType: 'singleRow',
591
+ disabled: isDisabledForSingleRow(),
592
+ onClick: () => signatureInformationCallback(isMobile, selectedDcmtInfos)
593
+ },
594
+ {
595
+ id: 'sign-verify',
596
+ icon: _jsx(IconCheckIn, {}),
597
+ name: SDKUI_Localizator.VerifySignature,
598
+ operationType: 'multiRow',
599
+ disabled: isDisabledForMultiRow(),
600
+ onClick: async () => { await runOperationAsync(selectedDcmtInfos, DcmtOperationTypes.VerifySign); }
601
+ },
602
+ ]
603
+ };
604
+ };
605
+ const handleCheckOutOperationCallback = async (checkout) => {
606
+ const firstDoc = selectedDcmtInfos?.[0];
607
+ if (!firstDoc)
608
+ return;
609
+ const onRefreshAsync = async () => {
610
+ await updateCurrentDcmt?.();
611
+ await refreshFocusedDataRowAsync?.(firstDoc.TID, firstDoc.DID, true);
612
+ };
613
+ await handleCheckOutCallback(firstDoc, checkout, dtd?.name ?? SDKUI_Localizator.SearchResult, downloadDcmtsAsync, onRefreshAsync);
614
+ };
615
+ const handleCheckInOperationCallback = async () => {
616
+ const firstDoc = selectedDcmtInfos?.[0];
617
+ if (!firstDoc)
618
+ return;
619
+ firstDoc.fileName = dtd?.name ?? SDKUI_Localizator.SearchResult;
620
+ const onRefreshAsync = async () => {
621
+ await updateCurrentDcmt?.();
622
+ await refreshFocusedDataRowAsync?.(firstDoc.TID, firstDoc.DID, true);
623
+ };
624
+ await handleCheckInCallback(firstDoc, onRefreshAsync);
625
+ };
626
+ const copyCheckoutPathToClipboardOperationCallback = () => {
627
+ const firstDoc = selectedDcmtInfos?.[0];
628
+ if (!firstDoc)
629
+ return;
630
+ copyCheckoutPathToClipboardCallback(firstDoc, dtd?.name ?? SDKUI_Localizator.SearchResult);
631
+ };
632
+ const checkinMenuItem = () => {
633
+ // Take the first document (used for validation checks)
634
+ let dcmt = focusedItem;
635
+ if (isDcmtFormContext) {
636
+ dcmt = dcmtDataRowForCicoStatus;
637
+ }
638
+ const { cicoEnabled, checkoutStatus } = getDcmtCicoStatus(dcmt, allUsers, dtd);
639
+ return {
640
+ id: 'cico',
641
+ icon: _jsx(IconFileDots, {}),
642
+ name: "Check in/Check out",
643
+ disabled: dcmt === undefined || isDisabledForSingleRow(),
644
+ submenu: [
645
+ {
646
+ id: 'co',
647
+ icon: _jsx("span", { style: { fontSize: '18px' }, className: "dx-icon-edit" }),
648
+ name: 'Check out',
649
+ disabled: !cicoEnabled || checkoutStatus.isCheckedOut || isDisabledForSingleRow(),
650
+ onClick: () => handleCheckOutOperationCallback(true),
651
+ },
652
+ {
653
+ id: 'ci',
654
+ icon: _jsx("span", { style: { fontSize: '18px' }, className: "dx-icon-unlock" }),
655
+ name: 'Check in',
656
+ onClick: () => handleCheckInOperationCallback(),
657
+ disabled: !cicoEnabled || !checkoutStatus.isCheckedOut || checkoutStatus.mode === 'lockMode' || isDisabledForSingleRow()
658
+ },
659
+ {
660
+ id: 'co-cancel',
661
+ icon: _jsx("span", { style: { fontSize: '18px' }, className: "dx-icon-remove" }),
662
+ name: SDKUI_Localizator.CancelCheckOut,
663
+ disabled: !cicoEnabled || !checkoutStatus.isCheckedOut || checkoutStatus.mode === 'lockMode' || isDisabledForSingleRow(),
664
+ onClick: () => handleCheckOutOperationCallback(false),
665
+ },
666
+ {
667
+ id: 'co-info',
668
+ icon: _jsx("span", { style: { fontSize: '18px' }, className: "dx-icon-info" }),
669
+ name: SDKUI_Localizator.CheckoutInfo,
670
+ onClick: showCheckoutInformationFormCallback,
671
+ disabled: !checkoutStatus.isCheckedOut || isDisabledForSingleRow()
672
+ },
673
+ {
674
+ id: 'co-path',
675
+ icon: _jsx("span", { style: { fontSize: '18px' }, className: "dx-icon-copy" }),
676
+ name: SDKUI_Localizator.CopyCheckoutPath,
677
+ onClick: copyCheckoutPathToClipboardOperationCallback,
678
+ disabled: !checkoutStatus.isCheckedOut || isDisabledForSingleRow()
679
+ },
680
+ {
681
+ id: 'co-hist',
682
+ icon: _jsx("span", { style: { fontSize: '18px' }, className: "dx-icon-clock" }),
683
+ name: SDKUI_Localizator.History,
684
+ disabled: !cicoEnabled || isDisabledForSingleRow(),
685
+ onClick: showHistoryCallback,
686
+ },
687
+ ]
688
+ };
689
+ };
690
+ const relationsMenuItem = () => {
691
+ return {
692
+ id: 'rel',
693
+ icon: _jsx(IconRelation, {}),
694
+ name: SDKUI_Localizator.Relations,
695
+ operationType: 'multiRow',
696
+ disabled: isDisabledForMultiRow(),
697
+ submenu: [
698
+ {
699
+ id: 'rel-pair',
700
+ icon: _jsx(IconPair, {}),
701
+ name: SDKUI_Localizator.MatchManyDocumentsManyToMany,
702
+ operationType: 'multiRow',
703
+ disabled: !hasManyToManyRelation || isDisabledForMultiRow(),
704
+ onClick: async () => await pairManyToMany(true)
705
+ },
706
+ {
707
+ id: 'rel-unpair',
708
+ icon: _jsx(IconUnpair, {}),
709
+ name: SDKUI_Localizator.UnmatchManyDocumentsManyToMany,
710
+ operationType: 'multiRow',
711
+ disabled: !hasManyToManyRelation || isDisabledForMultiRow(),
712
+ onClick: async () => await pairManyToMany(false)
713
+ },
714
+ {
715
+ id: 'rel-ark-mst',
716
+ icon: _jsx(IconArchiveMaster, {}),
717
+ name: SDKUI_Localizator.ArchiveMasterDocument,
718
+ operationType: 'multiRow',
719
+ beginGroup: true,
720
+ disabled: canArchiveMasterRelation !== true,
721
+ onClick: async () => await archiveMasterDocuments(selectedDcmtInfos?.[0]?.TID)
722
+ },
723
+ {
724
+ id: 'rel-ark-det',
725
+ icon: _jsx(IconArchiveDetail, {}),
726
+ name: SDKUI_Localizator.ArchiveDetailDocument,
727
+ operationType: 'multiRow',
728
+ disabled: canArchiveDetailRelation !== true,
729
+ onClick: async () => await archiveDetailDocuments?.(selectedDcmtInfos?.[0]?.TID)
730
+ },
731
+ {
732
+ id: 'rel-mst',
733
+ icon: _jsx(IconDetailDcmts, { transform: 'scale(-1, 1)' }),
734
+ name: SDKUI_Localizator.DcmtsMaster,
735
+ operationType: 'singleRow',
736
+ visible: true,
737
+ beginGroup: true,
738
+ disabled: !contextConfig.hasMasterRelations || !contextConfig.canShowRelations || isDisabledForMultiRow(),
739
+ onClick: () => openMasterDcmtsFormHandler(true)
740
+ },
741
+ {
742
+ id: 'rel-det',
743
+ icon: _jsx(IconDetailDcmts, {}),
744
+ name: SDKUI_Localizator.DcmtsDetail,
745
+ operationType: 'multiRow',
746
+ disabled: !contextConfig.hasDetailRelations || !contextConfig.canShowRelations || isDisabledForMultiRow(),
747
+ visible: true,
748
+ onClick: () => openDetailDcmtsFormHandler(true)
749
+ }
750
+ ]
751
+ };
752
+ };
753
+ /* const shareMenuItem = (): TMContextMenuItemProps => {
754
+ return {
755
+ icon: <IconShare />,
756
+ name: "Condivisione",
757
+ operationType: 'multiRow',
758
+ disabled: fromDatagrid ? false : isDisabledForMultiRow(),
759
+ submenu: [
760
+ {
761
+ icon: <IconShare />,
762
+ name: "Archiviazione condivisa",
763
+ operationType: 'multiRow',
764
+ disabled: fromDatagrid ? false : isDisabledForMultiRow(),
765
+ onClick: () => ShowAlert({ message: "TODO Archiviazione condivisa", mode: 'info', title: `${"TODO"}`, duration: 3000 })
766
+ },
767
+ {
768
+ icon: <IconSharedDcmt />,
769
+ name: "Documenti condivisi",
770
+ operationType: 'multiRow',
771
+ disabled: fromDatagrid ? false : isDisabledForMultiRow(),
772
+ onClick: () => ShowAlert({ message: "TODO Documenti condivisi", mode: 'info', title: `${"TODO"}`, duration: 3000 })
773
+ }
774
+ ]
775
+ }
776
+ } */
777
+ const sharedDcmtsMenuItem = () => {
778
+ return {
779
+ id: 'shr',
780
+ icon: _jsx(IconSharedDcmt, {}),
781
+ name: SDKUI_Localizator.SharedDocuments,
782
+ operationType: 'multiRow',
783
+ disabled: isDisabledForSingleRow(),
784
+ submenu: [
785
+ {
786
+ id: 'shr-ark',
787
+ icon: _jsx(IconSharedDcmt, {}),
788
+ name: SDKUI_Localizator.SharedArchiving,
789
+ operationType: 'singleRow',
790
+ disabled: isDisabledForSingleRow(),
791
+ onClick: async () => { await openSharedArchiveHandler(); }
792
+ },
793
+ {
794
+ id: 'shr-show',
795
+ icon: _jsx(IconSharedDcmt, {}),
796
+ name: SDKUI_Localizator.ShowSharedDocuments,
797
+ operationType: 'multiRow',
798
+ disabled: isDisabledForSingleRow(),
799
+ onClick: async () => { await showSharedDcmtsHandler(); }
800
+ }
801
+ ]
802
+ };
803
+ };
804
+ const fullTextSearchMenuItem = () => {
805
+ const dcmt = selectedItemsFull?.[0];
806
+ return {
807
+ id: 'ft',
808
+ icon: _jsx(IconSearch, {}),
809
+ name: SDKUI_Localizator.FullTextSearch,
810
+ operationType: 'multiRow',
811
+ disabled: isDisabledForMultiRow(),
812
+ submenu: [
813
+ {
814
+ id: 'ft-info',
815
+ icon: _jsx(IconInfo, {}),
816
+ name: SDKUI_Localizator.IndexingInformation,
817
+ operationType: 'singleRow',
818
+ disabled: isDisabledForSingleRow(),
819
+ onClick: async () => {
820
+ try {
821
+ TMSpinner.show({ description: `${SDKUI_Localizator.Loading}...` });
822
+ const msg = await SDK_Globals.tmSession?.NewSearchEngine().FreeSearchGetDcmtInfoAsync(dcmt.TID, dcmt.DID);
823
+ TMMessageBoxManager.show({ buttons: [ButtonNames.OK], message: msg, title: SDKUI_Localizator.IndexingInformation });
824
+ }
825
+ catch (e) {
826
+ TMExceptionBoxManager.show({ exception: e });
827
+ }
828
+ finally {
829
+ TMSpinner.hide();
830
+ }
831
+ }
832
+ },
833
+ {
834
+ id: 'ft-idx',
835
+ icon: _jsx(IconArchiveDoc, {}),
836
+ name: SDKUI_Localizator.IndexOrReindex,
837
+ operationType: 'multiRow',
838
+ disabled: isDisabledForMultiRow(),
839
+ onClick: async () => { await runOperationAsync(selectedDcmtInfos, DcmtOperationTypes.FreeSearchReindex); }
840
+ },
841
+ {
842
+ id: 'ft-del',
843
+ icon: _jsx(IconDelete, {}),
844
+ name: SDKUI_Localizator.IndexingDelete,
845
+ operationType: 'multiRow',
846
+ disabled: isDisabledForMultiRow(),
847
+ onClick: async () => { await runOperationAsync(selectedDcmtInfos, DcmtOperationTypes.FreeSearchPurge); }
848
+ },
849
+ ...(dcmt?.FTExplanations !== undefined
850
+ ? [{
851
+ id: 'ft-det',
852
+ icon: _jsx(IconPlatform, {}),
853
+ name: SDKUI_Localizator.ResultDetails,
854
+ operationType: 'singleRow',
855
+ disabled: isDisabledForSingleRow(),
856
+ onClick: () => {
857
+ TMMessageBoxManager.show({
858
+ showToppy: false,
859
+ buttons: [ButtonNames.OK],
860
+ message: dcmt?.FTExplanations, title: "Dettagli del risultato"
861
+ });
862
+ }
863
+ }] : []),
864
+ ]
865
+ };
866
+ };
867
+ const otherOperationsMenuItem = () => {
868
+ return {
869
+ id: 'oth',
870
+ icon: _jsx(IconDotsVerticalCircleOutline, {}),
871
+ name: SDKUI_Localizator.Other,
872
+ submenu: [
873
+ {
874
+ id: 'oth-search',
875
+ icon: _jsx(IconSearch, {}),
876
+ name: showSearchTMDatagrid ? SDKUI_Localizator.HideSearch : SDKUI_Localizator.ShowSearch,
877
+ disabled: false,
878
+ onClick: () => setShowSearchTMDatagrid(prev => !prev)
879
+ },
880
+ {
881
+ id: 'oth-exp',
882
+ icon: _jsx(IconExportTo, {}),
883
+ name: SDKUI_Localizator.ExportTo,
884
+ operationType: 'multiRow',
885
+ disabled: false,
886
+ onClick: () => setShowExportForm(true)
887
+ },
888
+ ...(enablePinIcons
889
+ ? [{
890
+ id: 'oth-float',
891
+ icon: showFloatingBar ? _jsx(IconHide, {}) : _jsx(IconShow, {}),
892
+ name: showFloatingBar
893
+ ? SDKUI_Localizator.HideFloatingBar
894
+ : SDKUI_Localizator.ShowFloatingBar,
895
+ disabled: false,
896
+ onClick: () => setShowFloatingBar(prev => !prev)
897
+ }]
898
+ : [])
899
+ ]
900
+ };
901
+ };
902
+ /** MENU SPECIFICO ARCHIVED WORKGROUP */
903
+ const shareFromWgMenuItem = () => {
904
+ return {
905
+ id: 'wg-share',
906
+ icon: _jsx(IconShare, {}),
907
+ name: SDKUI_Localizator.Share,
908
+ visible: workingGroupContext !== undefined && openAddDocumentForm !== undefined,
909
+ disabled: workingGroupContext === undefined,
910
+ onClick: () => openAddDocumentForm && openAddDocumentForm(),
911
+ };
912
+ };
913
+ const copyFromWgMenuItem = () => {
914
+ return {
915
+ id: 'wg-copy',
916
+ icon: _jsx(IconCopy, {}),
917
+ name: SDKUI_Localizator.CopyToDrafts,
918
+ operationType: 'multiRow',
919
+ visible: openWGsCopyMoveForm !== undefined,
920
+ disabled: isDisabledForMultiRow(),
921
+ onClick: () => { (dtd && openWGsCopyMoveForm) && openWGsCopyMoveForm('copyToWgDraft', dtd, selectedDcmtInfos); },
922
+ };
923
+ };
924
+ const movetofolderFromWgMenuItem = () => {
925
+ return {
926
+ id: 'wg-move',
927
+ icon: _jsx(IconMoveToFolder, {}),
928
+ name: !isMobile ? SDKUI_Localizator.CopyToArchivedDocuments : SDKUI_Localizator.CopyToArchived,
929
+ operationType: 'multiRow',
930
+ visible: openWGsCopyMoveForm !== undefined,
931
+ disabled: isDisabledForMultiRow(),
932
+ onClick: () => { (dtd && openWGsCopyMoveForm) && openWGsCopyMoveForm('copyToWgArchivedDoc', dtd, selectedDcmtInfos); },
933
+ };
934
+ };
935
+ const commentFromWgMenuItem = (beginGroup) => {
936
+ return {
937
+ id: 'wg-cmt',
938
+ icon: _jsx("span", { className: "dx-icon-chat" }),
939
+ name: SDKUI_Localizator.Comment,
940
+ operationType: 'multiRow',
941
+ visible: workingGroupContext !== undefined && openCommentFormCallback !== undefined,
942
+ disabled: workingGroupContext === undefined,
943
+ onClick: () => openCommentFormCallback && openCommentFormCallback(selectedDcmtInfos),
944
+ beginGroup: beginGroup,
945
+ };
946
+ };
947
+ const removeFromWgMenuItem = (name) => {
948
+ return {
949
+ id: 'wg-rm',
950
+ icon: _jsx(IconDelete, {}),
951
+ name: name,
952
+ operationType: 'multiRow',
953
+ visible: workingGroupContext !== undefined,
954
+ disabled: workingGroupContext === undefined || isDisabledForMultiRow(),
955
+ onClick: async () => {
956
+ if (workingGroupContext)
957
+ selectedDcmtInfos.forEach(dcmt => dcmt.workingGroupId = workingGroupContext.id);
958
+ await runOperationAsync(selectedDcmtInfos, DcmtOperationTypes.RemoveFromWorkgroup, onRefreshSearchAsyncDatagrid);
959
+ }
960
+ };
961
+ };
962
+ const handleWFOperationCompleted = async () => {
963
+ await onWFOperationCompleted?.();
964
+ if (context !== SearchResultContext.DCMT_FORM && !showMoreInfoPopup) {
965
+ onCloseDcmtForm?.();
966
+ }
967
+ };
968
+ const customButtonMenuItems = () => {
969
+ const customButtonsItems = customButtonsLayout?.customButtons?.filter((customButton) => customButton.isForSearchResult && customButton.isForSearchResult > 0)
970
+ .map((customButton) => ({
971
+ icon: TMImageLibrary({ imageID: customButton.glyphID }),
972
+ name: customButton.title || 'Bottone personalizzato',
973
+ onClick: () => setCurrentCustomButton(customButton)
974
+ }));
975
+ return customButtonsItems && customButtonsItems.length > 0 ? {
976
+ icon: _jsx(IconCustom, {}),
977
+ name: SDKUI_Localizator.CustomButtons,
978
+ submenu: customButtonsItems
979
+ } : {};
980
+ };
981
+ // MENU STANDARD
982
+ const getDefaultMenuItems = () => {
983
+ return [
984
+ {
985
+ id: 'doc',
986
+ icon: _jsx(IconFileDots, {}),
987
+ name: !isMobile ? SDKUI_Localizator.DocumentOperations : SDKUI_Localizator.Documents,
988
+ disabled: isDisabledForSingleRow() && isDisabledForMultiRow(),
989
+ submenu: [
990
+ addToFavoriteOperation(),
991
+ addReplaceFileOperation(),
992
+ openFormOperation(),
993
+ deletetionMenuItem(),
994
+ fileCheckMenuItem(),
995
+ fileConversionsMenuItem(),
996
+ ...(SDK_Globals.tmSession?.SessionDescr?.appModuleID === AppModules.SURFER ? [createContextualTaskMenuItem()] : []),
997
+ downloadFileMenuItem(),
998
+ downloadXMLAttachmentsMenuItem(),
999
+ duplicateDocumentMenuItem(),
1000
+ batchUpdateMenuItem(),
1001
+ passToArchive(),
1002
+ ...(selectedDcmtInfos.length > 0 && isPdfEditorAvailable(dtd, selectedDcmtInfos[0]?.FILEEXT) && onOpenPdfEditorRequest ? [pdfEditorMenuItem(onOpenPdfEditorRequest)] : []),
1003
+ ]
1004
+ },
1005
+ signatureMenuItem(),
1006
+ checkinMenuItem(),
1007
+ allowRelations ? relationsMenuItem() : null,
1008
+ sharedDcmtsMenuItem(),
1009
+ // shareMenuItem(),
1010
+ fullTextSearchMenuItem(),
1011
+ otherOperationsMenuItem(),
1012
+ {
1013
+ id: 'wg',
1014
+ icon: _jsx(IconUserGroupOutline, {}),
1015
+ name: !isMobile ? SDKUI_Localizator.WorkgroupOperations : SDKUI_Localizator.WorkingGroups,
1016
+ operationType: 'multiRow',
1017
+ visible: openWGsCopyMoveForm !== undefined || workingGroupContext !== undefined,
1018
+ disabled: isDisabledForMultiRow(),
1019
+ beginGroup: true,
1020
+ submenu: [
1021
+ shareFromWgMenuItem(),
1022
+ copyFromWgMenuItem(),
1023
+ movetofolderFromWgMenuItem(),
1024
+ commentFromWgMenuItem(true),
1025
+ removeFromWgMenuItem(SDKUI_Localizator.Remove)
1026
+ ]
1027
+ },
1028
+ ];
1029
+ };
1030
+ const getArchivedWorkgroupMenuItems = () => {
1031
+ const items = [
1032
+ addReplaceFileOperation(),
1033
+ openFormOperation(),
1034
+ deletetionMenuItem(),
1035
+ fileConversionsMenuItem(),
1036
+ ...(SDK_Globals.tmSession?.SessionDescr?.appModuleID === AppModules.SURFER ? [createContextualTaskMenuItem()] : []),
1037
+ downloadFileMenuItem(),
1038
+ shareFromWgMenuItem(),
1039
+ copyFromWgMenuItem(),
1040
+ movetofolderFromWgMenuItem(),
1041
+ commentFromWgMenuItem(false),
1042
+ removeFromWgMenuItem(SDKUI_Localizator.RemoveFromWorkgroup),
1043
+ ];
1044
+ return items.sort((a, b) => a.name.localeCompare(b.name));
1045
+ };
1046
+ const getDcmtFormMenuItems = () => {
1047
+ return [
1048
+ {
1049
+ id: 'doc',
1050
+ icon: _jsx(IconCheck, {}),
1051
+ name: !isMobile ? SDKUI_Localizator.DocumentOperations : SDKUI_Localizator.Documents,
1052
+ disabled: isDisabledForSingleRow() && isDisabledForMultiRow(),
1053
+ submenu: [
1054
+ ...(inputDcmtFormLayoutMode === LayoutModes.Update ? [addToFavoriteOperation()] : []),
1055
+ ...((onTaskCreateRequest && inputDcmtFormLayoutMode === LayoutModes.Update && SDK_Globals.tmSession?.SessionDescr?.appModuleID === AppModules.SURFER) ? [createContextualTaskMenuItem()] : []),
1056
+ downloadFileMenuItem(),
1057
+ downloadXMLAttachmentsMenuItem(),
1058
+ ...(selectedDcmtInfos.length > 0 && isPdfEditorAvailable(dtd, selectedDcmtInfos[0]?.FILEEXT) && onOpenPdfEditorRequest ? [pdfEditorMenuItem(onOpenPdfEditorRequest)] : []),
1059
+ ]
1060
+ },
1061
+ signatureMenuItem(),
1062
+ checkinMenuItem(),
1063
+ ...(allowRelations && inputDcmtFormLayoutMode === LayoutModes.Update ? [relationsMenuItem()] : []),
1064
+ ...((inputDcmtFormLayoutMode === LayoutModes.Update) ? [fullTextSearchMenuItem()] : []),
1065
+ ];
1066
+ };
1067
+ const getOperationMenuItems = () => {
1068
+ const getMenuItemsByContext = () => {
1069
+ switch (context) {
1070
+ case SearchResultContext.DCMT_FORM:
1071
+ return getDcmtFormMenuItems();
1072
+ case SearchResultContext.ARCHIVED_WORKGROUP:
1073
+ return getArchivedWorkgroupMenuItems();
1074
+ default:
1075
+ return getDefaultMenuItems();
1076
+ }
1077
+ };
1078
+ const baseMenuItems = getMenuItemsByContext().filter((item) => item !== null);
1079
+ const customButtons = customButtonMenuItems();
1080
+ return customButtons.name ? baseMenuItems.concat([customButtons]) : baseMenuItems;
1081
+ };
1082
+ const operationItems = () => {
1083
+ return addPinIconToItems(getOperationMenuItems());
1084
+ };
1085
+ const renderFloatingBar = (floatingBarContainerRef && floatingBarContainerRef.current && allowFloatingBar && showFloatingBar && deviceType !== DeviceType.MOBILE) ? (_jsx(TMFloatingMenuBar, { containerRef: floatingBarContainerRef, contextMenuItems: operationItems(), isConstrained: true, defaultPosition: { x: 1, y: 88 }, defaultPinnedItems: ['rel-det', 'rel-mst', 'dl'], defaultOrientation: 'horizontal', hasContextMenu: false, pinnedItemIds: pinnedItemIds, onPinChange: setPinnedItemIds })) : null;
1086
+ const renderDcmtOperations = (_jsxs(_Fragment, { children: [(showExportForm && searchResult && dataColumns && dataSource && selectedRowKeys) && (_jsx(TMDataGridExportForm, { dataColumns: dataColumns, dataSource: dataSource, selectedRowKeys: selectedRowKeys, onCloseExportForm: () => setShowExportForm(false), searchResult: searchResult })), _jsx(StyledMultiViewPanel, { "$isVisible": isOpenDcmtForm, children: ((isOpenDcmtForm && focusedItem?.TID !== undefined && focusedItem?.DID !== undefined) &&
1087
+ _jsx(TMDcmtForm, { isModal: openDcmtFormAsModal || (dcmtFormLayoutMode === LayoutModes.Ark && focusedItem?.DID !== undefined), titleModal: dtd?.name ?? '', TID: focusedItem.TID, DID: focusedItem.DID, allowButtonsRefs: true, layoutMode: dcmtFormLayoutMode, count: visibleItems?.length, itemIndex: visibleItems ? visibleItems.findIndex(o => o.rowIndex === focusedItem?.rowIndex) + 1 : undefined, canNext: canNavigateHandler ? canNavigateHandler('next') : false, canPrev: canNavigateHandler ? canNavigateHandler('prev') : false, onNext: () => onNavigateHandler && onNavigateHandler('next'), onPrev: () => onNavigateHandler && onNavigateHandler('prev'), onClose: () => { setIsOpenDcmtForm(false); onDcmtFormOpenChange(false, LayoutModes.Update); }, onWFOperationCompleted: onWFOperationCompleted, onTaskCreateRequest: onTaskCreateRequest, onSavedAsyncCallback: onSavedAsyncCallback, openS4TViewer: openS4TViewer, onOpenS4TViewerRequest: onOpenS4TViewerRequest, onOpenPdfEditorRequest: onOpenPdfEditorRequest, onReferenceClick: onReferenceClick, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers, moreInfoTasks: getMoreInfoTasksForDocument(allTasks, focusedItem?.TID, focusedItem?.DID), showDcmtFormSidebar: showDcmtFormSidebar, datagridUtility: {
1088
+ onRefreshSearchAsyncDatagrid,
1089
+ onRefreshDataRowsAsync,
1090
+ refreshFocusedDataRowAsync,
1091
+ onRefreshBlogDatagrid,
1092
+ onRefreshPreviewDatagrid
1093
+ } })) }), (showHistory && dtd && selectedDcmtInfos.length > 0) && _jsx(TMViewHistoryDcmt, { fromDTD: dtd, deviceType: deviceType, inputDcmt: selectedDcmtInfos[0], onClose: hideHistoryCallback, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), (commentFormState.show && selectedDcmtInfos.length > 0) && _jsx(TMBlogCommentForm, { context: { engine: 'SearchEngine', object: { tid: selectedDcmtInfos[0].TID, did: selectedDcmtInfos[0].DID } }, onClose: hideCommentFormCallback, refreshCallback: onRefreshBlog, participants: [], showAttachmentsSection: true, allArchivedDocumentsFileItems: convertSearchResultDescriptorToFileItems(currentSearchResults ?? []), isCommentRequired: commentFormState.isRequired, removeAndEditAttachment: commentFormState.removeAndEditAttachment, selectedAttachmentDid: [Number(selectedDcmtInfos[0].DID)] }), (showCheckoutInformationForm && dtd && selectedDcmtInfos.length > 0) &&
1094
+ _jsx(TMDcmtCheckoutInfoForm, { dtdName: dtd.name ?? SDKUI_Localizator.SearchResult, selectedDcmtOrFocused: selectedDcmtInfos[0], onClose: hideCheckoutInformationFormCallback }), _jsx(StyledMultiViewPanel, { "$isVisible": isOpenDetails, children: isOpenDetails && _jsx(TMMasterDetailDcmts, { deviceType: deviceType, isForMaster: false, inputDcmts: selectedDcmtInfos, allowNavigation: selectedDcmtInfos.length === 1, canNext: canNavigateHandler ? canNavigateHandler('next') : false, canPrev: canNavigateHandler ? canNavigateHandler('prev') : false, onNext: () => onNavigateHandler && onNavigateHandler('next'), onPrev: () => onNavigateHandler && onNavigateHandler('prev'), onBack: () => setIsOpenDetails(false), allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }), _jsxs(StyledMultiViewPanel, { "$isVisible": isOpenMaster, children: [isOpenMaster && _jsx(TMMasterDetailDcmts, { deviceType: deviceType, inputDcmts: selectedDcmtInfos, isForMaster: true, allowNavigation: selectedDcmtInfos.length === 1, canNext: canNavigateHandler ? canNavigateHandler('next') : false, canPrev: canNavigateHandler ? canNavigateHandler('prev') : false, onNext: () => onNavigateHandler && onNavigateHandler('next'), onPrev: () => onNavigateHandler && onNavigateHandler('prev'), onBack: () => setIsOpenMaster(false), appendMasterDcmts: handleAddItem, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), secondaryMasterDcmts.length > 0 && secondaryMasterDcmts.map((dcmt, index) => {
1095
+ return (_jsx(StyledModalContainer, { style: { backgroundColor: 'white' }, children: _jsx(TMMasterDetailDcmts, { deviceType: deviceType, inputDcmts: [dcmt], isForMaster: true, allowNavigation: false, onBack: () => handleRemoveItem(dcmt.TID, dcmt.DID), appendMasterDcmts: handleAddItem, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }, `${index}-${dcmt.DID}`));
1096
+ })] }), isOpenArchiveRelationForm && _jsx(TMDcmtForm, { isModal: true, titleModal: SDKUI_Localizator.Archive + ' - ' + (archiveType === 'detail' ? SDKUI_Localizator.DcmtsDetail : SDKUI_Localizator.DcmtsMaster), TID: archiveRelatedDcmtFormTID, layoutMode: LayoutModes.Ark, inputMids: archiveRelatedDcmtFormMids, showBackButton: false, allowButtonsRefs: false, onClose: () => {
1097
+ setIsOpenArchiveRelationForm(false);
1098
+ setArchiveType(undefined);
1099
+ setArchiveRelatedDcmtFormTID(undefined);
1100
+ setArchiveRelatedDcmtFormMids([]);
1101
+ }, onSavedAsyncCallback: async (tid, did, metadataResult) => {
1102
+ setIsOpenArchiveRelationForm(false);
1103
+ setArchiveType(undefined);
1104
+ setArchiveRelatedDcmtFormTID(undefined);
1105
+ setArchiveRelatedDcmtFormMids([]);
1106
+ await onRefreshSearchAsyncDatagrid?.();
1107
+ }, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers, showDcmtFormSidebar: showDcmtFormSidebar }), showRelatedDcmtsChooser &&
1108
+ _jsx(TMChooserForm, { dataSource: relatedDcmtsChooserDataSource, onChoose: async (selectedRelation) => {
1109
+ try {
1110
+ setShowRelatedDcmtsChooser(false);
1111
+ TMSpinner.show({ description: SDKUI_Localizator.Loading });
1112
+ const relation = relatedDcmts?.find(r => r.id === selectedRelation[0]);
1113
+ if (!relation || !archiveType)
1114
+ return;
1115
+ await archiveRelatedDcmtHandler(relation, archiveType);
1116
+ }
1117
+ catch (error) {
1118
+ TMExceptionBoxManager.show({ exception: error });
1119
+ }
1120
+ finally {
1121
+ TMSpinner.hide();
1122
+ }
1123
+ }, onClose: () => setShowRelatedDcmtsChooser(false), manageUseLocalizedName: false }), showManyToManyChooser &&
1124
+ _jsx(TMChooserForm, { dataSource: manyToManyChooserDataSource, onChoose: async (selectedRelation) => {
1125
+ try {
1126
+ setShowManyToManyChooser(false);
1127
+ TMSpinner.show({ description: SDKUI_Localizator.Loading });
1128
+ const relation = manyToManyRelations?.find(r => r.id === selectedRelation[0]);
1129
+ if (!relation)
1130
+ return;
1131
+ await executeManyToManyPairing(relation, isPairingManyToMany);
1132
+ }
1133
+ catch (error) {
1134
+ TMExceptionBoxManager.show({ exception: error });
1135
+ }
1136
+ finally {
1137
+ TMSpinner.hide();
1138
+ }
1139
+ }, onClose: () => setShowManyToManyChooser(false), manageUseLocalizedName: false }), showPairDcmtsModal &&
1140
+ _jsx(TMModal, { title: (isPairingManyToMany ? "Abbina" : "Disabbina") + " documenti", onClose: () => setShowPairDcmtsModal(false), width: isMobile ? '90%' : '50%', height: isMobile ? '90%' : '70%', children: _jsx(TMSearchResult, { searchResults: pairedSearchResults, onRefreshAfterAddDcmtToFavs: onRefreshAfterAddDcmtToFavs, onRefreshSearchAsyncDatagrid: onRefreshSearchAsyncDatagrid, onFileOpened: onFileOpened, onTaskCreateRequest: onTaskCreateRequest, openWGsCopyMoveForm: openWGsCopyMoveForm, editPdfForm: editPdfForm, openS4TViewer: openS4TViewer, onOpenS4TViewerRequest: onOpenS4TViewerRequest, onOpenPdfEditorRequest: onOpenPdfEditorRequest, passToArchiveCallback: passToArchiveCallback, showTodoDcmtForm: showTodoDcmtForm, allowFloatingBar: false, floatingActionConfig: pairFloatingActionConfig, showBackButton: false, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers, toppyHelpCenterUsePortal: toppyHelpCenterUsePortal, showToppyDraggableHelpCenter: showToppyDraggableHelpCenter }) }), showPairSearchModal &&
1141
+ _jsx(TMModal, { title: "Ricerca documenti", onClose: () => setShowPairSearchModal(false), width: isMobile ? '90%' : '50%', height: isMobile ? '90%' : '70%', children: _jsx(TMSearch, { onlyShowSearchQueryPanel: true, inputTID: pairSearchModalTargetTID, inputMids: pairSearchModalInputMids, floatingActionConfig: pairSearchModalFloatingActionConfig, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }), isOpenSharedArchive && _jsx(TMModal, { title: "Archiviazione condivisa", onClose: () => {
1142
+ setIsOpenSharedArchive(false);
1143
+ }, width: isMobile ? '90%' : '60%', height: isMobile ? '90%' : '80%', children: _jsx(TMArchive, { inputDID: selectedDcmtInfos?.[0].DID, inputTID: selectedDcmtInfos?.[0].TID, inputMids: currentMetadataValues.filter(md => md.mid && md.mid > 100).map(md => ({ mid: md.mid, value: md.value ?? '' })), isSharedArchive: true, inputFile: sharedDcmtFile, onSavedAsyncCallback: async (tid, did) => {
1144
+ setIsOpenSharedArchive(false);
1145
+ await onRefreshSearchAsyncDatagrid?.();
1146
+ }, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }), sharedDcmtSearchResults.length > 0 &&
1147
+ _jsx(TMModal, { title: "Documenti condivisi", onClose: () => {
1148
+ setSharedDcmtSearchResults([]);
1149
+ }, width: isMobile ? '90%' : '60%', height: isMobile ? '90%' : '80%', children: _jsx(TMSearchResult, { searchResults: sharedDcmtSearchResults, allowFloatingBar: false, showSelector: true, disableAccordionIfSingleCategory: true, showBackButton: isMobile, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }), isOpenBatchUpdate && _jsx(TMBatchUpdateForm, { isModal: true, titleModal: `${SDKUI_Localizator.BatchUpdate} (${selectedDcmtInfos.length} documenti selezionati)`, inputDcmts: selectedDcmtInfos, TID: selectedDcmtInfos.length > 0 ? selectedDcmtInfos[0]?.TID : undefined, DID: selectedDcmtInfos.length > 0 ? selectedDcmtInfos[0]?.DID : undefined, onBack: () => updateBatchUpdateForm(false), onSavedCallbackAsync: async () => {
1150
+ updateBatchUpdateForm(false);
1151
+ setIsModifiedBatchUpdate(false);
1152
+ await onRefreshDataRowsAsync?.();
1153
+ }, onStatusChanged: (isModified) => { setIsModifiedBatchUpdate(isModified); } }), showApprovePopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, selectedItems: selectedDcmtInfos, isReject: 0, onClose: () => updateShowApprovePopup(false) }), showRejectPopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, selectedItems: selectedDcmtInfos, isReject: 1, onClose: () => updateShowRejectPopup(false) }), showReAssignPopup && _jsx(WorkFlowReAssignPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, selectedItems: selectedDcmtInfos, onClose: () => updateShowReAssignPopup(false) }), showMoreInfoPopup && _jsx(WorkFlowMoreInfoPopUp, { fromDTD: dtd, TID: contextConfig.approvalTID, DID: focusedItem?.DID, deviceType: deviceType, onCompleted: handleWFOperationCompleted, onClose: () => updateShowMoreInfoPopup(false), allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers, triggerBlogRefresh: onRefreshBlogDatagrid }), _jsx(ConfirmFormatDialog, {}), _jsx(ConfirmAttachmentsDialog, {}), taskFormDialogComponent, s4TViewerDialogComponent, currentCustomButton && _jsx(TMCustomButton, { button: currentCustomButton, formData: currentMetadataValues, selectedItems: selectedItemsFull, onClose: () => setCurrentCustomButton(undefined) })] }));
1154
+ return {
1155
+ operationItems: operationItems(),
1156
+ renderFloatingBar,
1157
+ renderDcmtOperations,
1158
+ features: {
1159
+ isOpenDcmtForm,
1160
+ openFormHandler,
1161
+ dcmtFormLayoutMode,
1162
+ onDcmtFormOpenChange,
1163
+ showSearchTMDatagrid,
1164
+ showExportForm,
1165
+ isOpenBatchUpdate,
1166
+ isModifiedBatchUpdate,
1167
+ updateBatchUpdateForm,
1168
+ handleSignApprove,
1169
+ checkoutInfo: {
1170
+ showHistory,
1171
+ showHistoryCallback,
1172
+ hideHistoryCallback,
1173
+ showCheckoutInformationForm,
1174
+ showCheckoutInformationFormCallback,
1175
+ hideCheckoutInformationFormCallback,
1176
+ commentFormState,
1177
+ hideCommentFormCallback,
1178
+ copyCheckoutPathToClipboardCallback,
1179
+ handleCheckOutCallback,
1180
+ handleCheckInCallback,
1181
+ showCicoWaitPanel,
1182
+ cicoWaitPanelTitle,
1183
+ showCicoPrimaryProgress,
1184
+ cicoPrimaryProgressText,
1185
+ cicoPrimaryProgressValue,
1186
+ cicoPrimaryProgressMax,
1187
+ },
1188
+ dcmtOperations: {
1189
+ abortController,
1190
+ showWaitPanel,
1191
+ showPrimary,
1192
+ waitPanelTitle,
1193
+ waitPanelTextPrimary,
1194
+ waitPanelValuePrimary,
1195
+ waitPanelMaxValuePrimary,
1196
+ showSecondary,
1197
+ waitPanelTextSecondary,
1198
+ waitPanelValueSecondary,
1199
+ waitPanelMaxValueSecondary,
1200
+ downloadDcmtsAsync,
1201
+ getDcmtFileAsync,
1202
+ clearDcmtsFileCache,
1203
+ removeDcmtsFileCache,
1204
+ isDcmtFileInCache,
1205
+ runOperationAsync,
1206
+ },
1207
+ relatedDocumentsInfo: {
1208
+ // Data
1209
+ relatedDcmts,
1210
+ pairedSearchResults,
1211
+ manyToManyRelations,
1212
+ selectedManyToManyRelation,
1213
+ manyToManyChooserDataSource,
1214
+ relatedDcmtsChooserDataSource,
1215
+ // Flags / State booleans
1216
+ showRelatedDcmtsChooser,
1217
+ isOpenDetails,
1218
+ isOpenMaster,
1219
+ isOpenArchiveRelationForm,
1220
+ isPairingManyToMany,
1221
+ showManyToManyChooser,
1222
+ showPairSearchModal,
1223
+ currentTIDHasDetailRelations,
1224
+ currentTIDHasMasterRelations,
1225
+ canArchiveMasterRelation,
1226
+ canArchiveDetailRelation,
1227
+ hasManyToManyRelation,
1228
+ showPairDcmtsModal,
1229
+ // Pair search modal state
1230
+ pairSearchModalTargetTID,
1231
+ pairSearchModalParentTID,
1232
+ pairSearchModalParentDID,
1233
+ pairSearchModalRelation,
1234
+ pairSearchModalInputMids,
1235
+ // Config
1236
+ pairFloatingActionConfig,
1237
+ pairSearchModalFloatingActionConfig,
1238
+ // Archive state
1239
+ archiveRelatedDcmtFormTID,
1240
+ archiveRelatedDcmtFormMids,
1241
+ archiveType,
1242
+ // Setters
1243
+ setIsOpenDetails,
1244
+ setIsOpenMaster,
1245
+ setShowRelatedDcmtsChooser,
1246
+ setIsOpenArchiveRelationForm,
1247
+ setArchiveType,
1248
+ setArchiveRelatedDcmtFormTID,
1249
+ setArchiveRelatedDcmtFormMids,
1250
+ setShowManyToManyChooser,
1251
+ setShowPairDcmtsModal,
1252
+ setShowPairSearchModal,
1253
+ // Logic / Helpers
1254
+ checkRelatedDcmtsArchiveCapability,
1255
+ checkManyToManyCapability,
1256
+ // Actions
1257
+ pairManyToMany,
1258
+ executeManyToManyPairing,
1259
+ archiveDetailDocuments,
1260
+ archiveMasterDocuments,
1261
+ archiveRelatedDcmtHandler
1262
+ },
1263
+ toppyOperations: {
1264
+ showApprovePopup,
1265
+ showRejectPopup,
1266
+ showReAssignPopup,
1267
+ showMoreInfoPopup,
1268
+ updateShowApprovePopup,
1269
+ updateShowRejectPopup,
1270
+ updateShowReAssignPopup,
1271
+ updateShowMoreInfoPopup
1272
+ }
1273
+ }
1274
+ };
1275
+ };