@topconsultnpm/sdkui-react 6.20.0 → 6.21.0-dev1.10

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