@topconsultnpm/sdkui-react 6.22.0-dev2.2 → 6.22.0-dev2.21

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 (109) hide show
  1. package/lib/components/NewComponents/ContextMenu/TMContextMenu.js +1 -1
  2. package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.js +1 -1
  3. package/lib/components/base/TMButton.d.ts +13 -0
  4. package/lib/components/base/TMButton.js +137 -5
  5. package/lib/components/base/TMDataGrid.d.ts +2 -0
  6. package/lib/components/base/TMDataGrid.js +68 -4
  7. package/lib/components/base/TMEditorBase.d.ts +2 -0
  8. package/lib/components/base/TMModal.d.ts +4 -0
  9. package/lib/components/base/TMModal.js +42 -11
  10. package/lib/components/base/TMPanel.d.ts +1 -0
  11. package/lib/components/base/TMPanel.js +79 -20
  12. package/lib/components/base/TMTooltip.d.ts +2 -1
  13. package/lib/components/base/TMTooltip.js +23 -6
  14. package/lib/components/base/TMTreeView.js +108 -67
  15. package/lib/components/choosers/TMDcmtTypeChooser.js +4 -3
  16. package/lib/components/choosers/TMDistinctValues.d.ts +9 -7
  17. package/lib/components/choosers/TMDistinctValues.js +149 -142
  18. package/lib/components/choosers/TMMetadataChooser.js +1 -1
  19. package/lib/components/choosers/TMQuickSearchInfo.d.ts +12 -0
  20. package/lib/components/choosers/TMQuickSearchInfo.js +279 -0
  21. package/lib/components/choosers/TMQuickSearchSettingsForm.d.ts +16 -0
  22. package/lib/components/choosers/TMQuickSearchSettingsForm.js +94 -0
  23. package/lib/components/choosers/TMSelectedValuesSummary.d.ts +13 -0
  24. package/lib/components/choosers/TMSelectedValuesSummary.js +91 -0
  25. package/lib/components/editors/TMDropDown.d.ts +3 -0
  26. package/lib/components/editors/TMDropDown.js +197 -5
  27. package/lib/components/editors/TMMetadataEditor.d.ts +5 -1
  28. package/lib/components/editors/TMMetadataEditor.js +8 -3
  29. package/lib/components/editors/TMTextBox.js +15 -15
  30. package/lib/components/features/documents/TMBatchUpdateForm.js +19 -5
  31. package/lib/components/features/documents/TMDcmtForm.d.ts +7 -0
  32. package/lib/components/features/documents/TMDcmtForm.js +104 -42
  33. package/lib/components/features/documents/TMDcmtFormActionButtons.d.ts +11 -0
  34. package/lib/components/features/documents/TMDcmtFormActionButtons.js +74 -7
  35. package/lib/components/features/documents/TMMasterDetailDcmts.js +95 -33
  36. package/lib/components/features/documents/TMMasterInfoFields.d.ts +19 -0
  37. package/lib/components/features/documents/TMMasterInfoFields.js +172 -0
  38. package/lib/components/features/documents/TMMultiMasterDetailDcmtsForm.d.ts +40 -0
  39. package/lib/components/features/documents/TMMultiMasterDetailDcmtsForm.js +277 -0
  40. package/lib/components/features/documents/TMMultiMasterDetailDcmtsUtils.d.ts +354 -0
  41. package/lib/components/features/documents/TMMultiMasterDetailDcmtsUtils.js +234 -0
  42. package/lib/components/features/documents/TMRelationViewer.d.ts +14 -1
  43. package/lib/components/features/documents/TMRelationViewer.js +69 -20
  44. package/lib/components/features/search/TMSearch.js +29 -16
  45. package/lib/components/features/search/TMSearchQueryEditor.js +5 -3
  46. package/lib/components/features/search/TMSearchQueryPanel.d.ts +1 -1
  47. package/lib/components/features/search/TMSearchQueryPanel.js +28 -7
  48. package/lib/components/features/search/TMSearchResult.d.ts +9 -0
  49. package/lib/components/features/search/TMSearchResult.js +323 -92
  50. package/lib/components/features/search/TMTreeSelector.js +18 -5
  51. package/lib/components/features/workflow/TMWorkflowPopup.d.ts +10 -0
  52. package/lib/components/features/workflow/TMWorkflowPopup.js +8 -4
  53. package/lib/components/layout/panelManager/TMPanelManagerContainer.d.ts +1 -0
  54. package/lib/components/layout/panelManager/TMPanelManagerContainer.js +24 -14
  55. package/lib/components/layout/panelManager/TMPanelWrapper.js +2 -2
  56. package/lib/components/layout/panelManager/types.d.ts +3 -0
  57. package/lib/components/viewers/TMMidViewer.js +4 -1
  58. package/lib/components/viewers/TMTidViewer.js +25 -11
  59. package/lib/helper/SDKUI_Globals.d.ts +55 -0
  60. package/lib/helper/SDKUI_Globals.js +82 -0
  61. package/lib/helper/SDKUI_Localizator.d.ts +24 -0
  62. package/lib/helper/SDKUI_Localizator.js +240 -0
  63. package/lib/helper/TMIcons.d.ts +1 -0
  64. package/lib/helper/TMIcons.js +3 -0
  65. package/lib/helper/dataGridSearchHelper.d.ts +28 -0
  66. package/lib/helper/dataGridSearchHelper.js +51 -0
  67. package/lib/helper/dcmtsHelper.d.ts +20 -0
  68. package/lib/helper/dcmtsHelper.js +58 -1
  69. package/lib/helper/helpers.d.ts +20 -0
  70. package/lib/helper/helpers.js +40 -0
  71. package/lib/helper/index.d.ts +1 -0
  72. package/lib/helper/index.js +1 -0
  73. package/lib/helper/queryHelper.d.ts +2 -0
  74. package/lib/helper/queryHelper.js +3 -1
  75. package/lib/hooks/tmDistinctValuesGridHelper.d.ts +16 -0
  76. package/lib/hooks/tmDistinctValuesGridHelper.js +31 -0
  77. package/lib/hooks/useArchiveListForm.d.ts +39 -0
  78. package/lib/hooks/useArchiveListForm.js +46 -0
  79. package/lib/hooks/useCaseFlowApprove.d.ts +56 -0
  80. package/lib/hooks/useCaseFlowApprove.js +157 -0
  81. package/lib/hooks/useDataUserIdItem.d.ts +1 -0
  82. package/lib/hooks/useDataUserIdItem.js +1 -0
  83. package/lib/hooks/useDocumentOperations.d.ts +2 -0
  84. package/lib/hooks/useDocumentOperations.js +28 -5
  85. package/lib/hooks/useMultiMasterDetailDcmts.d.ts +98 -0
  86. package/lib/hooks/useMultiMasterDetailDcmts.js +567 -0
  87. package/lib/hooks/useRelatedDocuments.js +2 -26
  88. package/lib/hooks/useTMDistinctValuesMetadataDisplay.d.ts +18 -0
  89. package/lib/hooks/useTMDistinctValuesMetadataDisplay.js +103 -0
  90. package/lib/hooks/useTMDistinctValuesQuickSearch.d.ts +49 -0
  91. package/lib/hooks/useTMDistinctValuesQuickSearch.js +307 -0
  92. package/lib/hooks/useTMDistinctValuesSelection.d.ts +42 -0
  93. package/lib/hooks/useTMDistinctValuesSelection.js +103 -0
  94. package/lib/hooks/useTMDistinctValuesSource.d.ts +29 -0
  95. package/lib/hooks/useTMDistinctValuesSource.js +105 -0
  96. package/lib/index.d.ts +1 -0
  97. package/lib/index.js +1 -0
  98. package/lib/services/caseflow/CaseFlowService.d.ts +236 -0
  99. package/lib/services/caseflow/CaseFlowService.js +693 -0
  100. package/lib/services/caseflow/CaseFlowTemplateCacheService.d.ts +28 -0
  101. package/lib/services/caseflow/CaseFlowTemplateCacheService.js +121 -0
  102. package/lib/services/caseflow/caseFlowNameCache.d.ts +32 -0
  103. package/lib/services/caseflow/caseFlowNameCache.js +116 -0
  104. package/lib/services/caseflow/caseFlowWorkItemUtils.d.ts +61 -0
  105. package/lib/services/caseflow/caseFlowWorkItemUtils.js +113 -0
  106. package/lib/services/index.d.ts +4 -0
  107. package/lib/services/index.js +4 -0
  108. package/lib/services/platform_services.d.ts +1 -1
  109. package/package.json +66 -66
@@ -0,0 +1,234 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import React, { useEffect, useRef } from 'react';
3
+ import { AccessLevelsEx, DataListViewModes, DcmtTypeListCacheService, MetadataDataDomains, MetadataDataTypes, SDK_Globals } from '@topconsultnpm/sdk-ts';
4
+ import { hoverStyle, IconChevronRight, IconWindowMaximize, IconWindowMinimize, SDKUI_Localizator } from '../../../helper';
5
+ import { formatScalarValue, getUserMetadataSorted } from '../../../helper/dcmtsHelper';
6
+ import { TMColors } from '../../../utils/theme';
7
+ import { TMDcmtTypeIcon } from '../../viewers/TMTidViewer';
8
+ import TMTooltip from '../../base/TMTooltip';
9
+ import { DeviceType, useDeviceType } from '../../base/TMDeviceProvider';
10
+ import { useTMPanelManagerContext } from '../../layout/panelManager/TMPanelManagerContext';
11
+ // l'elenco da archiviare è l'informazione più importante, quindi prende la fetta maggiore
12
+ export const SECTION_WEIGHTS = { masterInfo: 25, archivedDetails: 30, archiveList: 45 };
13
+ export const SECTION_HEADER_HEIGHT_PX = 30;
14
+ // Spessore dei separatori fra i pannelli
15
+ export const PANEL_GUTTER_PX = 10;
16
+ // =================================================================================================
17
+ // HELPER
18
+ // =================================================================================================
19
+ /** Il master è modificabile solo se il tipo documento lo consente */
20
+ export const canUpdateMasterCallback = (dtd, masterDcmt) => (dtd?.perm?.canUpdate === AccessLevelsEx.Yes || dtd?.perm?.canUpdate === AccessLevelsEx.Mixed)
21
+ && masterDcmt?.TID !== undefined && masterDcmt?.DID !== undefined;
22
+ /** Permesso di archiviazione sul tipo documento di dettaglio */
23
+ export const canArchive = (dtd) => dtd?.perm?.canArchive === AccessLevelsEx.Yes || dtd?.perm?.canArchive === AccessLevelsEx.Mixed;
24
+ /**
25
+ * Marcatore delle celle modificabili direttamente in griglia: il doppio clic le porta in modifica,
26
+ * quindi non deve aprire anche il form della riga
27
+ */
28
+ export const INLINE_EDITABLE_CELL_CLASS = 'tm-cell-inline-editable';
29
+ /**
30
+ * Modifica diretta in griglia: solo il testo libero. Liste dati, calcolati, numeratori e speciali
31
+ * hanno editor e vincoli propri, date e numeri una formattazione dedicata: restano al form
32
+ */
33
+ export const isInlineEditableMetadata = (md) => md.dataType === MetadataDataTypes.Varchar
34
+ && (md.dataDomain === undefined || md.dataDomain === MetadataDataDomains.None)
35
+ && md.isSystem !== 1 && md.isSystemDerived !== 1;
36
+ /** Colonne della griglia di riepilogo dai metadati (utente) del tipo documento */
37
+ export const buildColumnsFromDtd = (dtd, renderDataListCell) => getUserMetadataSorted(dtd).map(md => {
38
+ const dataListID = md.dataListID ?? 0;
39
+ const isDataList = md.dataDomain === MetadataDataDomains.DataList && dataListID > 0;
40
+ const viewMode = md.dataListViewMode ?? DataListViewModes.None;
41
+ const dataType = md.dataType;
42
+ const format = md.format?.format;
43
+ const formatCulture = md.format?.formatCulture;
44
+ // Date e numeri usano la formattazione scalare; le liste dati il render comune
45
+ const needsScalarFormat = !isDataList && (dataType === MetadataDataTypes.DateTime || dataType === MetadataDataTypes.Number);
46
+ const isInlineEditable = isInlineEditableMetadata(md);
47
+ return {
48
+ dataField: String(md.id),
49
+ caption: (SDK_Globals.useLocalizedName ? md.nameLoc : md.name) ?? md.name ?? '',
50
+ // La colonna modificabile dichiara il tipo: senza valori DevExtreme non saprebbe che editor usare
51
+ ...(isInlineEditable
52
+ ? {
53
+ dataType: 'string',
54
+ allowEditing: true,
55
+ showEditorAlways: true,
56
+ cssClass: INLINE_EDITABLE_CELL_CLASS,
57
+ // Lunghezza e obbligatorietà del metadato valgono anche in griglia
58
+ editorOptions: md.length ? { maxLength: md.length } : undefined,
59
+ validationRules: String(md.isRequired) === '1' ? [{ type: 'required', message: SDKUI_Localizator.RequiredField }] : undefined,
60
+ }
61
+ : { allowEditing: false }),
62
+ cellRender: isDataList
63
+ ? (cellData) => renderDataListCell(cellData.value, dataListID, viewMode)
64
+ : (needsScalarFormat ? (cellData) => formatScalarValue(cellData.value, dataType, format, formatCulture) : undefined),
65
+ };
66
+ });
67
+ // Accesso al descrittore del tipo documento di dettaglio
68
+ export const getDetailDtdAsync = (detailTID) => detailTID === undefined ? Promise.resolve(undefined) : DcmtTypeListCacheService.GetWithNotGrantedAsync(detailTID, undefined);
69
+ /** Nome visualizzato del tipo documento (localizzato se richiesto) */
70
+ export const getDtdDisplayName = (dtd) => {
71
+ if (!dtd)
72
+ return '';
73
+ return (SDK_Globals.useLocalizedName ? dtd.nameLoc : dtd.name) ?? dtd.name ?? '';
74
+ };
75
+ /** Messaggio del blocco: con righe inserite il tipo documento non è più modificabile */
76
+ export const getBackLockedTitle = () => SDKUI_Localizator.DeleteAllRowsToChangeDcmtType;
77
+ /**
78
+ * Altezze dei pannelli impilati a partire dalle sezioni aperte:
79
+ * una sezione chiusa vale 0% e resta a schermo con la sola testata
80
+ * le aperte si spartiscono tutto lo spazio
81
+ */
82
+ export const sectionPanelHeights = (sections, sectionsOpen, currentDimensions) => {
83
+ const weightOf = (section) => {
84
+ if (!sectionsOpen[section])
85
+ return 0;
86
+ const current = parseFloat(currentDimensions?.[section]?.height ?? '');
87
+ // Sezione che si apre ora (era a 0%) o prima apertura: si riparte dalla quota nominale
88
+ return Number.isFinite(current) && current > 0 ? current : SECTION_WEIGHTS[section];
89
+ };
90
+ const total = sections.reduce((sum, section) => sum + weightOf(section), 0);
91
+ return sections.reduce((acc, section) => {
92
+ acc[section] = { width: '100%', height: total > 0 ? `${(weightOf(section) / total) * 100}%` : '0%' };
93
+ return acc;
94
+ }, {});
95
+ };
96
+ // =================================================================================================
97
+ // STILI
98
+ // =================================================================================================
99
+ export const multiDetailStyles = {
100
+ // Stepper
101
+ stepper: { display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '4px' },
102
+ backArrow: { display: 'flex', alignItems: 'center', justifyContent: 'center', width: '26px', height: '26px', borderRadius: '50%', border: `1.5px solid ${TMColors.primary}`, color: TMColors.primary, cursor: 'pointer', marginRight: '8px', transition: 'all 0.18s ease' },
103
+ stepPill: { display: 'flex', alignItems: 'center', gap: '7px', padding: '3px 10px 3px 4px', borderRadius: '16px', transition: 'all 0.18s ease' },
104
+ stepCircle: { width: '22px', height: '22px', borderRadius: '50%', color: '#ffffff', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '12px', fontWeight: 600, flexShrink: 0, transition: 'all 0.18s ease' },
105
+ stepLabel: { fontSize: '12px', whiteSpace: 'nowrap', display: 'flex', alignItems: 'center' },
106
+ stepConnector: { width: '18px', height: '2px', margin: '0 5px', borderRadius: '1px', flexShrink: 0 },
107
+ stepTypeLabel: { display: 'flex', alignItems: 'center', gap: '6px', maxWidth: '260px' },
108
+ stepTypeLabelText: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
109
+ // Fase 1 - Selezione tipo documento
110
+ selectContainer: { display: 'flex', flexDirection: 'column', alignItems: 'center', flex: 1, gap: '8px', overflow: 'auto', padding: '8px 16px 24px' },
111
+ selectTitle: { fontSize: '18px', fontWeight: 700, color: TMColors.text_normal, textAlign: 'center', marginBottom: '16px' },
112
+ selectList: { display: 'flex', flexDirection: 'column', gap: '8px', width: '100%', maxWidth: '640px' },
113
+ typeCard: { display: 'flex', alignItems: 'center', gap: '12px', padding: '10px 14px', borderRadius: '9px', cursor: 'pointer', boxShadow: '0 1px 3px rgba(0, 0, 0, 0.06)', transition: 'all 0.15s ease' },
114
+ typeCardIcon: { width: '34px', height: '34px', borderRadius: '9px', background: TMColors.primary_container, display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 },
115
+ typeCardName: { flex: 1, fontSize: '14px', fontWeight: 500, color: TMColors.text_normal, whiteSpace: 'normal', wordBreak: 'break-word', lineHeight: 1.3 },
116
+ };
117
+ /** Stili delle sezioni collassabili: qui perché la testata comune (renderAccordionHeader) vive in questo file */
118
+ export const accordionStyles = {
119
+ accordion: { display: 'flex', flexDirection: 'column', minHeight: 0, borderRadius: '8px', border: `1px solid ${TMColors.card_background}`, background: TMColors.default_background, overflow: 'hidden' },
120
+ // Sezione dentro un pannello: l'altezza è quella del pannello, che la sezione riempie. Serve `flex`
121
+ // e non `height: 100%`, perché il pannello chiuso ha altezza 0 e vive del suo ingombro minimo
122
+ accordionInPanel: { flex: 1 },
123
+ accordionHeader: { display: 'flex', alignItems: 'center', gap: '8px', padding: '4px 8px', cursor: 'pointer', userSelect: 'none', transition: 'background 0.15s ease', outline: 'none', flexShrink: 0, minHeight: '28px' },
124
+ accordionTitle: { flex: 1, fontSize: '12px', fontWeight: 600, color: TMColors.text_normal, display: 'flex', alignItems: 'center', gap: '6px', minWidth: 0 },
125
+ accordionBadge: { display: 'inline-flex', alignItems: 'center', justifyContent: 'center', minWidth: '18px', height: '16px', padding: '0 5px', borderRadius: '8px', background: TMColors.primary_container, color: TMColors.primary, fontSize: '10px', fontWeight: 700, flexShrink: 0 },
126
+ accordionListBody: { position: 'relative', flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column', borderTop: `1px solid ${TMColors.card_background}` },
127
+ accordionListPlaceholder: { display: 'flex', flex: 1, alignItems: 'center', justifyContent: 'center', gap: '10px', padding: '16px', color: TMColors.label_normal, fontSize: '13px' },
128
+ accordionExpandBtn: { display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: '20px', height: '20px', padding: 0, borderRadius: '6px', border: 'none', background: 'transparent', color: TMColors.label_normal, cursor: 'pointer', flexShrink: 0, transition: 'background 0.15s ease, color 0.15s ease' },
129
+ };
130
+ export const renderStepper = ({ steps, phase, hasMultipleTypes, isBackLocked, showBackArrow, onBack, onStepClick }) => (_jsxs("div", { style: multiDetailStyles.stepper, children: [showBackArrow && (_jsx(TMTooltip, { content: isBackLocked ? getBackLockedTitle() : SDKUI_Localizator.Back, parentStyle: { marginRight: '10px' }, children: _jsx("div", { onClick: isBackLocked ? undefined : onBack, style: {
131
+ ...multiDetailStyles.backArrow,
132
+ marginRight: 0,
133
+ ...(isBackLocked ? { borderColor: TMColors.disabled, color: TMColors.disabled, background: TMColors.card_background, opacity: 0.55, cursor: 'default' } : {}),
134
+ }, ...(isBackLocked ? {} : hoverStyle({ background: TMColors.primary, color: '#ffffff', transform: 'translateX(-2px)' }, { background: 'transparent', color: TMColors.primary, transform: 'translateX(0)' })), children: _jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", style: { display: 'block' }, children: _jsx("path", { d: "M15 5l-7 7 7 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }) })), steps.map((step, index) => {
135
+ const isActive = step.phase === phase;
136
+ const isCompleted = step.phase < phase;
137
+ // Completato: verde con spunta. Corrente: blu. Da fare: grigio disabilitato
138
+ const accentColor = isCompleted ? TMColors.success : (isActive ? TMColors.primary : TMColors.disabled);
139
+ // Step completato cliccabile per tornare indietro, salvo il lock per righe presenti
140
+ const isClickable = isCompleted && !isBackLocked;
141
+ // Tooltip esplicativo solo sullo step completato quando il ritorno è bloccato dalle righe
142
+ const showLockTooltip = isCompleted && isBackLocked;
143
+ const stepPill = (_jsxs("div", { onClick: isClickable ? () => onStepClick(step.phase) : undefined, style: {
144
+ ...multiDetailStyles.stepPill,
145
+ background: isActive ? TMColors.primary_container : 'transparent',
146
+ boxShadow: isActive ? `inset 0 0 0 1.5px ${TMColors.primary}` : 'none',
147
+ cursor: isClickable ? 'pointer' : 'default',
148
+ ...(showLockTooltip ? { opacity: 0.5, filter: 'grayscale(0.6)' } : {}),
149
+ }, ...(isClickable && !isActive
150
+ ? hoverStyle({ background: TMColors.primary_container, transform: 'translateY(-1px)' }, { background: 'transparent', transform: 'translateY(0)' })
151
+ : {}), children: [hasMultipleTypes && (_jsx("div", { style: { ...multiDetailStyles.stepCircle, background: accentColor, boxShadow: isActive ? `0 2px 6px ${TMColors.primary}55` : 'none' }, children: isCompleted
152
+ ? (_jsx("svg", { width: "13", height: "13", viewBox: "0 0 24 24", fill: "none", style: { display: 'block' }, children: _jsx("path", { d: "M5 13l4 4L19 7", stroke: "#ffffff", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }) }))
153
+ : step.phase + 1 })), _jsx("span", { style: { ...multiDetailStyles.stepLabel, fontWeight: isActive ? 700 : 500, color: accentColor }, children: step.label })] }));
154
+ return (_jsxs(React.Fragment, { children: [showLockTooltip
155
+ ? _jsx(TMTooltip, { content: getBackLockedTitle(), children: stepPill })
156
+ : stepPill, index < steps.length - 1 && (_jsx("div", { style: { ...multiDetailStyles.stepConnector, background: isCompleted ? TMColors.success : TMColors.disabled } }))] }, step.phase));
157
+ })] }));
158
+ export const renderSelectDcmtType = ({ detailRelationItems, selectedRelation, onSelectRelation }) => (_jsxs("div", { style: multiDetailStyles.selectContainer, children: [_jsx("div", { style: multiDetailStyles.selectTitle, children: SDKUI_Localizator.SelectDcmtTypeForDetailArchiving }), _jsx("div", { style: multiDetailStyles.selectList, children: detailRelationItems.map((item) => {
159
+ const isSelected = item.relation === selectedRelation;
160
+ return (_jsxs("div", { onClick: () => onSelectRelation(item), style: {
161
+ ...multiDetailStyles.typeCard,
162
+ border: `1.5px solid ${isSelected ? TMColors.primary : TMColors.card_background}`,
163
+ background: isSelected ? TMColors.primary_container : TMColors.default_background,
164
+ }, ...hoverStyle({ borderColor: TMColors.primary, boxShadow: '0 4px 12px rgba(37, 89, 165, 0.18)' }, { borderColor: isSelected ? TMColors.primary : TMColors.card_background, boxShadow: '0 1px 3px rgba(0, 0, 0, 0.06)' }), children: [_jsx("div", { style: multiDetailStyles.typeCardIcon, children: _jsx(TMDcmtTypeIcon, { dtd: item.detailDtd }) }), _jsx("span", { style: multiDetailStyles.typeCardName, children: getDtdDisplayName(item.detailDtd) }), _jsx(IconChevronRight, { fontSize: 18, color: TMColors.label_normal })] }, item.relation.id ?? item.relation.detailTID));
165
+ }) })] }));
166
+ export const renderAccordionHeader = ({ section, isOpen, tooltip, count, title, actions, panel, onToggleOpen }) => {
167
+ const restBackground = isOpen ? TMColors.toolbar_background : 'transparent';
168
+ // Un pannello ingrandito non si collassa: resterebbe la sola testata al posto di tutto il riepilogo.
169
+ // Dove i pannelli si vedono uno alla volta (mobile) il collasso è precluso per lo stesso motivo
170
+ const canToggle = panel.canCollapse && !panel.isMaximized;
171
+ // Con un pannello alla volta l'ingrandimento non ha nulla da nascondere
172
+ const canMaximize = panel.canMaximize;
173
+ const onToggle = () => onToggleOpen(section, !isOpen);
174
+ const expandTooltip = panel.isMaximized ? SDKUI_Localizator.Minimize : SDKUI_Localizator.ZoomIn;
175
+ return (_jsxs("div", { role: canToggle ? 'button' : undefined, tabIndex: canToggle ? 0 : undefined, "aria-expanded": canToggle ? isOpen : undefined, style: { ...accordionStyles.accordionHeader, background: restBackground, ...(canToggle ? {} : { cursor: 'default' }) }, onClick: canToggle ? onToggle : undefined,
176
+ // Doppio click sulla testata: ingrandisce e riduce, come nei pannelli del prodotto
177
+ onDoubleClick: canMaximize ? () => panel.toggleMaximize() : undefined, onKeyDown: canToggle ? (e) => { if (e.key === 'Enter' || e.key === ' ') {
178
+ e.preventDefault();
179
+ onToggle();
180
+ } } : undefined, title: canToggle ? tooltip : undefined, ...(canToggle ? hoverStyle({ background: TMColors.primary_container }, { background: restBackground }) : {}), children: [_jsxs("span", { style: accordionStyles.accordionTitle, children: [title, _jsx("span", { style: accordionStyles.accordionBadge, children: count })] }), actions, canMaximize && (_jsx("button", { type: 'button', onClick: (e) => { e.stopPropagation(); panel.toggleMaximize(); }, style: accordionStyles.accordionExpandBtn, title: expandTooltip, "aria-label": expandTooltip, ...hoverStyle({ background: TMColors.primary_container, color: TMColors.primary }, { background: 'transparent', color: TMColors.label_normal }), children: panel.isMaximized ? _jsx(IconWindowMinimize, { fontSize: 14 }) : _jsx(IconWindowMaximize, { fontSize: 14 }) })), canToggle && (_jsx(IconChevronRight, { fontSize: 16, color: TMColors.label_normal, style: { transform: isOpen ? 'rotate(90deg)' : 'none', transition: 'transform 0.2s ease', flexShrink: 0 } }))] }));
181
+ };
182
+ /**
183
+ * Contenuto di un pannello: il contesto del panel manager è leggibile solo dentro l'albero del
184
+ * provider, quindi è qui che si prende lo stato di ingrandimento da passare alla sezione
185
+ */
186
+ export const TMSummarySectionSlot = ({ section, render, onBeforeMaximize }) => {
187
+ const { maximizedPanels, toggleMaximize } = useTMPanelManagerContext();
188
+ const isMaximized = maximizedPanels.includes(section);
189
+ // Su mobile il panel manager mostra un pannello alla volta: la sezione è già a tutto schermo, e
190
+ // ingrandirla nasconderebbe la barra con cui si passa da una sezione all'altra; chiuderla lascerebbe
191
+ // a schermo la sola testata, perché non ci sono altre sezioni a cui cedere lo spazio
192
+ const isMobile = useDeviceType() === DeviceType.MOBILE;
193
+ // Una sezione collassata non ha corpo: ingrandirla mostrerebbe un pannello vuoto, senza
194
+ // nemmeno poterla riaprire (da ingrandita il collasso è bloccato), quindi la si apre prima
195
+ const toggleMaximizeSection = () => {
196
+ if (!isMaximized)
197
+ onBeforeMaximize?.(section);
198
+ toggleMaximize(section);
199
+ };
200
+ return _jsx(_Fragment, { children: render({ isMaximized, canMaximize: !isMobile, canCollapse: !isMobile, toggleMaximize: toggleMaximizeSection }) });
201
+ };
202
+ /**
203
+ * Tiene allineate le altezze dei pannelli al collasso delle sezioni: il panel manager non
204
+ * conosce il collasso, quindi è qui che l'apertura di una sezione si traduce nelle nuove quote.
205
+ * Vive dentro il provider perché il contesto è leggibile solo lì
206
+ */
207
+ export const TMSectionPanelsHeights = ({ sections, sectionsOpen }) => {
208
+ const { panelDimensions, panelVisibility, setPanelDimensionsById, maximizedPanels } = useTMPanelManagerContext();
209
+ // Con un pannello ingrandito le quote sono quelle dell'ingrandimento (100% e 0%): riallinearle al
210
+ // collasso lo svuoterebbe, quindi si aspetta il ritorno alla vista normale per rifare i conti
211
+ const hasMaximizedPanel = maximizedPanels.length > 0;
212
+ // Le altezze correnti si leggono da un ref: fra le dipendenze rientrerebbero a ogni ridimensionamento,
213
+ // mentre qui interessa solo il collasso
214
+ const dimensionsRef = useRef(panelDimensions);
215
+ dimensionsRef.current = panelDimensions;
216
+ // Le prime altezze le imposta il provider da initialDimensions, già calcolate sul collasso corrente
217
+ const isFirstRun = useRef(true);
218
+ useEffect(() => {
219
+ if (isFirstRun.current) {
220
+ isFirstRun.current = false;
221
+ return;
222
+ }
223
+ if (hasMaximizedPanel)
224
+ return;
225
+ // Solo i pannelli a schermo si spartiscono l'altezza: contando anche i nascosti (su mobile ne
226
+ // resta visibile uno solo) al pannello a schermo toccherebbe la sua sola quota nominale,
227
+ // lasciando vuoto lo spazio dei pannelli che non ci sono. Chi è fuori schermo resta alle proprie
228
+ // quote, che sono quelle da cui il panel manager riparte quando lo si torna a mostrare
229
+ const visibleSections = sections.filter(section => panelVisibility[section] !== false);
230
+ const heights = sectionPanelHeights(visibleSections, sectionsOpen, dimensionsRef.current);
231
+ visibleSections.forEach(section => setPanelDimensionsById(section, heights[section].width, heights[section].height));
232
+ }, [sectionsOpen, hasMaximizedPanel, panelVisibility]);
233
+ return null;
234
+ };
@@ -132,6 +132,19 @@ export interface TMRelationViewerProps {
132
132
  * Useful to disable interactions (like context menu) during loading.
133
133
  */
134
134
  onLoadingStateChanged?: (isLoading: boolean) => void;
135
+ /**
136
+ * Invoked on mount to hand over a function that stops the ongoing correlations
137
+ * calculation: no further GetMetadata calls are performed and only the
138
+ * correlations already calculated are kept.
139
+ * The function is synchronous, so it can be safely called right before
140
+ * unmounting the viewer (e.g. when navigating back).
141
+ */
142
+ onStopCalculationReady?: (stopCalculation: () => void) => void;
143
+ /**
144
+ * Callback invoked when the calculation has actually been stopped
145
+ * (loadData terminated after an abort request).
146
+ */
147
+ onCalculationStopped?: () => void;
135
148
  }
136
149
  /**
137
150
  * Check if document type has detail relations
@@ -150,7 +163,7 @@ export declare const getDisplayValueByColumn: (col: DataColumnDescriptor | undef
150
163
  * For each document, fetches complete metadata using GetMetadataAsync to ensure
151
164
  * all metadata properties (isSpecialSearchOutput, permissions, etc.) are available
152
165
  */
153
- export declare const searchResultToDataSource: (searchResult: SearchResultDescriptor | undefined, hideSysMetadata?: boolean) => Promise<any[]>;
166
+ export declare const searchResultToDataSource: (searchResult: SearchResultDescriptor | undefined, hideSysMetadata?: boolean, signal?: AbortSignal) => Promise<any[]>;
154
167
  export declare const DEFAULT_RELATION_EXPAND_LEVEL = 4;
155
168
  declare const TMRelationViewer: React.FC<TMRelationViewerProps>;
156
169
  export default TMRelationViewer;
@@ -70,7 +70,7 @@ export const getDisplayValueByColumn = (col, value) => {
70
70
  * For each document, fetches complete metadata using GetMetadataAsync to ensure
71
71
  * all metadata properties (isSpecialSearchOutput, permissions, etc.) are available
72
72
  */
73
- export const searchResultToDataSource = async (searchResult, hideSysMetadata) => {
73
+ export const searchResultToDataSource = async (searchResult, hideSysMetadata, signal) => {
74
74
  const rows = searchResult?.dtdResult?.rows ?? [];
75
75
  const output = [];
76
76
  // Find TID and DID column indices
@@ -78,6 +78,9 @@ export const searchResultToDataSource = async (searchResult, hideSysMetadata) =>
78
78
  const tidColIndex = columns.findIndex(col => col.caption?.toUpperCase() === 'TID');
79
79
  const didColIndex = columns.findIndex(col => col.caption?.toUpperCase() === 'DID');
80
80
  for (let index = 0; index < rows.length; index++) {
81
+ // Interruzione richiesta dall'utente: restituisce i documenti già elaborati
82
+ if (signal?.aborted)
83
+ break;
81
84
  const row = rows[index];
82
85
  // Extract TID and DID from row
83
86
  const tid = tidColIndex >= 0 ? Number(row[tidColIndex]) : searchResult?.fromTID;
@@ -144,7 +147,7 @@ export const searchResultToDataSource = async (searchResult, hideSysMetadata) =>
144
147
  return output;
145
148
  };
146
149
  export const DEFAULT_RELATION_EXPAND_LEVEL = 4; // Default maximum depth level for expansion (can be adjusted)
147
- const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndicator = true, allowShowZeroDcmts = true, initialShowZeroDcmts = false, allowedTIDs, allowMultipleSelection = false, focusedItem, selectedItems, onFocusedItemChanged, onSelectedItemsChanged, onAllItemsChanged, onDocumentDoubleClick, customItemRender, customDocumentStyle, customMainContainerContent, customDocumentContent, showMetadataNames = false, maxDepthLevel = 2, invertMasterNavigation = true, additionalStaticItems, showMainDocument = true, labelMainContainer, onNoRelationsFound, onItemContextMenu, focusedItemFormData = [], showExpandAllButton = false, defaultExpandAll = false, onLoadingStateChanged }) => {
150
+ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndicator = true, allowShowZeroDcmts = true, initialShowZeroDcmts = false, allowedTIDs, allowMultipleSelection = false, focusedItem, selectedItems, onFocusedItemChanged, onSelectedItemsChanged, onAllItemsChanged, onDocumentDoubleClick, customItemRender, customDocumentStyle, customMainContainerContent, customDocumentContent, showMetadataNames = false, maxDepthLevel = 2, invertMasterNavigation = true, additionalStaticItems, showMainDocument = true, labelMainContainer, onNoRelationsFound, onItemContextMenu, focusedItemFormData = [], showExpandAllButton = false, defaultExpandAll = false, onLoadingStateChanged, onStopCalculationReady, onCalculationStopped }) => {
148
151
  // State
149
152
  const [dcmtTypes, setDcmtTypes] = useState([]);
150
153
  const [treeData, setTreeData] = useState([]);
@@ -159,6 +162,8 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
159
162
  const [waitPanelValuePrimary, setWaitPanelValuePrimary] = useState(0);
160
163
  const [waitPanelMaxValuePrimary, setWaitPanelMaxValuePrimary] = useState(0);
161
164
  const [abortController] = useState(new AbortController());
165
+ // True quando l'utente ha interrotto il calcolo delle correlazioni (pulsante "Interrompi")
166
+ const [loadStoppedByUser, setLoadStoppedByUser] = useState(false);
162
167
  const [showExpansionWaitPanel, setShowExpansionWaitPanel] = useState(false);
163
168
  const [expansionWaitPanelText, setExpansionWaitPanelText] = useState('');
164
169
  const [expansionWaitPanelValue, setExpansionWaitPanelValue] = useState(0);
@@ -191,6 +196,27 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
191
196
  const isLoading = showWaitPanel || showExpansionWaitPanel;
192
197
  onLoadingStateChanged?.(isLoading);
193
198
  }, [showWaitPanel, showExpansionWaitPanel, onLoadingStateChanged]);
199
+ // Mantiene l'AbortController dell'espansione in corso accessibile da callback stabili
200
+ const expansionAbortControllerRef = React.useRef(undefined);
201
+ useEffect(() => {
202
+ expansionAbortControllerRef.current = expansionAbortController;
203
+ }, [expansionAbortController]);
204
+ /**
205
+ * Interrompe il calcolo delle correlazioni (iniziale e/o espansione in corso):
206
+ * non vengono eseguite ulteriori chiamate GetMetadata e vengono mantenute
207
+ * solo le correlazioni già calcolate.
208
+ * È sincrona: può essere invocata immediatamente prima di smontare il viewer
209
+ * (es. pulsante "Indietro"), quando un effect non farebbe in tempo.
210
+ */
211
+ const stopCalculation = useCallback(() => {
212
+ if (!abortController.signal.aborted)
213
+ abortController.abort();
214
+ expansionAbortControllerRef.current?.abort();
215
+ }, [abortController]);
216
+ // Espone la funzione di interruzione al componente padre
217
+ useEffect(() => {
218
+ onStopCalculationReady?.(stopCalculation);
219
+ }, [onStopCalculationReady, stopCalculation]);
194
220
  // Sincronizza expandLevel quando userSettings.searchSettings.relationExpandLevel cambia
195
221
  useEffect(() => {
196
222
  const globalExpandLevel = SDKUI_Globals.userSettings?.searchSettings?.relationExpandLevel;
@@ -220,7 +246,7 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
220
246
  /**
221
247
  * Recursively retrieve detail documents (adapted from TMMasterDetailDcmts.tsx)
222
248
  */
223
- const getDetailDcmtsAsync = useCallback(async (mTID, mDID, maxLevel) => {
249
+ const getDetailDcmtsAsync = useCallback(async (mTID, mDID, maxLevel, signal) => {
224
250
  const items = [];
225
251
  if (!mTID)
226
252
  return [];
@@ -240,6 +266,9 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
240
266
  return items;
241
267
  const results = await searchEngine.GetAllDetailDcmtsAsync(mTID, mDID) ?? [];
242
268
  for (const searchResult of results) {
269
+ // Interruzione richiesta dall'utente: restituisce le correlazioni già calcolate
270
+ if (signal?.aborted)
271
+ break;
243
272
  // Skip if allowedTIDs is set and this TID is not allowed
244
273
  if (allowedTIDs && searchResult.fromTID && !allowedTIDs.includes(searchResult.fromTID)) {
245
274
  continue;
@@ -261,7 +290,7 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
261
290
  expanded: false,
262
291
  hidden: false
263
292
  };
264
- const source = await searchResultToDataSource(searchResult);
293
+ const source = await searchResultToDataSource(searchResult, undefined, signal);
265
294
  if (source && source.length > 0) {
266
295
  const dcmtDetails = [];
267
296
  // Check once if this document type can have detail relations
@@ -307,7 +336,7 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
307
336
  /**
308
337
  * Recursively retrieve master documents
309
338
  */
310
- const getMasterDcmtsAsync = useCallback(async (dTID, dDID, maxLevel) => {
339
+ const getMasterDcmtsAsync = useCallback(async (dTID, dDID, maxLevel, signal) => {
311
340
  const items = [];
312
341
  if (!dTID)
313
342
  return [];
@@ -327,6 +356,9 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
327
356
  return items;
328
357
  const results = await searchEngine.GetAllMasterDcmtsAsync(dTID, dDID) ?? [];
329
358
  for (const searchResult of results) {
359
+ // Interruzione richiesta dall'utente: restituisce le correlazioni già calcolate
360
+ if (signal?.aborted)
361
+ break;
330
362
  // Skip if allowedTIDs is set and this TID is not allowed
331
363
  if (allowedTIDs && searchResult.fromTID && !allowedTIDs.includes(searchResult.fromTID)) {
332
364
  continue;
@@ -348,7 +380,7 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
348
380
  expanded: false,
349
381
  hidden: false
350
382
  };
351
- const source = await searchResultToDataSource(searchResult);
383
+ const source = await searchResultToDataSource(searchResult, undefined, signal);
352
384
  if (source && source.length > 0) {
353
385
  const dcmtMasters = [];
354
386
  // Check once if this document type can have master relations (for inverted mode)
@@ -576,7 +608,7 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
576
608
  }
577
609
  const dtd = await DcmtTypeListCacheService.GetAsync(dcmt.TID);
578
610
  // Parse document values
579
- const docValues = await searchResultToDataSource(result);
611
+ const docValues = await searchResultToDataSource(result, undefined, abortController.signal);
580
612
  const docRow = docValues.length > 0 ? docValues[0] : undefined;
581
613
  // Generate unique GUID for this container
582
614
  const containerGUID = genUniqueId();
@@ -585,16 +617,21 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
585
617
  // ========================================================================
586
618
  if (isForMaster && !invertMasterNavigation) {
587
619
  // Carica i master documents
588
- const masterDocs = await getMasterDcmtsAsync(dcmt.TID, dcmt.DID, maxDepthLevel);
620
+ const masterDocs = await getMasterDcmtsAsync(dcmt.TID, dcmt.DID, maxDepthLevel, abortController.signal);
589
621
  // Per ogni master, carica i suoi detail (incluso il documento corrente)
590
622
  for (const masterContainer of masterDocs) {
623
+ if (abortController.signal.aborted)
624
+ break;
591
625
  if (!masterContainer.items)
592
626
  continue;
593
627
  // Per ogni master document nel container, carica i detail
594
628
  for (const masterDoc of masterContainer.items) {
629
+ // Interruzione richiesta dall'utente: mantiene i dati già calcolati
630
+ if (abortController.signal.aborted)
631
+ break;
595
632
  if (masterDoc.tid && masterDoc.did) {
596
633
  // Carica i detail del master (incluso il documento di partenza)
597
- const detailDocs = await getDetailDcmtsAsync(masterDoc.tid, masterDoc.did, 1);
634
+ const detailDocs = await getDetailDcmtsAsync(masterDoc.tid, masterDoc.did, 1, abortController.signal);
598
635
  masterDoc.items = detailDocs;
599
636
  masterDoc.itemsCount = detailDocs.length;
600
637
  masterDoc.isLoaded = true;
@@ -627,8 +664,8 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
627
664
  else {
628
665
  // Load related documents (detail or master based on isForMaster flag)
629
666
  const relatedDocs = isForMaster
630
- ? await getMasterDcmtsAsync(dcmt.TID, dcmt.DID, maxDepthLevel)
631
- : await getDetailDcmtsAsync(dcmt.TID, dcmt.DID, maxDepthLevel);
667
+ ? await getMasterDcmtsAsync(dcmt.TID, dcmt.DID, maxDepthLevel, abortController.signal)
668
+ : await getDetailDcmtsAsync(dcmt.TID, dcmt.DID, maxDepthLevel, abortController.signal);
632
669
  // Se showMainDocument è false, mostra i container dei dettagli direttamente sotto il container principale
633
670
  if (!showMainDocument) {
634
671
  // Check if a container for this TID already exists in the tree
@@ -775,8 +812,15 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
775
812
  // Check recursively if there are any actual documents
776
813
  return hasNoActualDocuments(container.items);
777
814
  });
815
+ // Calcolo interrotto dall'utente: mostra solo ciò che è stato calcolato,
816
+ // senza notificare l'assenza di correlazioni (il risultato è parziale, non definitivo)
817
+ const wasStopped = abortController.signal.aborted;
818
+ if (wasStopped) {
819
+ setLoadStoppedByUser(true);
820
+ onCalculationStopped?.();
821
+ }
778
822
  // If no relations found, notify parent
779
- if (hasNoRelations && onNoRelationsFound) {
823
+ if (!wasStopped && hasNoRelations && onNoRelationsFound) {
780
824
  onNoRelationsFound();
781
825
  }
782
826
  // Update metadata error count state
@@ -804,7 +848,7 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
804
848
  // Now it will correctly detect expanded nodes and add infoMessage if all children are hidden
805
849
  const processedTree = updateHiddenProperty(expandedTree);
806
850
  setTreeData(processedTree);
807
- }, [inputDcmts, dcmtTypes, maxDepthLevel, isForMaster, invertMasterNavigation, getDetailDcmtsAsync, getMasterDcmtsAsync, abortController, updateHiddenProperty, showMainDocument, labelMainContainer, onNoRelationsFound]);
851
+ }, [inputDcmts, dcmtTypes, maxDepthLevel, isForMaster, invertMasterNavigation, getDetailDcmtsAsync, getMasterDcmtsAsync, abortController, updateHiddenProperty, showMainDocument, labelMainContainer, onNoRelationsFound, onCalculationStopped]);
808
852
  /**
809
853
  * Merge main tree data with additional static items
810
854
  */
@@ -1047,15 +1091,15 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
1047
1091
  let loadedItems = [];
1048
1092
  if (isForMaster && !invertMasterNavigation) {
1049
1093
  // Original mode: detail documents load detail documents (natural detail→detail navigation)
1050
- loadedItems = await getDetailDcmtsAsync(node.tid, node.did, 1);
1094
+ loadedItems = await getDetailDcmtsAsync(node.tid, node.did, 1, newAbortController.signal);
1051
1095
  }
1052
1096
  else if (isForMaster) {
1053
1097
  // Inverted master mode: load master documents
1054
- loadedItems = await getMasterDcmtsAsync(node.tid, node.did, 1);
1098
+ loadedItems = await getMasterDcmtsAsync(node.tid, node.did, 1, newAbortController.signal);
1055
1099
  }
1056
1100
  else {
1057
1101
  // Standard mode: load detail documents
1058
- loadedItems = await getDetailDcmtsAsync(node.tid, node.did, 1);
1102
+ loadedItems = await getDetailDcmtsAsync(node.tid, node.did, 1, newAbortController.signal);
1059
1103
  }
1060
1104
  // Espandi automaticamente il primo container se ci sono documenti correlati
1061
1105
  if (loadedItems.length > 0 && loadedItems[0].isContainer) {
@@ -1417,13 +1461,13 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
1417
1461
  let loadedItems = [];
1418
1462
  // Carica i documenti correlati (detail o master in base alla modalità)
1419
1463
  if (isForMaster && !invertMasterNavigation) {
1420
- loadedItems = await getDetailDcmtsAsync(node.tid, node.did, 1);
1464
+ loadedItems = await getDetailDcmtsAsync(node.tid, node.did, 1, newAbortController.signal);
1421
1465
  }
1422
1466
  else if (isForMaster) {
1423
- loadedItems = await getMasterDcmtsAsync(node.tid, node.did, 1);
1467
+ loadedItems = await getMasterDcmtsAsync(node.tid, node.did, 1, newAbortController.signal);
1424
1468
  }
1425
1469
  else {
1426
- loadedItems = await getDetailDcmtsAsync(node.tid, node.did, 1);
1470
+ loadedItems = await getDetailDcmtsAsync(node.tid, node.did, 1, newAbortController.signal);
1427
1471
  }
1428
1472
  // Applica le regole di visibilità (showZeroDcmts)
1429
1473
  expandedNode.items = updateHiddenProperty(loadedItems);
@@ -1524,6 +1568,10 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
1524
1568
  return _jsx("div", { style: { padding: '20px', textAlign: 'center' }, children: _jsx(TMWaitPanel, { title: SDKUI_Localizator.LoadingDetailDocuments, showPrimary: true, textPrimary: waitPanelTextPrimary, valuePrimary: waitPanelValuePrimary, maxValuePrimary: waitPanelMaxValuePrimary, isCancelable: true, abortController: abortController, onAbortClick: () => { setTimeout(() => { abortController.abort(); }, 1000); } }) });
1525
1569
  }
1526
1570
  if (mergedTreeData.length === 0) {
1571
+ // Calcolo interrotto dall'utente prima di aver calcolato qualsiasi correlazione
1572
+ if (loadStoppedByUser) {
1573
+ return _jsx(TMToppyMessage, { message: SDKUI_Localizator.RelationsCalculationStopped });
1574
+ }
1527
1575
  // Se NON isForMaster e tutti i GetMetadataAsync sono falliti
1528
1576
  if (!isForMaster && metadataErrorCount === inputDcmts.length) {
1529
1577
  return _jsx(TMToppyMessage, { message: SDKUI_Localizator.DocumentsNotAvailableOrNoCorrelations });
@@ -1534,7 +1582,8 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
1534
1582
  return _jsx("div", { style: { padding: '20px', textAlign: 'center', color: '#666' }, children: SDKUI_Localizator.NoRelationsAvailable });
1535
1583
  }
1536
1584
  // Se isForMaster e non ci sono master documents disponibili
1537
- if (isForMaster && totalMasterDocuments === 0) {
1585
+ // (se il calcolo è stato interrotto l'albero parziale viene comunque mostrato)
1586
+ if (isForMaster && totalMasterDocuments === 0 && !loadStoppedByUser) {
1538
1587
  return _jsx(TMToppyMessage, { message: SDKUI_Localizator.NoMasterDocumentsAvailable });
1539
1588
  }
1540
1589
  return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', height: '100%', minHeight: 0, width: '100%' }, children: [showExpandAllButton && (_jsxs("div", { style: { flexShrink: 0, display: 'flex', alignItems: 'center', gap: '6px', height: '40px', paddingLeft: '10px', backgroundColor: TMColors.toolbar_background }, children: [_jsx(TMTooltip, { content: expandLevel === 0
@@ -5,7 +5,7 @@ import TMSavedQuerySelector from './TMSavedQuerySelector';
5
5
  import TMTreeSelector from './TMTreeSelector';
6
6
  import { TabPanel, Item } from 'devextreme-react/tab-panel';
7
7
  import TMSearchQueryPanel, { refreshLastSearch } from './TMSearchQueryPanel';
8
- import { getSysAllDcmtsSQD, IconFilter, IconRecentlyViewed, IconSavedQuery, IconTree, removeMruTid, SDKUI_Globals, SDKUI_Localizator, updateMruTids } from '../../../helper';
8
+ import { getSysAllDcmtsSQD, IconFilter, IconRecentlyViewed, IconSavedQuery, IconTree, mergeSearchResultsAppend, removeMruTid, SDKUI_Globals, SDKUI_Localizator, updateMruTids } from '../../../helper';
9
9
  import TMSearchResult from './TMSearchResult';
10
10
  import TMRecentsManager from '../../grids/TMRecentsManager';
11
11
  import { SearchResultContext } from '../../../ts';
@@ -164,6 +164,32 @@ const TMSearch = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTask
164
164
  console.error("Error refreshing search:", error);
165
165
  }
166
166
  };
167
+ const handleSearchCompleted = useCallback((searchResult, qd, append) => {
168
+ if (searchResult.length <= 0) {
169
+ // In ricerca normale un array vuoto resetta i risultati; in accoda si mantiene il set accumulato
170
+ if (!append)
171
+ setSearchResult(searchResult);
172
+ return;
173
+ }
174
+ const newResult = searchResult[0];
175
+ // In modalità accoda unisce il nuovo risultato a quello precedente (più recenti in cima).
176
+ setSearchResult(prev => {
177
+ if (append && prev.length > 0 && prev[0]?.fromTID === newResult?.fromTID) {
178
+ const merged = mergeSearchResultsAppend(prev[0], newResult);
179
+ return merged ? [merged] : searchResult;
180
+ }
181
+ return searchResult;
182
+ });
183
+ setLastQdSearched(qd);
184
+ setCurrentSearchView(TMSearchViews.Result);
185
+ // Salvataggio ultimi 10 TIDs
186
+ let fromTID = searchResult?.[0].fromTID;
187
+ let newMruTIDS = updateMruTids(SDKUI_Globals.userSettings.searchSettings.mruTIDs, fromTID);
188
+ SDKUI_Globals.userSettings.searchSettings.mruTIDs = newMruTIDS;
189
+ setMruTIDs(newMruTIDS);
190
+ setCurrentMruTID(fromTID);
191
+ setShowSearchResults(true);
192
+ }, []);
167
193
  const isMobile = deviceType === DeviceType.MOBILE;
168
194
  const isTabletOrMobile = deviceType === DeviceType.TABLET || deviceType === DeviceType.MOBILE;
169
195
  // --- JSX WRAPPERS ---
@@ -182,23 +208,10 @@ const TMSearch = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTask
182
208
  SDKUI_Globals.userSettings.searchSettings.mruTIDs = newMruTIDS;
183
209
  setMruTIDs(newMruTIDS);
184
210
  } }), [mruTIDs, currentMruTID, deviceType]);
185
- const tmSearchQueryPanelElement = useMemo(() => _jsx(TMSearchQueryPanelWrapper, { passToArchiveCallback: passToArchiveCallback, isExpertMode: isExpertMode, showBackToResultButton: searchResult.length > 0, fromDTD: fromDTD, SQD: currentSQD, inputMids: inputMids, maxDcmtsToBeReturned: maxDcmtsToBeReturned, onBackToResult: () => { setCurrentSearchView(TMSearchViews.Result); }, onSearchCompleted: (searchResult, qd) => {
186
- setSearchResult(searchResult);
187
- if (searchResult.length <= 0)
188
- return;
189
- setLastQdSearched(qd);
190
- setCurrentSearchView(TMSearchViews.Result);
191
- // Salvataggio ultimi 10 TIDs
192
- let fromTID = searchResult?.[0].fromTID;
193
- let newMruTIDS = updateMruTids(SDKUI_Globals.userSettings.searchSettings.mruTIDs, fromTID);
194
- SDKUI_Globals.userSettings.searchSettings.mruTIDs = newMruTIDS;
195
- setMruTIDs(newMruTIDS);
196
- setCurrentMruTID(fromTID);
197
- setShowSearchResults(true);
198
- }, onSqdSaved: async (newSqd) => {
211
+ const tmSearchQueryPanelElement = useMemo(() => _jsx(TMSearchQueryPanelWrapper, { passToArchiveCallback: passToArchiveCallback, isExpertMode: isExpertMode, showBackToResultButton: searchResult.length > 0, fromDTD: fromDTD, SQD: currentSQD, inputMids: inputMids, maxDcmtsToBeReturned: maxDcmtsToBeReturned, onBackToResult: () => { setCurrentSearchView(TMSearchViews.Result); }, onSearchCompleted: handleSearchCompleted, onSqdSaved: async (newSqd) => {
199
212
  await loadDataSQDsAsync(true, newSqd.masterTID);
200
213
  await setSQDAsync(newSqd);
201
- } }), [fromDTD, showSearchResults, setShowSearchResults, currentSQD, isExpertMode, mruTIDs, searchResult, passToArchiveCallback, inputMids, maxDcmtsToBeReturned]);
214
+ } }), [fromDTD, showSearchResults, setShowSearchResults, currentSQD, isExpertMode, mruTIDs, searchResult, passToArchiveCallback, inputMids, maxDcmtsToBeReturned, handleSearchCompleted]);
202
215
  const tmSavedQuerySelectorElement = useMemo(() => _jsxs(TabPanel, { width: "100%", height: "100%", showNavButtons: true, repaintChangesOnly: true, selectedIndex: currentSQDMode, onSelectedIndexChange: (index) => setCurrentSQDMode(index), children: [(currentTID || currentSQD) ? _jsx(Item, { title: fromDTD?.nameLoc, children: _jsx(TMSavedQuerySelectorWrapper, { allowShowSearch: false, items: filteredByTIDSQDs, selectedId: currentSQD?.id, onRefreshData: () => { loadDataSQDsAsync(true); }, onItemClick: (sqd) => {
203
216
  onSQDItemClick(sqd, setSQDAsync);
204
217
  }, onDeleted: (sqd) => onSQDDeleted(sqd, sqd.id == currentSQD?.id ? filteredByTIDSQDs.find(o => o.id == 1) : currentSQD, setSQDAsync), refreshFavoriteSavedQueries: refreshFavoriteSavedQueries }) }) : _jsx(_Fragment, {}), _jsx(Item, { title: SDKUI_Localizator.AllFemale, children: _jsx(TMSavedQuerySelectorWrapper, { allowShowSearch: true, items: allSQDs, manageDefault: false, onItemClick: (sqd) => {
@@ -58,10 +58,12 @@ const TMSearchQueryEditor = ({ qd, dcmtTypesList = [], isExpertMode = SDKUI_Glob
58
58
  const handleItemSelect = useCallback((tid, mid) => {
59
59
  if (currentEditingMID !== mid)
60
60
  setCurrentEditingMID(mid);
61
- if (!focusedTidMid || mid !== focusedTidMid.mid) {
62
- setFocusedTidMid({ tid: tid, mid: mid });
61
+ if (!focusedTidMid || mid !== focusedTidMid.mid || tid !== focusedTidMid.tid) {
62
+ const newFocusedTidMid = { tid: tid, mid: mid };
63
+ setFocusedTidMid(newFocusedTidMid);
64
+ onFocusedMetadataChanged?.(newFocusedTidMid);
63
65
  }
64
- }, [currentEditingMID, focusedTidMid]);
66
+ }, [currentEditingMID, focusedTidMid, onFocusedMetadataChanged]);
65
67
  const handleAdvancedMenuClick = useCallback((e) => {
66
68
  if (e.button === AdvancedMenuButtons.MakeEditable && e.mid) {
67
69
  addOrRemoveEditableList(e.mid);
@@ -12,7 +12,7 @@ interface ITMSearchQueryPanelProps {
12
12
  onBack?: () => void;
13
13
  onBackToResult?: () => void;
14
14
  onSqdSaved?: (newSqd: SavedQueryDescriptor) => void;
15
- onSearchCompleted?: (searchResult: SearchResultDescriptor[], qd: QueryDescriptor | undefined) => void;
15
+ onSearchCompleted?: (searchResult: SearchResultDescriptor[], qd: QueryDescriptor | undefined, append?: boolean) => void;
16
16
  onClosePanel?: () => void;
17
17
  allowMaximize?: boolean;
18
18
  onMaximizePanel?: () => void;