@topconsultnpm/sdkui-react 6.19.0-dev2.5 → 6.19.0-dev2.50

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 (94) hide show
  1. package/lib/components/base/TMButton.d.ts +1 -0
  2. package/lib/components/base/TMButton.js +6 -6
  3. package/lib/components/base/TMCustomButton.d.ts +1 -1
  4. package/lib/components/base/TMCustomButton.js +83 -28
  5. package/lib/components/base/TMDataGridExportForm.d.ts +1 -1
  6. package/lib/components/base/TMDataGridExportForm.js +9 -3
  7. package/lib/components/base/TMFileManager.js +12 -3
  8. package/lib/components/base/TMFileManagerDataGridView.d.ts +2 -0
  9. package/lib/components/base/TMFileManagerDataGridView.js +12 -3
  10. package/lib/components/base/TMFileManagerThumbnailItems.d.ts +2 -0
  11. package/lib/components/base/TMFileManagerThumbnailItems.js +12 -2
  12. package/lib/components/base/TMFileManagerThumbnailsView.d.ts +2 -0
  13. package/lib/components/base/TMFileManagerThumbnailsView.js +2 -2
  14. package/lib/components/base/TMModal.d.ts +2 -0
  15. package/lib/components/base/TMModal.js +13 -2
  16. package/lib/components/base/TMTooltip.d.ts +1 -1
  17. package/lib/components/base/TMTooltip.js +1 -1
  18. package/lib/components/base/TMWaitPanel.js +8 -2
  19. package/lib/components/choosers/TMDcmtTypeChooser.js +2 -2
  20. package/lib/components/choosers/TMMetadataChooser.d.ts +4 -1
  21. package/lib/components/choosers/TMMetadataChooser.js +31 -8
  22. package/lib/components/choosers/TMUserChooser.d.ts +4 -0
  23. package/lib/components/choosers/TMUserChooser.js +21 -5
  24. package/lib/components/editors/TMDateBox.d.ts +1 -1
  25. package/lib/components/editors/TMTextArea.d.ts +1 -0
  26. package/lib/components/editors/TMTextArea.js +43 -9
  27. package/lib/components/editors/TMTextBox.js +33 -3
  28. package/lib/components/editors/TMTextExpression.js +36 -28
  29. package/lib/components/features/assistant/ToppyDraggableHelpCenter.d.ts +28 -0
  30. package/lib/components/features/assistant/ToppyDraggableHelpCenter.js +324 -0
  31. package/lib/components/features/assistant/ToppyHelpCenter.js +1 -1
  32. package/lib/components/features/assistant/ToppySpeechBubble.d.ts +8 -0
  33. package/lib/components/features/assistant/ToppySpeechBubble.js +53 -0
  34. package/lib/components/features/blog/TMBlogCommentForm.d.ts +2 -0
  35. package/lib/components/features/blog/TMBlogCommentForm.js +18 -6
  36. package/lib/components/features/documents/TMDcmtBlog.js +1 -1
  37. package/lib/components/features/documents/TMDcmtForm.js +313 -57
  38. package/lib/components/features/documents/TMDcmtPreview.js +45 -8
  39. package/lib/components/features/documents/TMRelationViewer.js +56 -23
  40. package/lib/components/features/search/TMSavedQuerySelector.js +1 -1
  41. package/lib/components/features/search/TMSearch.js +2 -2
  42. package/lib/components/features/search/TMSearchQueryEditor.js +1 -1
  43. package/lib/components/features/search/TMSearchQueryPanel.js +8 -25
  44. package/lib/components/features/search/TMSearchResult.js +94 -13
  45. package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +2 -1
  46. package/lib/components/features/search/TMSearchResultsMenuItems.js +97 -51
  47. package/lib/components/features/tasks/TMTaskForm.js +11 -5
  48. package/lib/components/features/tasks/TMTasksAgenda.js +4 -4
  49. package/lib/components/features/tasks/TMTasksCalendar.js +2 -2
  50. package/lib/components/features/tasks/TMTasksHeader.js +1 -1
  51. package/lib/components/features/tasks/TMTasksUtils.d.ts +2 -1
  52. package/lib/components/features/tasks/TMTasksUtils.js +18 -3
  53. package/lib/components/features/tasks/TMTasksUtilsView.js +26 -4
  54. package/lib/components/features/tasks/TMTasksView.js +12 -6
  55. package/lib/components/features/workflow/TMWorkflowPopup.js +3 -3
  56. package/lib/components/features/workflow/diagram/DiagramItemForm.js +8 -3
  57. package/lib/components/forms/TMResultDialog.js +8 -2
  58. package/lib/components/forms/TMSaveForm.js +2 -2
  59. package/lib/components/grids/TMBlogsPost.d.ts +8 -3
  60. package/lib/components/grids/TMBlogsPost.js +73 -11
  61. package/lib/components/grids/TMBlogsPostUtils.d.ts +1 -0
  62. package/lib/components/grids/TMBlogsPostUtils.js +15 -3
  63. package/lib/components/grids/TMRecentsManager.js +1 -1
  64. package/lib/components/index.d.ts +2 -1
  65. package/lib/components/index.js +2 -1
  66. package/lib/components/layout/panelManager/TMPanelManagerContainer.d.ts +1 -0
  67. package/lib/components/layout/panelManager/TMPanelManagerContainer.js +2 -2
  68. package/lib/components/layout/panelManager/TMPanelManagerContext.js +0 -1
  69. package/lib/components/layout/panelManager/TMPanelManagerToolbar.js +2 -1
  70. package/lib/components/layout/panelManager/types.d.ts +1 -0
  71. package/lib/components/pages/TMPage.js +1 -1
  72. package/lib/components/settings/SettingsAppearance.js +5 -5
  73. package/lib/components/viewers/TMDataListItemViewer.d.ts +1 -1
  74. package/lib/components/viewers/TMMidViewer.d.ts +1 -1
  75. package/lib/components/viewers/TMTidViewer.d.ts +1 -1
  76. package/lib/helper/GlobalStyles.d.ts +2 -0
  77. package/lib/helper/GlobalStyles.js +10 -0
  78. package/lib/helper/Globalization.d.ts +1 -0
  79. package/lib/helper/Globalization.js +30 -0
  80. package/lib/helper/SDKUI_Localizator.d.ts +39 -2
  81. package/lib/helper/SDKUI_Localizator.js +392 -22
  82. package/lib/helper/TMCustomSearchBar.js +1 -1
  83. package/lib/helper/TMIcons.d.ts +4 -1
  84. package/lib/helper/TMIcons.js +13 -1
  85. package/lib/helper/TMUtils.d.ts +1 -4
  86. package/lib/helper/TMUtils.js +18 -23
  87. package/lib/helper/dcmtsHelper.d.ts +2 -1
  88. package/lib/helper/dcmtsHelper.js +56 -17
  89. package/lib/helper/helpers.js +5 -1
  90. package/lib/helper/index.d.ts +1 -0
  91. package/lib/helper/index.js +1 -0
  92. package/lib/hooks/useRelatedDocuments.js +35 -26
  93. package/lib/ts/types.d.ts +3 -1
  94. package/package.json +8 -8
@@ -4,11 +4,12 @@ import TMDcmtPreview from './TMDcmtPreview';
4
4
  import { AccessLevels, ArchiveConstraints, ArchiveEngineByID, DcmtTypeListCacheService, LayoutCacheService, LayoutModes, MetadataDataTypes, ObjectClasses, ResultTypes, SDK_Globals, SDK_Localizator, SystemMIDsAsNumber, SystemTIDs, Task_States, TemplateTIDs, TID_DID, UpdateEngineByID, ValidationItem, WorkflowCacheService, WorkItemMetadataNames } from '@topconsultnpm/sdk-ts';
5
5
  import { ContextMenu } from 'devextreme-react';
6
6
  import { WorkFlowApproveRejectPopUp, WorkFlowMoreInfoPopUp, WorkFlowOperationButtons, WorkFlowReAssignPopUp } from '../workflow/TMWorkflowPopup';
7
- import { DownloadTypes, FormModes } from '../../../ts';
7
+ import { DownloadTypes, FormModes, DcmtOperationTypes } from '../../../ts';
8
8
  import { DeviceType, useDeviceType } from '../../base/TMDeviceProvider';
9
9
  import { useDcmtOperations } from '../../../hooks/useDcmtOperations';
10
+ import { useRelatedDocuments } from '../../../hooks/useRelatedDocuments';
10
11
  import { getWorkItemSetIDAsync, handleArchiveVisibility, searchResultToMetadataValues } from '../../../helper/queryHelper';
11
- import { genUniqueId, IconShow, SDKUI_Localizator, updateMruTids, IconBoard, IconDcmtTypeSys, IconDetailDcmts, svgToString, IconDownload, calcIsModified, IconMenuVertical, Globalization, getListMaxItems, getSystemMetadata, IconBoxArchiveIn, IconClear, IconUndo, SDKUI_Globals, IconPreview, isTaskMoreInfo, IconWorkflow, IconSearch, deepCompare, IconCheck, IconActivity } from '../../../helper';
12
+ import { genUniqueId, IconShow, SDKUI_Localizator, updateMruTids, IconBoard, IconDcmtTypeSys, IconDetailDcmts, svgToString, IconDownload, calcIsModified, IconMenuVertical, Globalization, getListMaxItems, getSystemMetadata, IconBoxArchiveIn, IconClear, IconUndo, SDKUI_Globals, IconPreview, isTaskMoreInfo, IconWorkflow, IconSearch, deepCompare, IconCheck, IconActivity, TMImageLibrary, IconStar, IconRelation, IconInfo, IconArchiveDoc, IconDelete, IconPair, IconUnpair, IconArchiveMaster, IconArchiveDetail } from '../../../helper';
12
13
  import { hasDetailRelations, hasMasterRelations, isXMLFileExt } from '../../../helper/dcmtsHelper';
13
14
  import { Gutters, TMColors } from '../../../utils/theme';
14
15
  import { StyledFormButtonsContainer, StyledLoadingContainer, StyledModalContainer, StyledReferenceButton, StyledSpinner, StyledToolbarCardContainer } from '../../base/Styled';
@@ -27,11 +28,12 @@ import TMMasterDetailDcmts from './TMMasterDetailDcmts';
27
28
  import TMDcmtBlog from './TMDcmtBlog';
28
29
  import { useInputAttachmentsDialog } from '../../../hooks/useInputDialog';
29
30
  import TMModal from '../../base/TMModal';
31
+ import TMChooserForm from '../../forms/TMChooserForm';
32
+ import TMSearchResult from '../search/TMSearchResult';
30
33
  import { useTMPanelManagerContext } from '../../layout/panelManager/TMPanelManagerContext';
31
34
  import TMPanelManagerContainer from '../../layout/panelManager/TMPanelManagerContainer';
32
35
  import { TMPanelManagerWithPersistenceProvider } from '../../layout/panelManager/TMPanelManagerWithPersistenceProvider';
33
36
  import { useWorkflowApprove } from '../../../hooks/useWorkflowApprove';
34
- import ToppyHelpCenter from '../assistant/ToppyHelpCenter';
35
37
  import TMBlogCommentForm from '../blog/TMBlogCommentForm';
36
38
  import WFDiagram from '../workflow/diagram/WFDiagram';
37
39
  import TMTooltip from '../../base/TMTooltip';
@@ -39,9 +41,10 @@ import TMDcmtTasks from './TMDcmtTasks';
39
41
  import TMToppyMessage from '../../../helper/TMToppyMessage';
40
42
  import { getTaskAssignedToMe } from '../tasks/TMTasksUtils';
41
43
  import TMCustomButton from '../../base/TMCustomButton';
44
+ import ToppyDraggableHelpCenter from '../assistant/ToppyDraggableHelpCenter';
42
45
  let abortControllerLocal = new AbortController();
43
46
  //#endregion
44
- const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTaskCallback, editTaskCallback, handleNavigateToWGs, handleNavigateToDossiers, showHeader = true, onSaveRecents, layoutMode = LayoutModes.Update, showBackButton = true, onClose, onSavedAsyncCallback, TID, DID, formMode = FormModes.Update, canNext, canPrev, count, itemIndex, onNext, onPrev, allowNavigation = true, allowRelations = true, isClosable = false, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, showDcmtFormSidebar = true, invokedByTodo = false, titleModal, isModal = false, widthModal = "100%", heightModal = "100%", groupId, onWFOperationCompleted, onTaskCompleted, inputFile = null, taskFormDialogComponent, taskMoreInfo, connectorFileSave = undefined, inputMids = [], onOpenS4TViewerRequest, s4TViewerDialogComponent, enableDragDropOverlay = false, passToSearch, isSharedDcmt = false, sharedSourceTID, sharedSourceDID, allowButtonsRefs = false, onReferenceClick, }) => {
47
+ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTaskCallback, editTaskCallback, handleNavigateToWGs, handleNavigateToDossiers, showHeader = true, onSaveRecents, layoutMode = LayoutModes.Update, showBackButton = true, onClose, onSavedAsyncCallback, TID, DID, formMode = FormModes.Update, canNext, canPrev, count, itemIndex, onNext, onPrev, allowNavigation = true, allowRelations = true, isClosable = false, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, showDcmtFormSidebar = true, invokedByTodo = false, titleModal, isModal = false, widthModal = "100%", heightModal = "100%", groupId, onWFOperationCompleted, onTaskCompleted, onTaskCreateRequest, inputFile = null, taskFormDialogComponent, taskMoreInfo, connectorFileSave = undefined, inputMids = [], onOpenS4TViewerRequest, s4TViewerDialogComponent, enableDragDropOverlay = false, passToSearch, isSharedDcmt = false, sharedSourceTID, sharedSourceDID, allowButtonsRefs = false, onReferenceClick, }) => {
45
48
  const [id, setID] = useState('');
46
49
  const [showWaitPanelLocal, setShowWaitPanelLocal] = useState(false);
47
50
  const [waitPanelTitleLocal, setWaitPanelTitleLocal] = useState('');
@@ -102,10 +105,44 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
102
105
  setDcmtReferences(undefined);
103
106
  }, [allowButtonsRefs]);
104
107
  const { openConfirmAttachmentsDialog, ConfirmAttachmentsDialog } = useInputAttachmentsDialog();
105
- const { abortController, showWaitPanel, waitPanelTitle, showPrimary, waitPanelTextPrimary, waitPanelValuePrimary, waitPanelMaxValuePrimary, showSecondary, waitPanelTextSecondary, waitPanelValueSecondary, waitPanelMaxValueSecondary, downloadDcmtsAsync } = useDcmtOperations();
106
- // Custom hook to manage workflow approval data
108
+ const { abortController, showWaitPanel, waitPanelTitle, showPrimary, waitPanelTextPrimary, waitPanelValuePrimary, waitPanelMaxValuePrimary, showSecondary, waitPanelTextSecondary, waitPanelValueSecondary, waitPanelMaxValueSecondary, downloadDcmtsAsync, runOperationAsync } = useDcmtOperations();
107
109
  const { workflowApproveData } = useWorkflowApprove();
110
+ const currentSearchResults = useMemo(() => {
111
+ if (!formData || formData.length === 0 || !TID || !DID)
112
+ return [];
113
+ const selectMIDs = [];
114
+ const rowValues = [];
115
+ formData.forEach(md => {
116
+ if (md.mid !== undefined) {
117
+ selectMIDs.push(md.mid);
118
+ rowValues.push(md.value);
119
+ }
120
+ });
121
+ const searchResult = {
122
+ fromTID: TID,
123
+ selectMIDs: selectMIDs,
124
+ dtdResult: {
125
+ rows: [rowValues],
126
+ columns: selectMIDs.map(mid => ({ name: `MID_${mid}` }))
127
+ },
128
+ dcmtsFound: 1,
129
+ dcmtsReturned: 1
130
+ };
131
+ return [searchResult];
132
+ }, [formData, TID, DID]);
133
+ const relatedDocuments = useRelatedDocuments({
134
+ selectedSearchResult: TID ? { fromTID: Number(TID) } : undefined,
135
+ focusedItem: currentDcmt ? { TID: currentDcmt.tid, DID: currentDcmt.did, rowIndex: 0 } : undefined,
136
+ currentSearchResults: currentSearchResults
137
+ });
138
+ const { relatedDcmts, showRelatedDcmtsChooser, archiveType, isOpenArchiveRelationForm, archiveRelatedDcmtFormTID, archiveRelatedDcmtFormMids, relatedDcmtsChooserDataSource, showManyToManyChooser, manyToManyChooserDataSource, manyToManyRelations, isPairingManyToMany, showPairDcmtsModal, pairedSearchResults, pairFloatingActionConfig, hasManyToManyRelation, canArchiveMasterRelation, canArchiveDetailRelation, pairManyToMany, archiveMasterDocuments, archiveDetailDocuments, checkRelatedDcmtsArchiveCapability, checkManyToManyCapability, setShowRelatedDcmtsChooser, setShowManyToManyChooser, setShowPairDcmtsModal, setIsOpenArchiveRelationForm, setArchiveType, setArchiveRelatedDcmtFormTID, setArchiveRelatedDcmtFormMids, archiveRelatedDcmtHandler, executeManyToManyPairing } = relatedDocuments;
108
139
  const fetchErrorShownRef = useRef(false);
140
+ useEffect(() => {
141
+ if (!TID)
142
+ return;
143
+ checkRelatedDcmtsArchiveCapability();
144
+ checkManyToManyCapability();
145
+ }, [TID, checkRelatedDcmtsArchiveCapability, checkManyToManyCapability]);
109
146
  const deviceType = useDeviceType();
110
147
  const getDcmts = useCallback(() => {
111
148
  return [{ TID: currentDcmt?.tid, DID: currentDcmt?.did, FILEEXT: currentDcmt?.fileExt }];
@@ -331,8 +368,8 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
331
368
  return;
332
369
  if (!formDataOrig || formDataOrig.length === 0)
333
370
  return;
334
- // Check if formData has actual user metadata (mid > 99), not just system metadata
335
- if (!formData.some(md => md.mid && md.mid > 99))
371
+ const hasUserMetadata = formData.some(md => md.mid && md.mid > 99);
372
+ if (!hasUserMetadata)
336
373
  return;
337
374
  if (appliedInputMidsRef.current && deepCompare(appliedInputMidsRef.current, inputMids))
338
375
  return;
@@ -466,29 +503,207 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
466
503
  const isApprView = useMemo(() => fromDTD?.templateTID === TemplateTIDs.WF_WIApprView, [fromDTD?.templateTID]);
467
504
  const workitemSetID = useMemo(() => workItems.find(o => o.did === Number(DID))?.setID || formData.find(o => o.md?.name === WorkItemMetadataNames.WI_SetID)?.value, [workItems, DID, formData]);
468
505
  const approvalVID = useMemo(() => workItems.length > 0 ? Number(workItems[0].tid) : -1, [workItems]);
506
+ //here
469
507
  const commandsMenuItems = useMemo(() => {
470
- const items = [
471
- { icon: svgToString(_jsx(IconDownload, {})), operationType: 'singleRow', disabled: fromDTD?.perm?.canRetrieveFile !== AccessLevels.Yes, text: "Download file", onClick: async () => await downloadDcmtsAsync(getDcmts(), DownloadTypes.Dcmt, "download") },
472
- { icon: svgToString(_jsx(IconDownload, {})), operationType: 'singleRow', disabled: !isXMLFileExt(currentDcmt?.fileExt), text: "Download allegati XML", onClick: async () => await downloadDcmtsAsync(getDcmts(), DownloadTypes.Attachment, "download", undefined, openConfirmAttachmentsDialog) },
473
- ...(allowRelations && currentTIDHasMasterRelations ? [{ icon: svgToString(_jsx(IconDetailDcmts, { transform: 'scale(-1, 1)' })), operationType: 'singleRow', disabled: isMasterDisabled, text: SDKUI_Localizator.DcmtsMaster, onClick: () => { if (!isMasterDisabled)
474
- setIsOpenMaster(!isOpenMaster); } }] : []),
475
- ...(allowRelations && currentTIDHasDetailRelations ? [{ icon: svgToString(_jsx(IconDetailDcmts, {})), operationType: 'singleRow', disabled: isDetailsDisabled, text: SDKUI_Localizator.DcmtsDetail, onClick: () => { if (!isDetailsDisabled)
476
- setIsOpenDetails(!isOpenDetails); } }] : []),
477
- ];
508
+ const items = [];
509
+ const operationsItems = [];
510
+ operationsItems.push({
511
+ icon: svgToString(_jsx(IconDownload, {})),
512
+ operationType: 'singleRow',
513
+ disabled: fromDTD?.perm?.canRetrieveFile !== AccessLevels.Yes,
514
+ text: SDKUI_Localizator.DownloadFile,
515
+ onClick: async () => await downloadDcmtsAsync(getDcmts(), DownloadTypes.Dcmt, "download")
516
+ }, {
517
+ icon: svgToString(_jsx(IconDownload, {})),
518
+ operationType: 'singleRow',
519
+ disabled: !isXMLFileExt(currentDcmt?.fileExt),
520
+ text: SDKUI_Localizator.DownloadXMLAttachments,
521
+ onClick: async () => await downloadDcmtsAsync(getDcmts(), DownloadTypes.Attachment, "download", undefined, openConfirmAttachmentsDialog)
522
+ });
523
+ if (layoutMode === LayoutModes.Update && DID) {
524
+ operationsItems.push({
525
+ icon: svgToString(_jsx(IconStar, {})),
526
+ text: SDKUI_Localizator.AddTo + ' ' + SDKUI_Localizator.Favorites,
527
+ operationType: 'singleRow',
528
+ disabled: false,
529
+ onClick: async () => {
530
+ await runOperationAsync(getDcmts(), DcmtOperationTypes.AddToFavs);
531
+ },
532
+ });
533
+ }
534
+ if (onTaskCreateRequest && layoutMode === LayoutModes.Update && DID) {
535
+ operationsItems.push({
536
+ icon: svgToString(_jsx(IconActivity, {})),
537
+ text: SDKUI_Localizator.CreateContextualTask,
538
+ operationType: 'singleRow',
539
+ disabled: false,
540
+ onClick: () => {
541
+ const dcmt = getDcmts()[0];
542
+ const taskContext = {
543
+ document: {
544
+ tid: dcmt.TID,
545
+ did: dcmt.DID,
546
+ name: fromDTD?.description || ''
547
+ }
548
+ };
549
+ onTaskCreateRequest(taskContext);
550
+ }
551
+ });
552
+ }
553
+ if (operationsItems.length > 0) {
554
+ items.push({
555
+ icon: svgToString(_jsx(IconCheck, {})),
556
+ text: SDKUI_Localizator.DocumentOperations,
557
+ items: operationsItems
558
+ });
559
+ }
560
+ if (allowRelations && layoutMode === LayoutModes.Update && DID) {
561
+ const relationsItems = [
562
+ {
563
+ icon: svgToString(_jsx(IconPair, {})),
564
+ text: SDKUI_Localizator.MatchManyDocumentsManyToMany,
565
+ operationType: 'singleRow',
566
+ disabled: !hasManyToManyRelation,
567
+ onClick: async () => await pairManyToMany?.(true)
568
+ },
569
+ {
570
+ icon: svgToString(_jsx(IconUnpair, {})),
571
+ text: SDKUI_Localizator.UnmatchManyDocumentsManyToMany,
572
+ operationType: 'singleRow',
573
+ disabled: !hasManyToManyRelation,
574
+ onClick: async () => await pairManyToMany?.(false)
575
+ },
576
+ {
577
+ icon: svgToString(_jsx(IconArchiveMaster, {})),
578
+ text: SDKUI_Localizator.ArchiveMasterDocument,
579
+ operationType: 'singleRow',
580
+ beginGroup: true,
581
+ disabled: canArchiveMasterRelation !== true,
582
+ onClick: async () => { if (TID)
583
+ await archiveMasterDocuments?.(TID); }
584
+ },
585
+ {
586
+ icon: svgToString(_jsx(IconArchiveDetail, {})),
587
+ text: SDKUI_Localizator.ArchiveDetailDocument,
588
+ operationType: 'singleRow',
589
+ disabled: canArchiveDetailRelation !== true,
590
+ onClick: async () => { if (TID)
591
+ await archiveDetailDocuments?.(TID); }
592
+ },
593
+ {
594
+ icon: svgToString(_jsx(IconDetailDcmts, { transform: 'scale(-1, 1)' })),
595
+ text: SDKUI_Localizator.DcmtsMaster,
596
+ operationType: 'singleRow',
597
+ visible: true,
598
+ beginGroup: true,
599
+ disabled: !currentTIDHasMasterRelations || isMasterDisabled,
600
+ onClick: () => { if (!isMasterDisabled)
601
+ setIsOpenMaster(!isOpenMaster); }
602
+ },
603
+ {
604
+ icon: svgToString(_jsx(IconDetailDcmts, {})),
605
+ text: SDKUI_Localizator.DcmtsDetail,
606
+ operationType: 'singleRow',
607
+ disabled: !currentTIDHasDetailRelations || isDetailsDisabled,
608
+ visible: true,
609
+ onClick: () => { if (!isDetailsDisabled)
610
+ setIsOpenDetails(!isOpenDetails); }
611
+ }
612
+ ];
613
+ items.push({
614
+ icon: svgToString(_jsx(IconRelation, {})),
615
+ text: SDKUI_Localizator.Relations,
616
+ items: relationsItems
617
+ });
618
+ }
619
+ if (layoutMode === LayoutModes.Update && DID) {
620
+ const fullTextItems = [
621
+ {
622
+ icon: svgToString(_jsx(IconInfo, {})),
623
+ text: SDKUI_Localizator.IndexingInformation,
624
+ operationType: 'singleRow',
625
+ disabled: false,
626
+ onClick: async () => {
627
+ try {
628
+ TMSpinner.show({ description: `${SDKUI_Localizator.Loading}...` });
629
+ const dcmts = getDcmts();
630
+ const msg = await SDK_Globals.tmSession?.NewSearchEngine().FreeSearchGetDcmtInfoAsync(dcmts[0].TID, dcmts[0].DID);
631
+ TMMessageBoxManager.show({ buttons: [ButtonNames.OK], message: msg, title: SDKUI_Localizator.IndexingInformation });
632
+ }
633
+ catch (e) {
634
+ TMExceptionBoxManager.show({ exception: e });
635
+ }
636
+ finally {
637
+ TMSpinner.hide();
638
+ }
639
+ }
640
+ },
641
+ {
642
+ icon: svgToString(_jsx(IconArchiveDoc, {})),
643
+ text: SDKUI_Localizator.IndexOrReindex,
644
+ operationType: 'singleRow',
645
+ disabled: false,
646
+ onClick: async () => {
647
+ await runOperationAsync(getDcmts(), DcmtOperationTypes.FreeSearchReindex);
648
+ }
649
+ },
650
+ {
651
+ icon: svgToString(_jsx(IconDelete, {})),
652
+ text: SDKUI_Localizator.IndexingDelete,
653
+ operationType: 'singleRow',
654
+ disabled: false,
655
+ onClick: async () => {
656
+ await runOperationAsync(getDcmts(), DcmtOperationTypes.FreeSearchPurge);
657
+ }
658
+ }
659
+ ];
660
+ items.push({
661
+ icon: svgToString(_jsx(IconSearch, {})),
662
+ text: SDKUI_Localizator.FullTextSearch,
663
+ items: fullTextItems
664
+ });
665
+ }
478
666
  // Aggiungi submenu "Bottoni personalizzati" se esistono customButtons
479
667
  if (customButtonsLayout?.customButtons && Array.isArray(customButtonsLayout.customButtons) && customButtonsLayout.customButtons.length > 0) {
480
- const customButtonsItems = customButtonsLayout.customButtons.map((customButton) => ({
668
+ const customButtonsItems = customButtonsLayout.customButtons
669
+ .filter((customButton) => customButton.isForUpdate && customButton.isForUpdate > 0)
670
+ .map((customButton) => ({
671
+ icon: svgToString(TMImageLibrary({ imageID: customButton.glyphID, showPath: true })),
481
672
  text: customButton.title || 'Bottone personalizzato',
482
673
  onClick: () => setCustomButton(customButton)
483
674
  }));
484
675
  items.push({
485
676
  icon: svgToString(_jsx(IconCheck, {})),
486
- text: 'Bottoni personalizzati',
677
+ text: SDKUI_Localizator.CustomButtons,
487
678
  items: customButtonsItems
488
679
  });
489
680
  }
490
681
  return items;
491
- }, [fromDTD?.perm?.canRetrieveFile, currentDcmt?.fileExt, allowRelations, currentTIDHasMasterRelations, isMasterDisabled, currentTIDHasDetailRelations, isDetailsDisabled, customButtonsLayout, getDcmts, downloadDcmtsAsync, openConfirmAttachmentsDialog]);
682
+ }, [
683
+ fromDTD?.perm?.canRetrieveFile,
684
+ fromDTD?.description,
685
+ currentDcmt?.fileExt,
686
+ allowRelations,
687
+ currentTIDHasMasterRelations,
688
+ isMasterDisabled,
689
+ currentTIDHasDetailRelations,
690
+ isDetailsDisabled,
691
+ customButtonsLayout,
692
+ layoutMode,
693
+ TID,
694
+ DID,
695
+ onTaskCreateRequest,
696
+ hasManyToManyRelation,
697
+ canArchiveMasterRelation,
698
+ canArchiveDetailRelation,
699
+ pairManyToMany,
700
+ archiveMasterDocuments,
701
+ archiveDetailDocuments,
702
+ getDcmts,
703
+ downloadDcmtsAsync,
704
+ runOperationAsync,
705
+ openConfirmAttachmentsDialog
706
+ ]);
492
707
  const isModified = useMemo(() => calcIsModified(formData, formDataOrig), [formData, formDataOrig]);
493
708
  const formToolbar = useMemo(() => _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '10px' }, children: [allowNavigation && canPrev != undefined && _jsx("p", { style: { textAlign: 'center', padding: '1px 4px', display: 'flex' }, children: `${itemIndex}/${count}` }), allowNavigation && canPrev != undefined && _jsx(TMSaveFormButtonPrevious, { btnStyle: 'icon', iconColor: 'white', isModified: isModified, formMode: formMode, canPrev: canPrev, onPrev: onPrev }), allowNavigation && canNext != undefined && _jsx(TMSaveFormButtonNext, { btnStyle: 'icon', iconColor: 'white', isModified: isModified, formMode: formMode, canNext: canNext, onNext: onNext }), layoutMode === LayoutModes.Update && _jsx(IconMenuVertical, { id: `commands-detail-${id}`, color: 'white', cursor: 'pointer' }), layoutMode === LayoutModes.Update && _jsx(ContextMenu, { showEvent: 'click', dataSource: commandsMenuItems, target: `#commands-detail-${id}` }), layoutMode === LayoutModes.Ark &&
494
709
  _jsx(TMTooltip, { content: SDKUI_Localizator.PassToSearch, position: 'bottom', children: _jsx(IconSearch, { style: { cursor: 'pointer' }, onClick: handlePassToSearch }) })] }), [allowNavigation, canPrev, canNext, itemIndex, count, isModified, formMode, onPrev, onNext, layoutMode, id, commandsMenuItems, handlePassToSearch]);
@@ -1122,47 +1337,88 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
1122
1337
  height: '100%',
1123
1338
  position: 'relative',
1124
1339
  overflow: 'hidden'
1125
- }, children: [isNavigating && _jsx(Spinner, { description: SDKUI_Localizator.Loading, flat: false }), (fromDTD) && _jsxs(TMLayoutWaitingContainer, { direction: 'vertical', showWaitPanel: useWaitPanelLocalState ? showWaitPanelLocal : showWaitPanel, showWaitPanelPrimary: useWaitPanelLocalState ? showPrimaryLocal : showPrimary, showWaitPanelSecondary: useWaitPanelLocalState ? showSecondaryLocal : showSecondary, waitPanelTitle: useWaitPanelLocalState ? waitPanelTitleLocal : waitPanelTitle, waitPanelTextPrimary: useWaitPanelLocalState ? waitPanelTextPrimaryLocal : waitPanelTextPrimary, waitPanelValuePrimary: useWaitPanelLocalState ? waitPanelValuePrimaryLocal : waitPanelValuePrimary, waitPanelMaxValuePrimary: useWaitPanelLocalState ? waitPanelMaxValuePrimaryLocal : waitPanelMaxValuePrimary, waitPanelTextSecondary: useWaitPanelLocalState ? waitPanelTextSecondaryLocal : waitPanelTextSecondary, waitPanelValueSecondary: useWaitPanelLocalState ? waitPanelValueSecondaryLocal : waitPanelValueSecondary, waitPanelMaxValueSecondary: useWaitPanelLocalState ? waitPanelMaxValueSecondaryLocal : waitPanelMaxValueSecondary, isCancelable: useWaitPanelLocalState ? dcmtFile ? dcmtFile.size >= 1000000 : false : true, abortController: useWaitPanelLocalState ? abortControllerLocal : abortController, children: [(groupId && groupId.length > 0)
1126
- ? _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", parentId: groupId, showToolbar: showDcmtFormSidebar })
1127
- : _jsxs(TMPanelManagerWithPersistenceProvider, { panels: initialPanels, initialVisibility: allInitialPanelVisibility, defaultDimensions: defaultPanelDimensions, initialDimensions: defaultPanelDimensions, initialMobilePanelId: 'tmDcmtForm', isPersistenceEnabled: !isMobile ? hasSavedLayout() : false, persistPanelStates: !isMobile ? (state) => persistPanelStates(state) : undefined, persistedPanelStates: getPersistedPanelStates(), children: [_jsx(WfButtonStateHandler, { isWFDisabled: isWFDisabled }), _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", parentId: groupId, showToolbar: showDcmtFormSidebar })] }), isOpenDistinctValues &&
1128
- _jsx(TMDistinctValues, { tid: TID, mid: focusedMetadataValue?.mid, isModal: true, showHeader: false, layoutMode: layoutMode, onSelectionChanged: (e) => {
1129
- if (!e)
1130
- return;
1131
- setFormData((prevItems) => prevItems.map((item) => item.tid == e.tid && item.mid === e.mid ? { ...item, value: e.newValue } : item));
1132
- } }), isOpenFormulaEditor &&
1133
- _jsx(TMFormulaEditor, { isModal: true, formMode: FormModes.Update, inputData: getFormula(), showBack: false, onClose: () => setIsOpenFormulaEditor(false), onApplied: (newFormula) => {
1134
- setFormData((prevItems) => prevItems.map((item) => item.tid == newFormula.tid && item.mid === newFormula.mid ? { ...item, value: FormulaHelper.addFormulaTag(newFormula.expression), isSelected: true, isEditable: true } : item));
1135
- setFocusedMetadataValue(prevState => ({
1136
- ...prevState,
1137
- isSelected: true,
1138
- isEditable: true,
1139
- value: FormulaHelper.addFormulaTag(newFormula.expression)
1140
- }));
1141
- } }), showApprovePopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, TID: approvalVID, DID: DID, isReject: 0, onClose: () => setShowApprovePopup(false) }), showRejectPopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, TID: approvalVID, DID: DID, isReject: 1, onClose: () => setShowRejectPopup(false) }), showReAssignPopup && _jsx(WorkFlowReAssignPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, TID: approvalVID, DID: DID, onClose: () => setShowReAssignPopup(false) }), showMoreInfoPopup && _jsx(WorkFlowMoreInfoPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, TID: approvalVID, DID: DID, onClose: () => setShowMoreInfoPopup(false) }), (isModal && onClose) && _jsx("div", { id: "TMDcmtFormShowConfirmForClose-" + id })] }), (showToppyForApprove || showToppyForCompleteMoreInfo || showToppyForReferences) && (_jsx(ToppyHelpCenter, { deviceType: deviceType, usePortal: false, content: _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '10px' }, children: [showToppyForApprove && (workItems.length === 1 ?
1142
- _jsx(WorkFlowOperationButtons, { deviceType: deviceType, onApprove: () => setShowApprovePopup(true), onSignApprove: handleSignApprove, onReject: () => setShowRejectPopup(true), onReAssign: () => setShowReAssignPopup(true), onMoreInfo: () => setShowMoreInfoPopup(true), dtd: fromDTD })
1143
- :
1144
- _jsxs("div", { style: { padding: 10, color: 'white', maxWidth: '180px', borderRadius: 10, background: '#1B1464 0% 0% no-repeat padding-box', border: '1px solid #FFFFFF' }, children: [`Devi approvare ${workItems.length} workitem(s) per questo documento.`, `Vai alla sezione di approvazione.`] })), showToppyForCompleteMoreInfo && (_jsxs(_Fragment, { children: [_jsx("div", { style: { padding: 10, color: 'white', maxWidth: '180px', borderRadius: 10, background: '#1B1464 0% 0% no-repeat padding-box', border: '1px solid #FFFFFF' }, children: `${SDKUI_Localizator.MoreInfoCompleteRequestSentBy} ${taskMoreInfo?.fromName}!` }), _jsx(TMButton, { caption: SDKUI_Localizator.CommentAndComplete, color: 'success', showTooltip: false, onClick: () => {
1145
- setShowCommentForm(true);
1146
- } })] })), showToppyForReferences && dcmtReferences && dcmtReferences
1147
- .filter(ref => ref.objClass === ObjectClasses.Dossier || ref.objClass === ObjectClasses.WorkingGroup) // keep only known objClass types
1148
- .map((ref, index, arr) => {
1149
- const mapEntry = referenceActionMap[String(ref.objClass)];
1150
- const label = mapEntry?.label ?? 'Vai a riferimento';
1151
- return (_jsxs(React.Fragment, { children: [index === 0 && (showToppyForApprove || showToppyForCompleteMoreInfo) && (_jsx("div", { style: {
1152
- height: 1,
1153
- backgroundColor: 'rgba(255,255,255,0.2)',
1154
- margin: '6px 0'
1155
- } })), _jsxs(StyledReferenceButton, { onClick: () => handleNavigateToReference(ref), children: [_jsx("span", { children: label }), _jsx("span", { children: `"${ref.objName}"` })] }, `ref-${index}-${ref.objID}`)] }, `ref-frag-${index}-${ref.objID}`));
1156
- })] }) })), (showCommentForm && TID && DID) &&
1340
+ }, children: [_jsxs("div", { style: { width: '100%', height: '100%', display: isOpenDetails || isOpenMaster ? 'none' : 'flex' }, children: [isNavigating && _jsx(Spinner, { description: SDKUI_Localizator.Loading, flat: false }), (fromDTD) && _jsxs(TMLayoutWaitingContainer, { direction: 'vertical', showWaitPanel: useWaitPanelLocalState ? showWaitPanelLocal : showWaitPanel, showWaitPanelPrimary: useWaitPanelLocalState ? showPrimaryLocal : showPrimary, showWaitPanelSecondary: useWaitPanelLocalState ? showSecondaryLocal : showSecondary, waitPanelTitle: useWaitPanelLocalState ? waitPanelTitleLocal : waitPanelTitle, waitPanelTextPrimary: useWaitPanelLocalState ? waitPanelTextPrimaryLocal : waitPanelTextPrimary, waitPanelValuePrimary: useWaitPanelLocalState ? waitPanelValuePrimaryLocal : waitPanelValuePrimary, waitPanelMaxValuePrimary: useWaitPanelLocalState ? waitPanelMaxValuePrimaryLocal : waitPanelMaxValuePrimary, waitPanelTextSecondary: useWaitPanelLocalState ? waitPanelTextSecondaryLocal : waitPanelTextSecondary, waitPanelValueSecondary: useWaitPanelLocalState ? waitPanelValueSecondaryLocal : waitPanelValueSecondary, waitPanelMaxValueSecondary: useWaitPanelLocalState ? waitPanelMaxValueSecondaryLocal : waitPanelMaxValueSecondary, isCancelable: useWaitPanelLocalState ? dcmtFile ? dcmtFile.size >= 1000000 : false : true, abortController: useWaitPanelLocalState ? abortControllerLocal : abortController, children: [(groupId && groupId.length > 0)
1341
+ ? _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", parentId: groupId, showToolbar: showDcmtFormSidebar })
1342
+ : _jsxs(TMPanelManagerWithPersistenceProvider, { panels: initialPanels, initialVisibility: allInitialPanelVisibility, defaultDimensions: defaultPanelDimensions, initialDimensions: defaultPanelDimensions, initialMobilePanelId: 'tmDcmtForm', isPersistenceEnabled: !isMobile ? hasSavedLayout() : false, persistPanelStates: !isMobile ? (state) => persistPanelStates(state) : undefined, persistedPanelStates: getPersistedPanelStates(), children: [_jsx(WfButtonStateHandler, { isWFDisabled: isWFDisabled }), _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", parentId: groupId, showToolbar: showDcmtFormSidebar })] }), isOpenDistinctValues &&
1343
+ _jsx(TMDistinctValues, { tid: TID, mid: focusedMetadataValue?.mid, isModal: true, showHeader: false, layoutMode: layoutMode, onSelectionChanged: (e) => {
1344
+ if (!e)
1345
+ return;
1346
+ setFormData((prevItems) => prevItems.map((item) => item.tid == e.tid && item.mid === e.mid ? { ...item, value: e.newValue } : item));
1347
+ } }), isOpenFormulaEditor &&
1348
+ _jsx(TMFormulaEditor, { isModal: true, formMode: FormModes.Update, inputData: getFormula(), showBack: false, onClose: () => setIsOpenFormulaEditor(false), onApplied: (newFormula) => {
1349
+ setFormData((prevItems) => prevItems.map((item) => item.tid == newFormula.tid && item.mid === newFormula.mid ? { ...item, value: FormulaHelper.addFormulaTag(newFormula.expression), isSelected: true, isEditable: true } : item));
1350
+ setFocusedMetadataValue(prevState => ({
1351
+ ...prevState,
1352
+ isSelected: true,
1353
+ isEditable: true,
1354
+ value: FormulaHelper.addFormulaTag(newFormula.expression)
1355
+ }));
1356
+ } }), showApprovePopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, TID: approvalVID, DID: DID, isReject: 0, onClose: () => setShowApprovePopup(false) }), showRejectPopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, TID: approvalVID, DID: DID, isReject: 1, onClose: () => setShowRejectPopup(false) }), showReAssignPopup && _jsx(WorkFlowReAssignPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, TID: approvalVID, DID: DID, onClose: () => setShowReAssignPopup(false) }), showMoreInfoPopup && _jsx(WorkFlowMoreInfoPopUp, { deviceType: deviceType, onCompleted: handleWFOperationCompleted, TID: approvalVID, DID: DID, onClose: () => setShowMoreInfoPopup(false) }), (isModal && onClose) && _jsx("div", { id: "TMDcmtFormShowConfirmForClose-" + id })] }), (showToppyForApprove || showToppyForCompleteMoreInfo || showToppyForReferences) && (_jsx(ToppyDraggableHelpCenter, { initialIsCollapsed: false, deviceType: deviceType, content: _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '10px' }, children: [showToppyForApprove && (workItems.length === 1 ?
1357
+ _jsx(WorkFlowOperationButtons, { deviceType: deviceType, onApprove: () => setShowApprovePopup(true), onSignApprove: handleSignApprove, onReject: () => setShowRejectPopup(true), onReAssign: () => setShowReAssignPopup(true), onMoreInfo: () => setShowMoreInfoPopup(true), dtd: fromDTD })
1358
+ :
1359
+ _jsxs("div", { style: { padding: 10, color: 'white', maxWidth: '180px', borderRadius: 10, background: '#1B1464 0% 0% no-repeat padding-box', border: '1px solid #FFFFFF' }, children: [`Devi approvare ${workItems.length} workitem(s) per questo documento.`, `Vai alla sezione di approvazione.`] })), showToppyForCompleteMoreInfo && (_jsxs(_Fragment, { children: [_jsx("div", { style: { padding: 10, color: 'white', maxWidth: '180px', borderRadius: 10, background: '#1B1464 0% 0% no-repeat padding-box', border: '1px solid #FFFFFF' }, children: `${SDKUI_Localizator.MoreInfoCompleteRequestSentBy} ${taskMoreInfo?.fromName}!` }), _jsx(TMButton, { caption: SDKUI_Localizator.CommentAndComplete, color: 'success', showTooltip: false, onClick: () => {
1360
+ setShowCommentForm(true);
1361
+ } })] })), showToppyForReferences && dcmtReferences && dcmtReferences
1362
+ .filter(ref => ref.objClass === ObjectClasses.Dossier || ref.objClass === ObjectClasses.WorkingGroup) // keep only known objClass types
1363
+ .map((ref, index, arr) => {
1364
+ const mapEntry = referenceActionMap[String(ref.objClass)];
1365
+ const label = mapEntry?.label ?? 'Vai a riferimento';
1366
+ return (_jsxs(React.Fragment, { children: [index === 0 && (showToppyForApprove || showToppyForCompleteMoreInfo) && (_jsx("div", { style: {
1367
+ height: 1,
1368
+ backgroundColor: 'rgba(255,255,255,0.2)',
1369
+ margin: '6px 0'
1370
+ } })), _jsxs(StyledReferenceButton, { onClick: () => handleNavigateToReference(ref), children: [_jsx("span", { children: label }), _jsx("span", { children: `"${ref.objName}"` })] }, `ref-${index}-${ref.objID}`)] }, `ref-frag-${index}-${ref.objID}`));
1371
+ })] }) }))] }), (showCommentForm && TID && DID) &&
1157
1372
  _jsx(TMBlogCommentForm, { context: { engine: 'SearchEngine', object: { tid: TID, did: DID } }, onClose: () => setShowCommentForm(false), refreshCallback: handleCompleteMoreInfo, participants: [], showAttachmentsSection: false, allArchivedDocumentsFileItems: [] }), isOpenDetails &&
1158
- _jsx(StyledModalContainer, { style: { backgroundColor: 'white' }, children: _jsx(TMMasterDetailDcmts, { deviceType: deviceType, isForMaster: false, inputDcmts: getSelectionDcmtInfo(), allowNavigation: allowNavigation, canNext: canNext, canPrev: canPrev, onNext: onNext, onPrev: onPrev, onBack: () => setIsOpenDetails(false), allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }), isOpenMaster &&
1159
- _jsxs(StyledModalContainer, { style: { backgroundColor: 'white' }, children: [_jsx(TMMasterDetailDcmts, { deviceType: deviceType, inputDcmts: getSelectionDcmtInfo(), isForMaster: true, allowNavigation: allowNavigation, canNext: canNext, canPrev: canPrev, onNext: onNext, onPrev: onPrev, 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) => {
1160
- 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}`));
1373
+ _jsx(StyledModalContainer, { children: _jsx(TMMasterDetailDcmts, { deviceType: deviceType, isForMaster: false, inputDcmts: getSelectionDcmtInfo(), allowNavigation: allowNavigation, canNext: canNext, canPrev: canPrev, onNext: onNext, onPrev: onPrev, onBack: () => setIsOpenDetails(false), allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }), isOpenMaster &&
1374
+ _jsxs(StyledModalContainer, { children: [_jsx(TMMasterDetailDcmts, { deviceType: deviceType, inputDcmts: getSelectionDcmtInfo(), isForMaster: true, allowNavigation: allowNavigation, canNext: canNext, canPrev: canPrev, onNext: onNext, onPrev: onPrev, 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) => {
1375
+ return (_jsx(StyledModalContainer, { 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}`));
1161
1376
  })] }), taskFormDialogComponent, s4TViewerDialogComponent] }));
1162
1377
  };
1163
- return (_jsx(_Fragment, { children: (isModal && onClose)
1164
- ? _jsx(TMModal, { title: titleModal, onClose: handleClose, width: widthModal ?? '100%', height: heightModal ?? '100%', hidePopup: false, askClosingConfirm: true, children: _jsx("div", { style: { width: "100%", height: "100%", display: 'block', padding: "4px", position: 'relative' }, children: renderDcmtForm() }) })
1165
- : renderDcmtForm() }));
1378
+ return (_jsxs(_Fragment, { children: [(isModal && onClose)
1379
+ ? _jsx(TMModal, { title: titleModal, onClose: handleClose, width: widthModal ?? '100%', height: heightModal ?? '100%', hidePopup: false, askClosingConfirm: true, children: _jsx("div", { style: { width: "100%", height: "100%", display: 'block', padding: "4px", position: 'relative' }, children: renderDcmtForm() }) })
1380
+ : renderDcmtForm(), showRelatedDcmtsChooser && (_jsx(TMChooserForm, { dataSource: relatedDcmtsChooserDataSource, onChoose: async (selectedRelation) => {
1381
+ try {
1382
+ setShowRelatedDcmtsChooser(false);
1383
+ TMSpinner.show({ description: SDKUI_Localizator.Loading });
1384
+ const relation = relatedDcmts?.find(r => r.id === selectedRelation[0]);
1385
+ if (!relation || !archiveType)
1386
+ return;
1387
+ await archiveRelatedDcmtHandler(relation, archiveType);
1388
+ }
1389
+ catch (error) {
1390
+ TMExceptionBoxManager.show({ exception: error });
1391
+ }
1392
+ finally {
1393
+ TMSpinner.hide();
1394
+ }
1395
+ }, onClose: () => setShowRelatedDcmtsChooser(false), manageUseLocalizedName: false })), showManyToManyChooser && (_jsx(TMChooserForm, { dataSource: manyToManyChooserDataSource, onChoose: async (selectedRelation) => {
1396
+ try {
1397
+ setShowManyToManyChooser(false);
1398
+ TMSpinner.show({ description: SDKUI_Localizator.Loading });
1399
+ const relation = manyToManyRelations?.find(r => r.id === selectedRelation[0]);
1400
+ if (!relation)
1401
+ return;
1402
+ await executeManyToManyPairing(relation, isPairingManyToMany);
1403
+ }
1404
+ catch (error) {
1405
+ TMExceptionBoxManager.show({ exception: error });
1406
+ }
1407
+ finally {
1408
+ TMSpinner.hide();
1409
+ }
1410
+ }, onClose: () => setShowManyToManyChooser(false), manageUseLocalizedName: false })), 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: () => {
1411
+ setIsOpenArchiveRelationForm(false);
1412
+ setArchiveType(undefined);
1413
+ setArchiveRelatedDcmtFormTID(undefined);
1414
+ setArchiveRelatedDcmtFormMids([]);
1415
+ }, onSavedAsyncCallback: async (tid, did) => {
1416
+ setIsOpenArchiveRelationForm(false);
1417
+ setArchiveType(undefined);
1418
+ setArchiveRelatedDcmtFormTID(undefined);
1419
+ setArchiveRelatedDcmtFormMids([]);
1420
+ await fetchData();
1421
+ }, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers })), showPairDcmtsModal && (_jsx(TMModal, { title: (isPairingManyToMany ? "Abbina" : "Disabbina") + " documenti", onClose: () => setShowPairDcmtsModal(false), width: isMobile ? '90%' : '50%', height: isMobile ? '90%' : '70%', children: _jsx(TMSearchResult, { searchResults: pairedSearchResults, onRefreshSearchAsync: async () => await fetchData(), onTaskCreateRequest: onTaskCreateRequest, allowFloatingBar: false, floatingActionConfig: pairFloatingActionConfig, showBackButton: false, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }))] }));
1166
1422
  };
1167
1423
  export default TMDcmtForm;
1168
1424
  /**
@@ -15,11 +15,18 @@ import { TMSaveFormButtonPrevious, TMSaveFormButtonNext } from '../../forms/TMSa
15
15
  import { StyledAnimatedComponentOpacity } from '../../base/Styled';
16
16
  import TMPanel from '../../base/TMPanel';
17
17
  import TMTooltip from '../../base/TMTooltip';
18
+ const ErrorContent = ({ error, isAbortError, onRetry }) => {
19
+ if (isAbortError) {
20
+ return (_jsx(StyledAnimatedComponentOpacity, { style: { width: '100%', height: '100%' }, children: _jsxs(StyledPanelStatusContainer, { children: [_jsx(IconCloseOutline, { fontSize: 92, color: TMColors.error }), _jsxs(StyledPreviewNotAvailable, { children: [_jsx("div", { children: error }), _jsx("div", { children: SDKUI_Localizator.PreviewNotAvailable })] }), _jsx(TMButton, { caption: SDKUI_Localizator.TryAgain, onClick: onRetry, showTooltip: false })] }) }));
21
+ }
22
+ return _jsx(TMNothingToShow, { icon: _jsx(IconCloseOutline, { fontSize: 92, color: TMColors.error }), text: error });
23
+ };
18
24
  const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev, onClosePanel, onNext, onPrev, allowMaximize = true, onMaximizePanel }) => {
19
25
  const [dcmtBlob, setDcmtBlob] = useState(undefined);
20
26
  const [showPreview, setShowPreview] = useState(false);
21
27
  const [isFromCache, setIsFromCache] = useState(false);
22
28
  const [error, setError] = useState('');
29
+ const [isAbortError, setIsAbortError] = useState(false);
23
30
  const { abortController, showWaitPanel, waitPanelTitle, showPrimary, waitPanelTextPrimary, waitPanelValuePrimary, waitPanelMaxValuePrimary, showSecondary, waitPanelTextSecondary, waitPanelValueSecondary, waitPanelMaxValueSecondary, getDcmtFileAsync, clearDcmtsFileCache, removeDcmtsFileCache, isDcmtFileInCache } = useDcmtOperations();
24
31
  const cacheKey = dcmtData ? `${dcmtData.tid}-${dcmtData.did}` : '00';
25
32
  const [hasLoadedDataOnce, setHasLoadedDataOnce] = useState(false);
@@ -29,6 +36,7 @@ const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev
29
36
  setLastLoadedDid(undefined); // Reset
30
37
  setDcmtBlob(undefined);
31
38
  setError('');
39
+ setIsAbortError(false);
32
40
  setShowPreview(false);
33
41
  return;
34
42
  }
@@ -42,6 +50,7 @@ const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev
42
50
  if (shouldFetch) {
43
51
  setDcmtBlob(undefined);
44
52
  setError('');
53
+ setIsAbortError(false);
45
54
  if ((extensionHandler(dcmtData.fileExt) !== FileExtensionHandler.NONE) && ((dcmtData.fileSize ?? 0) <= (SDKUI_Globals.userSettings.searchSettings.previewThreshold * 1024))) {
46
55
  loadDocumentWithCache();
47
56
  setShowPreview(true);
@@ -65,15 +74,19 @@ const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev
65
74
  let dcmtFile = await getDcmtFileAsync({ TID: dcmtData?.tid, DID: dcmtData?.did, FILEEXT: dcmtData?.fileExt }, rfo, 'Anteprima', false);
66
75
  setDcmtBlob(dcmtFile?.file);
67
76
  setIsFromCache(!!dcmtFile?.isFromCache);
77
+ setError('');
78
+ setIsAbortError(false);
68
79
  }
69
80
  catch (ex) {
70
81
  const err = ex;
71
82
  if (err.name === 'CanceledError') {
72
83
  setError('Operazione annullata.');
84
+ setIsAbortError(true);
73
85
  ShowAlert({ message: err.message, mode: 'warning', duration: 3000, title: 'Abort' });
74
86
  }
75
87
  else {
76
88
  setError(getExceptionMessage(ex));
89
+ setIsAbortError(false);
77
90
  TMExceptionBoxManager.show({ exception: ex });
78
91
  }
79
92
  }
@@ -101,6 +114,9 @@ const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev
101
114
  const reOpenDcmt = async () => {
102
115
  removeDcmtsFileCache(cacheKey);
103
116
  setIsFromCache(false);
117
+ setError('');
118
+ setIsAbortError(false);
119
+ setDcmtBlob(undefined);
104
120
  try {
105
121
  await loadDocumentWithCache();
106
122
  }
@@ -112,7 +128,7 @@ const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev
112
128
  { icon: _jsx(IconCloseCircle, {}), text: SDKUI_Localizator.RemoveFromCache, onClick: () => { removeDcmtsFileCache(cacheKey); setIsFromCache(false); } },
113
129
  { icon: _jsx(IconClear, {}), text: SDKUI_Localizator.ClearCache, onClick: () => { clearDcmtsFileCache(); setIsFromCache(false); } },
114
130
  ] }, "btn13") }), _jsx(StyledHeaderIcon, { onClick: reOpenDcmt, "$color": TMColors.primaryColor, children: _jsx(TMTooltip, { content: SDKUI_Localizator.ReopenDocument, children: _jsx(IconRefresh, {}) }) })] }), children: error
115
- ? _jsx(TMNothingToShow, { icon: _jsx(IconCloseOutline, { fontSize: 92, color: TMColors.error }), text: error })
131
+ ? _jsx(ErrorContent, { error: error, isAbortError: isAbortError, onRetry: reOpenDcmt })
116
132
  : renderedPreview(dcmtData?.tid, dcmtData?.did, dcmtData?.fileExt, dcmtData?.fileSize, dcmtData?.fileCount, extensionHandler(dcmtData?.fileExt), showPreview, isResizingActive, () => { loadDocumentWithCache(); setShowPreview(true); }, dcmtBlob) }) }));
117
133
  };
118
134
  export default TMDcmtPreview;
@@ -148,11 +164,12 @@ export const TMFileViewer = ({ fileBlob, isResizingActive }) => {
148
164
  }, []);
149
165
  useEffect(() => {
150
166
  if (fileBlob) {
151
- const url = URL.createObjectURL(fileBlob);
152
- setBlobUrl(url);
153
167
  setFileType(fileBlob.type);
154
168
  setFormattedXml(undefined);
155
- if (fileBlob.type.includes("xml")) {
169
+ const fileName = fileBlob.name || '';
170
+ const fileExtension = fileName.split('.').pop()?.toLowerCase() || '';
171
+ const isConfigFile = ['config', 'cfg'].includes(fileExtension);
172
+ if (fileBlob.type.includes("xml") && !isConfigFile) {
156
173
  fileBlob.text().then((text) => {
157
174
  const parser = new DOMParser();
158
175
  const xmlDoc = parser.parseFromString(text, "application/xml");
@@ -169,10 +186,28 @@ export const TMFileViewer = ({ fileBlob, isResizingActive }) => {
169
186
  .replace(/</g, "&lt;")
170
187
  .replace(/>/g, "&gt;")}</pre>`);
171
188
  });
189
+ setBlobUrl(undefined);
190
+ }
191
+ else if (isConfigFile) {
192
+ fileBlob.text().then((text) => {
193
+ const escapedText = text
194
+ .replace(/&/g, "&amp;")
195
+ .replace(/</g, "&lt;")
196
+ .replace(/>/g, "&gt;");
197
+ setFormattedXml(`<pre style="font-family: monospace; white-space: pre-wrap; line-height: 1.5; margin: 0; padding: 10px;">${escapedText}</pre>`);
198
+ }).catch((error) => {
199
+ console.error("Error reading text file:", error);
200
+ setFormattedXml(`<div style="color: red;">Error reading file</div>`);
201
+ });
202
+ setBlobUrl(undefined);
203
+ }
204
+ else {
205
+ const url = URL.createObjectURL(fileBlob);
206
+ setBlobUrl(url);
207
+ return () => {
208
+ URL.revokeObjectURL(url);
209
+ };
172
210
  }
173
- return () => {
174
- URL.revokeObjectURL(url);
175
- };
176
211
  }
177
212
  else {
178
213
  setBlobUrl(undefined);
@@ -225,7 +260,9 @@ export const TMFileViewer = ({ fileBlob, isResizingActive }) => {
225
260
  display: 'inline-block'
226
261
  }, children: SDKUI_Localizator.OpenInNewTab })] })] }));
227
262
  }
228
- return (_jsx("iframe", { srcDoc: fileType?.includes("xml") && formattedXml ? `<html><body>${formattedXml}</body></html>` : undefined, src: !fileType?.includes("xml") || !formattedXml ? blobUrl : undefined, title: "File Viewer", width: "100%", height: "100%", style: { border: 'none', zIndex: 0, pointerEvents: isResizingActive === true ? "none" : "auto" } }));
263
+ return (_jsx("iframe", { srcDoc: formattedXml ? `<html><body>${formattedXml}</body></html>` : undefined, src: !formattedXml
264
+ ? (fileType === 'application/pdf' ? `${blobUrl}#view=FitH&scrollbar=1` : blobUrl)
265
+ : undefined, title: "File Viewer", width: "100%", height: "100%", style: { border: 'none', zIndex: 0, pointerEvents: isResizingActive === true ? "none" : "auto" } }, blobUrl));
229
266
  };
230
267
  const ImageViewer = ({ fileBlob, alt = 'Image', className }) => {
231
268
  const containerRef = useRef(null);