@topconsultnpm/sdkui-react 6.21.0-dev2.9 → 6.21.0-dev3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/lib/components/NewComponents/ContextMenu/styles.d.ts +4 -4
  2. package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +2 -2
  3. package/lib/components/base/TMAccordionNew.js +1 -0
  4. package/lib/components/base/TMAreaManager.js +19 -3
  5. package/lib/components/base/TMDataGrid.js +2 -2
  6. package/lib/components/base/TMFileManagerDataGridView.js +4 -4
  7. package/lib/components/base/TMFileManagerThumbnailItems.js +3 -3
  8. package/lib/components/base/TMFileManagerUtils.d.ts +7 -0
  9. package/lib/components/base/TMFileManagerUtils.js +14 -1
  10. package/lib/components/base/TMModal.d.ts +1 -0
  11. package/lib/components/base/TMModal.js +2 -2
  12. package/lib/components/base/TMPanel.d.ts +7 -4
  13. package/lib/components/base/TMPanel.js +58 -26
  14. package/lib/components/base/TMTreeView.js +24 -17
  15. package/lib/components/base/TMWaitPanel.d.ts +3 -1
  16. package/lib/components/base/TMWaitPanel.js +14 -9
  17. package/lib/components/choosers/TMDistinctValues.js +35 -21
  18. package/lib/components/choosers/TMDynDataListItemChooser.js +6 -1
  19. package/lib/components/choosers/TMUserChooser.d.ts +4 -0
  20. package/lib/components/choosers/TMUserChooser.js +7 -5
  21. package/lib/components/editors/TMEditorStyled.d.ts +6 -6
  22. package/lib/components/editors/TMFormulaEditor.d.ts +2 -0
  23. package/lib/components/editors/TMFormulaEditor.js +75 -21
  24. package/lib/components/editors/TMMetadataEditor.js +6 -2
  25. package/lib/components/editors/TMMetadataValues.js +2 -1
  26. package/lib/components/editors/TMRadioButton.js +7 -5
  27. package/lib/components/editors/TMTextBox.d.ts +2 -0
  28. package/lib/components/editors/TMTextBox.js +3 -3
  29. package/lib/components/features/archive/TMArchive.js +1 -1
  30. package/lib/components/features/blog/TMBlogCommentForm.js +5 -2
  31. package/lib/components/features/documents/TMCopyToFolderForm.d.ts +24 -0
  32. package/lib/components/features/documents/TMCopyToFolderForm.js +401 -0
  33. package/lib/components/features/documents/TMDcmtForm.d.ts +1 -0
  34. package/lib/components/features/documents/TMDcmtForm.js +126 -38
  35. package/lib/components/features/documents/TMDcmtIcon.js +1 -1
  36. package/lib/components/features/documents/TMDcmtPreview.d.ts +1 -0
  37. package/lib/components/features/documents/TMDcmtPreview.js +2 -2
  38. package/lib/components/features/documents/TMDcmtTasks.d.ts +1 -0
  39. package/lib/components/features/documents/TMDcmtTasks.js +2 -2
  40. package/lib/components/features/documents/TMDownloadRelationViewerSection.d.ts +23 -0
  41. package/lib/components/features/documents/TMDownloadRelationViewerSection.js +173 -0
  42. package/lib/components/features/documents/TMFileUploader.js +1 -1
  43. package/lib/components/features/documents/TMMasterDetailDcmts.d.ts +2 -0
  44. package/lib/components/features/documents/TMMasterDetailDcmts.js +28 -9
  45. package/lib/components/features/documents/TMMergeToPdfForm.d.ts +24 -0
  46. package/lib/components/features/documents/TMMergeToPdfForm.js +309 -0
  47. package/lib/components/features/documents/TMRelationViewer.d.ts +13 -0
  48. package/lib/components/features/documents/TMRelationViewer.js +80 -6
  49. package/lib/components/features/documents/copyAndMergeDcmtsShared.d.ts +58 -0
  50. package/lib/components/features/documents/copyAndMergeDcmtsShared.js +266 -0
  51. package/lib/components/features/search/SignatureParamsManager.d.ts +70 -0
  52. package/lib/components/features/search/SignatureParamsManager.js +145 -0
  53. package/lib/components/features/search/TMSavedQuerySelector.d.ts +2 -2
  54. package/lib/components/features/search/TMSavedQuerySelector.js +3 -2
  55. package/lib/components/features/search/TMSearch.d.ts +4 -1
  56. package/lib/components/features/search/TMSearch.js +16 -10
  57. package/lib/components/features/search/TMSearchQueryEditor.js +14 -8
  58. package/lib/components/features/search/TMSearchQueryPanel.js +1 -1
  59. package/lib/components/features/search/TMSearchResult.d.ts +2 -0
  60. package/lib/components/features/search/TMSearchResult.js +118 -23
  61. package/lib/components/features/search/TMViewHistoryDcmt.js +1 -1
  62. package/lib/components/features/workflow/diagram/queryDescriptorParser.js +3 -6
  63. package/lib/components/forms/Login/TMLoginForm.d.ts +9 -0
  64. package/lib/components/forms/Login/TMLoginForm.js +61 -0
  65. package/lib/components/forms/TMResultDialog.d.ts +1 -1
  66. package/lib/components/forms/TMResultDialog.js +4 -2
  67. package/lib/components/grids/TMBlogAttachments.js +2 -2
  68. package/lib/components/grids/TMBlogsPost.js +5 -3
  69. package/lib/components/grids/TMBlogsPostUtils.d.ts +1 -0
  70. package/lib/components/grids/TMBlogsPostUtils.js +3 -1
  71. package/lib/components/index.d.ts +1 -0
  72. package/lib/components/index.js +1 -0
  73. package/lib/components/pages/TMPage.js +3 -1
  74. package/lib/components/query/TMQueryEditor.js +1 -1
  75. package/lib/components/viewers/TMTidViewer.js +1 -1
  76. package/lib/helper/MergePdfManager.d.ts +45 -0
  77. package/lib/helper/MergePdfManager.js +148 -0
  78. package/lib/helper/SDKUI_Globals.d.ts +15 -0
  79. package/lib/helper/SDKUI_Globals.js +16 -1
  80. package/lib/helper/SDKUI_Localizator.d.ts +108 -2
  81. package/lib/helper/SDKUI_Localizator.js +1080 -12
  82. package/lib/helper/TMPdfViewer.js +25 -24
  83. package/lib/helper/TMUtils.d.ts +24 -0
  84. package/lib/helper/TMUtils.js +72 -0
  85. package/lib/helper/ZipManager.d.ts +56 -0
  86. package/lib/helper/ZipManager.js +127 -0
  87. package/lib/helper/checkinCheckoutManager.d.ts +4 -3
  88. package/lib/helper/checkinCheckoutManager.js +29 -11
  89. package/lib/helper/index.d.ts +1 -0
  90. package/lib/helper/index.js +1 -0
  91. package/lib/hooks/useCheckInOutOperations.d.ts +4 -3
  92. package/lib/hooks/useDataUserIdItem.js +6 -4
  93. package/lib/hooks/useDcmtOperations.d.ts +26 -2
  94. package/lib/hooks/useDcmtOperations.js +123 -34
  95. package/lib/hooks/useDocumentOperations.d.ts +3 -0
  96. package/lib/hooks/useDocumentOperations.js +235 -26
  97. package/lib/hooks/useForm.js +5 -2
  98. package/lib/hooks/useRelatedDocuments.js +4 -4
  99. package/lib/hooks/useResizeObserver.d.ts +1 -1
  100. package/lib/hooks/useResizeObserver.js +16 -15
  101. package/lib/services/platform_services.d.ts +4 -4
  102. package/package.json +4 -2
@@ -18,16 +18,91 @@ const isScannerLicenseConfigured = () => {
18
18
  };
19
19
  let abortController = new AbortController();
20
20
  const downloadCountMap = new Map();
21
- const getDownloadFileName = (fileName) => {
22
- const firstDot = fileName.indexOf('.');
23
- const lastDot = fileName.lastIndexOf('.');
24
- if (firstDot === -1 || firstDot === lastDot)
25
- return fileName;
26
- const count = downloadCountMap.get(fileName) ?? 0;
27
- downloadCountMap.set(fileName, count + 1);
28
- if (count === 0)
29
- return fileName;
30
- return `${fileName.slice(0, firstDot)}(${count})${fileName.slice(firstDot)}`;
21
+ /**
22
+ * Genera il nome file per il download con logica di priorità configurabile.
23
+ *
24
+ * @param file - File recuperato dal backend (può contenere il nome originale)
25
+ * @param dcmtInfo - Informazioni del documento (fileName, DID, FILEEXT)
26
+ * @param useInputFileName - Controlla la priorità del nome:
27
+ * - true: priorità a dcmtInfo.fileName file.name → DID
28
+ * - false (default): priorità a file.name → dcmtInfo.fileName → DID
29
+ *
30
+ * Gestisce anche:
31
+ * - Aggiunta automatica dell'estensione se mancante
32
+ * - Duplicati per file con estensioni multiple (es: file.pdf.p7m)
33
+ */
34
+ const getDownloadFileName = (file, dcmtInfo, useInputFileName = false) => {
35
+ // === FASE 1: Costruzione nome base con fallback ===
36
+ // Determina l'estensione con fallback: prima dal backend, poi dal documento
37
+ const fileExtFromBackend = file?.name?.split('.').pop()?.toLowerCase();
38
+ const fileExtFromDcmt = dcmtInfo.FILEEXT?.toLowerCase();
39
+ const fileExtension = fileExtFromBackend ?? fileExtFromDcmt ?? '';
40
+ let baseFileName;
41
+ /**
42
+ * Logica di priorità per il nome file:
43
+ *
44
+ * Se useInputFileName = true:
45
+ * 1. Usa dcmtInfo.fileName (nome passato nell'input)
46
+ * 2. Fallback a file.name (nome dal backend)
47
+ * 3. Fallback finale a DID
48
+ *
49
+ * Se useInputFileName = false (default):
50
+ * 1. Usa file.name (nome recuperato dal backend)
51
+ * 2. Fallback a dcmtInfo.fileName (nome salvato nel documento)
52
+ * 3. Fallback finale a DID
53
+ */
54
+ if (useInputFileName) {
55
+ // Priorità al nome da inputDcmts (dcmtInfo.fileName)
56
+ if (dcmtInfo.fileName) {
57
+ const hasExtension = dcmtInfo.fileName.includes('.');
58
+ baseFileName = hasExtension
59
+ ? dcmtInfo.fileName
60
+ : (fileExtension ? `${dcmtInfo.fileName}.${fileExtension}` : dcmtInfo.fileName);
61
+ }
62
+ // Seconda priorità: nome dal backend
63
+ else if (file?.name) {
64
+ baseFileName = file.name;
65
+ }
66
+ // Fallback finale: ID documento con estensione
67
+ else {
68
+ baseFileName = fileExtension ? `${dcmtInfo.DID}.${fileExtension}` : `${dcmtInfo.DID}`;
69
+ }
70
+ }
71
+ else {
72
+ // Comportamento default: priorità al nome dal backend
73
+ // 1. Priorità massima: nome dal backend
74
+ if (file?.name) {
75
+ baseFileName = file.name;
76
+ }
77
+ // 2. Seconda priorità: nome salvato nel documento
78
+ else if (dcmtInfo.fileName) {
79
+ const hasExtension = dcmtInfo.fileName.includes('.');
80
+ baseFileName = hasExtension
81
+ ? dcmtInfo.fileName
82
+ : (fileExtension ? `${dcmtInfo.fileName}.${fileExtension}` : dcmtInfo.fileName);
83
+ }
84
+ // 3. Fallback finale: ID documento con estensione
85
+ else {
86
+ baseFileName = fileExtension ? `${dcmtInfo.DID}.${fileExtension}` : `${dcmtInfo.DID}`;
87
+ }
88
+ }
89
+ // === FASE 2: Gestione duplicati per file con estensioni multiple ===
90
+ const firstDot = baseFileName.indexOf('.');
91
+ const lastDot = baseFileName.lastIndexOf('.');
92
+ // Se non ci sono punti o c'è una sola estensione, ritorna il nome così com'è
93
+ if (firstDot === -1 || firstDot === lastDot) {
94
+ return baseFileName;
95
+ }
96
+ // Gestisce il contatore per evitare sovrascritture
97
+ const count = downloadCountMap.get(baseFileName) ?? 0;
98
+ downloadCountMap.set(baseFileName, count + 1);
99
+ // Prima occorrenza: nome originale
100
+ if (count === 0) {
101
+ return baseFileName;
102
+ }
103
+ // Download successivi: inserisce contatore dopo il nome base
104
+ // Es: "file.pdf.p7m" -> "file(1).pdf.p7m"
105
+ return `${baseFileName.slice(0, firstDot)}(${count})${baseFileName.slice(firstDot)}`;
31
106
  };
32
107
  export const useDcmtOperations = () => {
33
108
  const [showWaitPanel, setShowWaitPanel] = useState(false);
@@ -42,7 +117,7 @@ export const useDcmtOperations = () => {
42
117
  const [waitPanelMaxValueSecondary, setWaitPanelMaxValueSecondary] = useState(0);
43
118
  const { OpenFileDialog } = useFileDialog();
44
119
  const [selectFileSource, FileSourceDialog] = useFileSourceDialog();
45
- const _downloadDcmtsAsync = async (inputDcmts, downloadMode = "download", onFileDownloaded, skipConfirmation = false) => {
120
+ const _downloadDcmtsAsync = async (inputDcmts, downloadMode = "download", onFileDownloaded, skipConfirmation = false, retrieveOptions, useCache = true, showSuccessAlert = true, useInputFileName = false) => {
46
121
  if (inputDcmts === undefined)
47
122
  return;
48
123
  if (inputDcmts.length <= 0)
@@ -72,9 +147,13 @@ export const useDcmtOperations = () => {
72
147
  setWaitPanelTitle(operationTitle);
73
148
  abortController = new AbortController();
74
149
  const rfo = new RetrieveFileOptions();
75
- rfo.retrieveReason = DcmtOpers.ShowFile;
76
- rfo.invoiceRetrieveFormat = SDKUI_Globals.userSettings.searchSettings.invoiceRetrieveFormat;
77
- rfo.orderRetrieveFormat = SDKUI_Globals.userSettings.searchSettings.orderRetrieveFormat;
150
+ rfo.retrieveReason = retrieveOptions?.retrieveReason ?? DcmtOpers.ShowFile;
151
+ if (retrieveOptions?.cvtFormat !== undefined)
152
+ rfo.cvtFormat = retrieveOptions.cvtFormat;
153
+ if (retrieveOptions?.generalRetrieveFormat !== undefined)
154
+ rfo.generalRetrieveFormat = retrieveOptions.generalRetrieveFormat;
155
+ rfo.invoiceRetrieveFormat = retrieveOptions?.invoiceRetrieveFormat ?? SDKUI_Globals.userSettings.searchSettings.invoiceRetrieveFormat;
156
+ rfo.orderRetrieveFormat = retrieveOptions?.orderRetrieveFormat ?? SDKUI_Globals.userSettings.searchSettings.orderRetrieveFormat;
78
157
  let result = [];
79
158
  setWaitPanelMaxValuePrimary(inputDcmts.length);
80
159
  let firstBlock = true;
@@ -88,7 +167,7 @@ export const useDcmtOperations = () => {
88
167
  setWaitPanelTextPrimary(`Download file ${i + 1} di ${inputDcmts.length}`);
89
168
  let file;
90
169
  const cacheKey = `${inputDcmts[i].TID}-${inputDcmts[i].DID}`;
91
- if (dcmtsFileCacheDownload.has(cacheKey)) {
170
+ if (useCache && dcmtsFileCacheDownload.has(cacheKey)) {
92
171
  file = dcmtsFileCacheDownload.get(cacheKey);
93
172
  }
94
173
  else {
@@ -112,23 +191,30 @@ export const useDcmtOperations = () => {
112
191
  const fileURL = window.URL.createObjectURL(file);
113
192
  if (downloadMode === "openInNewWindow") {
114
193
  (onFileDownloaded && file)
115
- ? onFileDownloaded(file)
194
+ ? onFileDownloaded(file, inputDcmts[i])
116
195
  : window.open(fileURL, '_blank', 'noopener');
117
196
  }
118
197
  else {
119
- const alink2 = document.createElement('a');
120
- alink2.href = fileURL;
121
- const baseFileName = inputDcmts[i].fileName ?? (inputDcmts[i].FILEEXT ? `${inputDcmts[i].DID}.${inputDcmts[i].FILEEXT}` : file?.name);
122
- alink2.download = getDownloadFileName(baseFileName);
123
- alink2.target = "_blank";
124
- alink2.rel = "noreferrer";
125
- alink2.click();
198
+ if (onFileDownloaded && file) {
199
+ await onFileDownloaded(file, inputDcmts[i]);
200
+ }
201
+ else {
202
+ const alink2 = document.createElement('a');
203
+ alink2.href = fileURL;
204
+ // Usa useInputFileName per determinare la priorità del nome file
205
+ alink2.download = getDownloadFileName(file, inputDcmts[i], useInputFileName);
206
+ alink2.target = "_blank";
207
+ alink2.rel = "noreferrer";
208
+ alink2.click();
209
+ }
126
210
  }
127
- if (dcmtsFileCacheDownload.size >= CACHE_SIZE_LIMIT) {
128
- const oldestKey = dcmtsFileCacheDownload.keys().next().value;
129
- dcmtsFileCacheDownload.delete(oldestKey);
211
+ if (useCache) {
212
+ if (dcmtsFileCacheDownload.size >= CACHE_SIZE_LIMIT) {
213
+ const oldestKey = dcmtsFileCacheDownload.keys().next().value;
214
+ dcmtsFileCacheDownload.delete(oldestKey);
215
+ }
216
+ dcmtsFileCacheDownload.set(cacheKey, file);
130
217
  }
131
- dcmtsFileCacheDownload.set(cacheKey, file);
132
218
  result.push({ rowIndex: i, id1: inputDcmts[i].TID, id2: inputDcmts[i].DID, resultType: ResultTypes.SUCCESS });
133
219
  }
134
220
  catch (ex) {
@@ -146,9 +232,9 @@ export const useDcmtOperations = () => {
146
232
  setWaitPanelMaxValueSecondary(0);
147
233
  setWaitPanelValueSecondary(0);
148
234
  setShowWaitPanel(false);
149
- TMResultManager.show(result, operationTitle, "TID", "DID");
235
+ TMResultManager.show(result, operationTitle, "TID", "DID", undefined, undefined, showSuccessAlert);
150
236
  };
151
- const _downloadAttachmentsAsync = async (inputDcmts, confirmAttachments) => {
237
+ const _downloadAttachmentsAsync = async (inputDcmts, confirmAttachments, showSuccessAlert = true) => {
152
238
  if (inputDcmts === undefined)
153
239
  return;
154
240
  if (inputDcmts.length !== 1)
@@ -196,7 +282,7 @@ export const useDcmtOperations = () => {
196
282
  }
197
283
  }
198
284
  }
199
- TMResultManager.show(result, operationTitle, "TID", "DID");
285
+ TMResultManager.show(result, operationTitle, "TID", "DID", undefined, undefined, showSuccessAlert);
200
286
  }
201
287
  catch (ex) {
202
288
  TMSpinner.hide();
@@ -208,11 +294,14 @@ export const useDcmtOperations = () => {
208
294
  TMExceptionBoxManager.show({ exception: err });
209
295
  }
210
296
  };
211
- const downloadDcmtsAsync = async (inputDcmts, downloadType = DownloadTypes.Attachment, downloadMode = "download", onFileDownloaded, confirmAttachments, skipConfirmation = false) => {
297
+ const downloadDcmtsAsync = async (params) => {
298
+ const { inputDcmts, downloadType = DownloadTypes.Attachment, downloadMode = "download", onFileDownloaded, confirmAttachments, skipConfirmation = false, retrieveOptions, useCache = true, showSuccessAlert = true, useInputFileName = false, // Default: usa il nome dal backend
299
+ } = params;
212
300
  switch (downloadType) {
213
- case DownloadTypes.Dcmt: return await _downloadDcmtsAsync(inputDcmts, downloadMode, onFileDownloaded, skipConfirmation);
214
- case DownloadTypes.Attachment: return await _downloadAttachmentsAsync(inputDcmts, confirmAttachments);
215
- default: return await _downloadDcmtsAsync(inputDcmts, undefined, undefined, skipConfirmation);
301
+ // Per il download di documenti, passa useInputFileName per controllare la priorità del nome
302
+ case DownloadTypes.Dcmt: return await _downloadDcmtsAsync(inputDcmts, downloadMode, onFileDownloaded, skipConfirmation, retrieveOptions, useCache, showSuccessAlert, useInputFileName);
303
+ case DownloadTypes.Attachment: return await _downloadAttachmentsAsync(inputDcmts, confirmAttachments, showSuccessAlert);
304
+ default: return await _downloadDcmtsAsync(inputDcmts, undefined, undefined, skipConfirmation, retrieveOptions, useCache, showSuccessAlert, useInputFileName);
216
305
  }
217
306
  };
218
307
  const uploadDcmtsAsync = async (inputDcmts, operationTitle, operType, actionAfterOperationAsync) => {
@@ -38,6 +38,8 @@ export interface DocumentDataProps {
38
38
  s4TViewerDialogComponent?: React.ReactNode;
39
39
  };
40
40
  }
41
+ export type TMCopyToFolderMode = 'onlySelected' | 'customized';
42
+ export type TMCopyToFolderOperationType = 'copyToFolder' | 'mergeToPdf';
41
43
  export interface ExportDataProps {
42
44
  dataColumns?: Array<IColumnProps>;
43
45
  dataSource?: Array<any>;
@@ -110,6 +112,7 @@ export interface UseDocumentOperationsResult {
110
112
  isOpenBatchUpdate: boolean;
111
113
  isModifiedBatchUpdate: boolean;
112
114
  updateBatchUpdateForm: (value: boolean) => void;
115
+ closeDcmtFormHandler: () => void;
113
116
  handleSignApprove: () => void;
114
117
  showSearchTMDatagrid: boolean;
115
118
  showExportForm: boolean;