@topconsultnpm/sdkui-react 6.21.0-t1 → 6.21.0-t2
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.
- package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +4 -4
- package/lib/components/base/TMAccordionNew.d.ts +1 -0
- package/lib/components/base/TMAccordionNew.js +6 -5
- package/lib/components/base/TMAreaManager.js +19 -3
- package/lib/components/base/TMDataGrid.js +2 -2
- package/lib/components/base/TMModal.d.ts +1 -0
- package/lib/components/base/TMModal.js +2 -2
- package/lib/components/base/TMPanel.d.ts +7 -4
- package/lib/components/base/TMPanel.js +58 -26
- package/lib/components/base/TMTreeView.js +12 -2
- package/lib/components/base/TMWaitPanel.js +7 -4
- package/lib/components/choosers/TMDistinctValues.js +35 -21
- package/lib/components/choosers/TMUserChooser.d.ts +4 -0
- package/lib/components/choosers/TMUserChooser.js +7 -5
- package/lib/components/editors/TMDateBox.js +4 -2
- package/lib/components/editors/TMFormulaEditor.d.ts +2 -0
- package/lib/components/editors/TMFormulaEditor.js +75 -21
- package/lib/components/editors/TMMetadataValues.js +2 -1
- package/lib/components/editors/TMRadioButton.js +7 -5
- package/lib/components/editors/TMTextArea.d.ts +2 -0
- package/lib/components/editors/TMTextArea.js +6 -3
- package/lib/components/editors/TMTextBox.d.ts +2 -0
- package/lib/components/editors/TMTextBox.js +3 -3
- package/lib/components/features/archive/TMArchive.js +1 -1
- package/lib/components/features/documents/TMCopyToFolderForm.d.ts +24 -0
- package/lib/components/features/documents/TMCopyToFolderForm.js +379 -0
- package/lib/components/features/documents/TMDcmtForm.d.ts +1 -0
- package/lib/components/features/documents/TMDcmtForm.js +147 -45
- package/lib/components/features/documents/TMDcmtFormActionButtons.js +259 -60
- package/lib/components/features/documents/TMDcmtPreview.d.ts +1 -0
- package/lib/components/features/documents/TMDcmtPreview.js +2 -2
- package/lib/components/features/documents/TMDcmtTasks.d.ts +1 -0
- package/lib/components/features/documents/TMDcmtTasks.js +2 -2
- package/lib/components/features/documents/TMDownloadRelationViewerSection.d.ts +23 -0
- package/lib/components/features/documents/TMDownloadRelationViewerSection.js +173 -0
- package/lib/components/features/documents/TMFileUploader.js +1 -1
- package/lib/components/features/documents/TMMasterDetailDcmts.d.ts +4 -0
- package/lib/components/features/documents/TMMasterDetailDcmts.js +29 -9
- package/lib/components/features/documents/TMMergeToPdfForm.d.ts +26 -0
- package/lib/components/features/documents/TMMergeToPdfForm.js +293 -0
- package/lib/components/features/documents/TMRelationViewer.d.ts +13 -0
- package/lib/components/features/documents/TMRelationViewer.js +75 -6
- package/lib/components/features/documents/copyAndMergeDcmtsShared.d.ts +71 -0
- package/lib/components/features/documents/copyAndMergeDcmtsShared.js +304 -0
- package/lib/components/features/search/SignatureParamsManager.d.ts +70 -0
- package/lib/components/features/search/SignatureParamsManager.js +145 -0
- package/lib/components/features/search/TMSavedQuerySelector.d.ts +2 -2
- package/lib/components/features/search/TMSavedQuerySelector.js +3 -2
- package/lib/components/features/search/TMSearch.d.ts +6 -1
- package/lib/components/features/search/TMSearch.js +16 -10
- package/lib/components/features/search/TMSearchQueryPanel.js +1 -1
- package/lib/components/features/search/TMSearchResult.d.ts +4 -0
- package/lib/components/features/search/TMSearchResult.js +118 -22
- package/lib/components/features/search/TMViewHistoryDcmt.js +1 -2
- package/lib/components/features/workflow/TMWorkflowPopup.js +3 -0
- package/lib/components/features/workflow/diagram/queryDescriptorParser.js +3 -6
- package/lib/components/forms/Login/TMLoginForm.d.ts +9 -0
- package/lib/components/forms/Login/TMLoginForm.js +61 -0
- package/lib/components/forms/TMResultDialog.d.ts +1 -1
- package/lib/components/forms/TMResultDialog.js +4 -2
- package/lib/components/grids/TMBlogAttachments.d.ts +1 -0
- package/lib/components/grids/TMBlogAttachments.js +38 -12
- package/lib/components/grids/TMBlogsPost.js +7 -1
- package/lib/components/grids/TMBlogsPostUtils.js +11 -17
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/pages/TMPage.js +3 -1
- package/lib/components/query/TMQueryEditor.js +2 -2
- package/lib/components/viewers/TMTidViewer.js +1 -1
- package/lib/helper/GlobalStyles.js +6 -0
- package/lib/helper/SDKUI_Globals.d.ts +15 -0
- package/lib/helper/SDKUI_Globals.js +15 -1
- package/lib/helper/SDKUI_Localizator.d.ts +106 -2
- package/lib/helper/SDKUI_Localizator.js +1060 -12
- package/lib/helper/TMPdfViewer.js +25 -24
- package/lib/helper/TMUtils.d.ts +20 -0
- package/lib/helper/TMUtils.js +17 -0
- package/lib/helper/ZipManager.d.ts +56 -0
- package/lib/helper/ZipManager.js +127 -0
- package/lib/helper/index.d.ts +1 -0
- package/lib/helper/index.js +1 -0
- package/lib/hooks/useDataUserIdItem.js +6 -4
- package/lib/hooks/useDcmtOperations.d.ts +9 -2
- package/lib/hooks/useDcmtOperations.js +78 -35
- package/lib/hooks/useDocumentOperations.d.ts +5 -0
- package/lib/hooks/useDocumentOperations.js +238 -27
- package/lib/hooks/useForm.js +5 -2
- package/lib/hooks/useResizeObserver.d.ts +1 -1
- package/lib/hooks/useResizeObserver.js +16 -15
- package/lib/ts/types.d.ts +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { DownloadTypes } from '../../../ts';
|
|
4
|
+
import { calcResponsiveSizes, DocumentDownloadSettings, IconDelete, IconFolderOpen, IconPlay, IconSave, IconUndo, SDKUI_Globals, SDKUI_Localizator, ZipManager, } from '../../../helper';
|
|
5
|
+
import { DcmtOpers, GeneralRetrieveFormats, ResultTypes, RetrieveFileOptions, ValidationItem, } from '@topconsultnpm/sdk-ts';
|
|
6
|
+
import TMModal from '../../base/TMModal';
|
|
7
|
+
import { useDeviceType } from '../../base/TMDeviceProvider';
|
|
8
|
+
import TMRadioButton from '../../editors/TMRadioButton';
|
|
9
|
+
import TMTextBox from '../../editors/TMTextBox';
|
|
10
|
+
import TMDropDown from '../../editors/TMDropDown';
|
|
11
|
+
import TMInvoiceRetrieveFormats from '../../choosers/TMInvoiceRetrieveFormats';
|
|
12
|
+
import TMOrderRetrieveFormats from '../../choosers/TMOrderRetrieveFormats';
|
|
13
|
+
import TMButton from '../../base/TMButton';
|
|
14
|
+
import { ButtonNames, TMMessageBoxManager } from '../../base/TMPopUp';
|
|
15
|
+
import { useDcmtOperations } from '../../../hooks/useDcmtOperations';
|
|
16
|
+
import { TMLayoutWaitingContainer } from '../../base/TMWaitPanel';
|
|
17
|
+
import { TMSplitterLayout } from '../../base/TMLayout';
|
|
18
|
+
import TMCheckBox from '../../editors/TMCheckBox';
|
|
19
|
+
import ShowAlert from '../../base/TMAlert';
|
|
20
|
+
import { TMColors } from '../../../utils/theme';
|
|
21
|
+
import TMDownloadRelationViewerSection from './TMDownloadRelationViewerSection';
|
|
22
|
+
import { buildInitialDownloadSettings, fileExists, generateTargetFileName, generateUniqueFileName, getDcmtInfosToDownload, getFloatingLabelStyle, isDirectoryPickerSupported, } from './copyAndMergeDcmtsShared';
|
|
23
|
+
/**
|
|
24
|
+
* Form per la copia/zip dei documenti in una cartella locale.
|
|
25
|
+
* Logica condivisa con TMMergeToPdfForm è esternalizzata in copyAndMergeDcmtsShared
|
|
26
|
+
* e TMDownloadRelationViewerSection.
|
|
27
|
+
*/
|
|
28
|
+
const TMCopyToFolderForm = ({ mode, selectedDcmtInfos, onClose, showTMRelationViewer, allTasks, getAllTasks, deleteTaskByIdsCallback, addTaskCallback, editTaskCallback, handleNavigateToWGs, handleNavigateToDossiers }) => {
|
|
29
|
+
const { abortController, showWaitPanel, waitPanelTitle, showPrimary, waitPanelTextPrimary, waitPanelValuePrimary, waitPanelMaxValuePrimary, showSecondary, waitPanelTextSecondary, waitPanelValueSecondary, waitPanelMaxValueSecondary, downloadDcmtsAsync, } = useDcmtOperations();
|
|
30
|
+
// Get the current device type (e.g., mobile, tablet, desktop) using a custom hook.
|
|
31
|
+
const deviceType = useDeviceType();
|
|
32
|
+
// ---- Stato dei settings ----
|
|
33
|
+
const [settings, setSettings] = useState(() => buildInitialDownloadSettings(SDKUI_Globals.userSettings.documentDownloadSettings, SDKUI_Globals.userSettings.searchSettings.invoiceRetrieveFormat, SDKUI_Globals.userSettings.searchSettings.orderRetrieveFormat));
|
|
34
|
+
const [selectedItemsRelationViewer, setSelectedItemsRelationViewer] = useState([]);
|
|
35
|
+
const [hasSavedLayout, setHasSavedLayout] = useState(() => {
|
|
36
|
+
const saved = SDKUI_Globals.userSettings.documentDownloadSettings;
|
|
37
|
+
const defaults = new DocumentDownloadSettings();
|
|
38
|
+
return JSON.stringify(saved) !== JSON.stringify(defaults);
|
|
39
|
+
});
|
|
40
|
+
const updateSettings = (key, value) => {
|
|
41
|
+
setSettings(prev => ({ ...prev, [key]: value }));
|
|
42
|
+
};
|
|
43
|
+
// ---- Ref per la selezione cartella (File System Access API) ----
|
|
44
|
+
const folderHandleRef = useRef(null);
|
|
45
|
+
const skipSelectFolderRef = useRef(false);
|
|
46
|
+
const isPickerActiveRef = useRef(false);
|
|
47
|
+
const getTitle = () => {
|
|
48
|
+
const count = ` (${selectedDcmtInfos.length})`;
|
|
49
|
+
const modeLabelMap = {
|
|
50
|
+
onlySelected: SDKUI_Localizator.SelectedDocuments,
|
|
51
|
+
customized: SDKUI_Localizator.SelectedDocumentsAndRelated,
|
|
52
|
+
};
|
|
53
|
+
const modeLabel = modeLabelMap[mode] || modeLabelMap.onlySelected;
|
|
54
|
+
return `${SDKUI_Localizator.CopyToFolder} - ${modeLabel}${count}`;
|
|
55
|
+
};
|
|
56
|
+
const isUsingDefaultDownloads = settings.destinationFolder === 'Download' && !folderHandleRef.current;
|
|
57
|
+
// ---- Validazione ----
|
|
58
|
+
const { folderValidationItems, zipValidationItems } = useMemo(() => {
|
|
59
|
+
const folderItems = [];
|
|
60
|
+
const zipItems = [];
|
|
61
|
+
if (settings.exportMode === 'copy' && !settings.destinationFolder.trim()) {
|
|
62
|
+
folderItems.push(new ValidationItem(ResultTypes.ERROR, SDKUI_Localizator.FolderName, SDKUI_Localizator.RequiredField));
|
|
63
|
+
}
|
|
64
|
+
if (settings.exportMode === 'zip' && !settings.zipFileName.trim()) {
|
|
65
|
+
zipItems.push(new ValidationItem(ResultTypes.ERROR, SDKUI_Localizator.ZipFileName, SDKUI_Localizator.RequiredField));
|
|
66
|
+
}
|
|
67
|
+
return { folderValidationItems: folderItems, zipValidationItems: zipItems };
|
|
68
|
+
}, [settings.exportMode, settings.destinationFolder, settings.zipFileName]);
|
|
69
|
+
const isFormValid = () => {
|
|
70
|
+
if (settings.exportMode === 'copy')
|
|
71
|
+
return folderValidationItems.length === 0;
|
|
72
|
+
if (settings.exportMode === 'zip')
|
|
73
|
+
return zipValidationItems.length === 0;
|
|
74
|
+
return false;
|
|
75
|
+
};
|
|
76
|
+
// ---- Handler dei campi ----
|
|
77
|
+
const handleFolderValueChange = (e) => {
|
|
78
|
+
updateSettings('destinationFolder', e.target.value);
|
|
79
|
+
folderHandleRef.current = null;
|
|
80
|
+
};
|
|
81
|
+
const handleSelectFolder = async () => {
|
|
82
|
+
if (skipSelectFolderRef.current) {
|
|
83
|
+
skipSelectFolderRef.current = false;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (isPickerActiveRef.current)
|
|
87
|
+
return;
|
|
88
|
+
try {
|
|
89
|
+
isPickerActiveRef.current = true;
|
|
90
|
+
const dirHandle = await window.showDirectoryPicker({ mode: 'readwrite' });
|
|
91
|
+
folderHandleRef.current = dirHandle;
|
|
92
|
+
updateSettings('destinationFolder', dirHandle.name);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
if (err.name !== 'AbortError') {
|
|
96
|
+
console.error('Error selecting folder:', err);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
isPickerActiveRef.current = false;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const handleFileNamingModeChange = (e) => {
|
|
104
|
+
updateSettings('fileNamingMode', e.target.value);
|
|
105
|
+
};
|
|
106
|
+
const handleSeparatorChange = (e) => {
|
|
107
|
+
updateSettings('separatorChar', e.target.value.slice(0, 1));
|
|
108
|
+
};
|
|
109
|
+
// ---- Scrittura file nel filesystem locale ----
|
|
110
|
+
const writeFileToFolder = async (file, dcmtInfo) => {
|
|
111
|
+
try {
|
|
112
|
+
let targetFileName = await generateTargetFileName(file, dcmtInfo, {
|
|
113
|
+
fileNamingMode: settings.fileNamingMode,
|
|
114
|
+
separatorChar: settings.separatorChar,
|
|
115
|
+
});
|
|
116
|
+
// Se non c'è un handle della cartella: download standard del browser
|
|
117
|
+
if (!folderHandleRef.current) {
|
|
118
|
+
const url = URL.createObjectURL(file);
|
|
119
|
+
const a = document.createElement('a');
|
|
120
|
+
a.href = url;
|
|
121
|
+
a.download = targetFileName;
|
|
122
|
+
document.body.appendChild(a);
|
|
123
|
+
a.target = '_blank';
|
|
124
|
+
a.rel = 'noreferrer';
|
|
125
|
+
a.click();
|
|
126
|
+
document.body.removeChild(a);
|
|
127
|
+
URL.revokeObjectURL(url);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const exists = await fileExists(folderHandleRef.current, targetFileName);
|
|
131
|
+
if (exists) {
|
|
132
|
+
switch (settings.fileExistsMode) {
|
|
133
|
+
case 'skip':
|
|
134
|
+
return;
|
|
135
|
+
case 'rename':
|
|
136
|
+
targetFileName = await generateUniqueFileName(folderHandleRef.current, targetFileName);
|
|
137
|
+
break;
|
|
138
|
+
case 'overwrite':
|
|
139
|
+
default:
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const fileHandle = await folderHandleRef.current.getFileHandle(targetFileName, { create: true });
|
|
144
|
+
const writable = await fileHandle.createWritable();
|
|
145
|
+
await writable.write(file);
|
|
146
|
+
await writable.close();
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
console.error('Errore nella scrittura del file:', err);
|
|
150
|
+
throw err;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
// ---- Esecuzione (Copia oppure ZIP) ----
|
|
154
|
+
const run = async () => {
|
|
155
|
+
if (settings.exportMode === 'copy' && folderValidationItems.length > 0) {
|
|
156
|
+
TMMessageBoxManager.show({ message: SDKUI_Localizator.PleaseCorrectErrorsBeforeProceeding, buttons: [ButtonNames.OK] });
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (settings.exportMode === 'zip' && zipValidationItems.length > 0) {
|
|
160
|
+
TMMessageBoxManager.show({ message: SDKUI_Localizator.PleaseCorrectErrorsBeforeProceeding, buttons: [ButtonNames.OK] });
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const dcmtInfosToDownload = getDcmtInfosToDownload(selectedDcmtInfos, selectedItemsRelationViewer, showTMRelationViewer);
|
|
164
|
+
if (dcmtInfosToDownload.length === 0) {
|
|
165
|
+
TMMessageBoxManager.show({ message: SDKUI_Localizator.NoDocumentsSelected, buttons: [ButtonNames.OK] });
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const retrieveOptions = new RetrieveFileOptions();
|
|
169
|
+
retrieveOptions.retrieveReason = DcmtOpers.None;
|
|
170
|
+
retrieveOptions.generalRetrieveFormat = settings.removeSignature ? GeneralRetrieveFormats.OriginalUnsigned : GeneralRetrieveFormats.Original;
|
|
171
|
+
retrieveOptions.invoiceRetrieveFormat = settings.invoiceFormat ?? SDKUI_Globals.userSettings.searchSettings.invoiceRetrieveFormat;
|
|
172
|
+
retrieveOptions.orderRetrieveFormat = settings.orderFormat ?? SDKUI_Globals.userSettings.searchSettings.orderRetrieveFormat;
|
|
173
|
+
if (settings.exportMode === 'copy') {
|
|
174
|
+
await downloadDcmtsAsync(dcmtInfosToDownload, DownloadTypes.Dcmt, 'download', writeFileToFolder, undefined, true, retrieveOptions, false);
|
|
175
|
+
}
|
|
176
|
+
else if (settings.exportMode === 'zip') {
|
|
177
|
+
const zipEntries = [];
|
|
178
|
+
const fileNameCounts = new Map();
|
|
179
|
+
const getUniqueZipFileName = (fileName) => {
|
|
180
|
+
const lowerName = fileName.toLowerCase();
|
|
181
|
+
const count = fileNameCounts.get(lowerName) ?? 0;
|
|
182
|
+
fileNameCounts.set(lowerName, count + 1);
|
|
183
|
+
if (count === 0)
|
|
184
|
+
return fileName;
|
|
185
|
+
const dotIndex = fileName.lastIndexOf('.');
|
|
186
|
+
const baseName = dotIndex > 0 ? fileName.substring(0, dotIndex) : fileName;
|
|
187
|
+
const ext = dotIndex > 0 ? fileName.substring(dotIndex) : '';
|
|
188
|
+
return `${baseName} (${count})${ext}`;
|
|
189
|
+
};
|
|
190
|
+
const collectFileForZip = async (file, dcmtInfo) => {
|
|
191
|
+
const targetFileName = await generateTargetFileName(file, dcmtInfo, {
|
|
192
|
+
fileNamingMode: settings.fileNamingMode,
|
|
193
|
+
separatorChar: settings.separatorChar,
|
|
194
|
+
});
|
|
195
|
+
zipEntries.push({ filename: getUniqueZipFileName(targetFileName), data: file });
|
|
196
|
+
};
|
|
197
|
+
await downloadDcmtsAsync(dcmtInfosToDownload, DownloadTypes.Dcmt, 'download', collectFileForZip, undefined, true, retrieveOptions, false);
|
|
198
|
+
if (zipEntries.length > 0) {
|
|
199
|
+
const zipFileName = settings.zipFileName.trim().toLowerCase().endsWith('.zip')
|
|
200
|
+
? settings.zipFileName.trim()
|
|
201
|
+
: settings.zipFileName.trim() + '.zip';
|
|
202
|
+
// Crea il blob ZIP
|
|
203
|
+
const zipBlob = await ZipManager.createZip(zipEntries, {
|
|
204
|
+
compressionLevel: 6,
|
|
205
|
+
password: settings.zipPassword.trim() || undefined,
|
|
206
|
+
});
|
|
207
|
+
// Se c'è un handle della cartella: salva direttamente nella cartella selezionata
|
|
208
|
+
if (folderHandleRef.current) {
|
|
209
|
+
try {
|
|
210
|
+
// Per lo ZIP usa sempre rename automatico (come fa il browser)
|
|
211
|
+
const finalZipFileName = await generateUniqueFileName(folderHandleRef.current, zipFileName);
|
|
212
|
+
const fileHandle = await folderHandleRef.current.getFileHandle(finalZipFileName, { create: true });
|
|
213
|
+
const writable = await fileHandle.createWritable();
|
|
214
|
+
await writable.write(zipBlob);
|
|
215
|
+
await writable.close();
|
|
216
|
+
ShowAlert({ message: SDKUI_Localizator.ZipCreatedSavedInFolder.replaceParams(finalZipFileName, folderHandleRef.current.name), mode: 'success', duration: 5000, title: SDKUI_Localizator.CompressToZipFile });
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
console.error('Error saving ZIP to folder, fallback to standard download:', err);
|
|
220
|
+
// Fallback: download standard del browser
|
|
221
|
+
ZipManager.downloadBlob(zipBlob, zipFileName);
|
|
222
|
+
ShowAlert({ message: SDKUI_Localizator.ZipCreatedSavedInFolder.replaceParams(zipFileName, "Download"), mode: 'success', duration: 5000, title: SDKUI_Localizator.CompressToZipFile });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
// Se non c'è un handle della cartella: download zip standard del browser
|
|
227
|
+
ZipManager.downloadBlob(zipBlob, zipFileName);
|
|
228
|
+
ShowAlert({ message: SDKUI_Localizator.ZipCreatedSavedInFolder.replaceParams(zipFileName, "Download"), mode: 'success', duration: 5000, title: SDKUI_Localizator.CompressToZipFile });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
TMMessageBoxManager.show({ message: SDKUI_Localizator.ExportModeNotSupported, buttons: [ButtonNames.OK] });
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
onClose();
|
|
237
|
+
};
|
|
238
|
+
// ---- Layout salva/rimuovi ----
|
|
239
|
+
const saveLayout = () => {
|
|
240
|
+
const { zipPassword, ...settingsToSave } = settings;
|
|
241
|
+
SDKUI_Globals.userSettings.documentDownloadSettings = { ...settingsToSave, zipPassword: '' };
|
|
242
|
+
const defaults = new DocumentDownloadSettings();
|
|
243
|
+
const hasChanges = JSON.stringify(settings) !== JSON.stringify(defaults);
|
|
244
|
+
if (hasChanges) {
|
|
245
|
+
setHasSavedLayout(true);
|
|
246
|
+
ShowAlert({ mode: 'success', message: SDKUI_Localizator.OperationSuccess, title: SDKUI_Localizator.Save, duration: 3000 });
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const removeLayout = () => {
|
|
250
|
+
const defaults = new DocumentDownloadSettings();
|
|
251
|
+
SDKUI_Globals.userSettings.documentDownloadSettings = { ...defaults };
|
|
252
|
+
setSettings(defaults);
|
|
253
|
+
folderHandleRef.current = null;
|
|
254
|
+
setHasSavedLayout(false);
|
|
255
|
+
ShowAlert({ mode: 'success', message: SDKUI_Localizator.OperationSuccess, title: SDKUI_Localizator.Remove, duration: 3000 });
|
|
256
|
+
};
|
|
257
|
+
const isLayoutSameAsSaved = () => {
|
|
258
|
+
const saved = SDKUI_Globals.userSettings.documentDownloadSettings;
|
|
259
|
+
if (!saved) {
|
|
260
|
+
const defaults = new DocumentDownloadSettings();
|
|
261
|
+
return JSON.stringify(settings) === JSON.stringify(defaults);
|
|
262
|
+
}
|
|
263
|
+
return JSON.stringify(settings) === JSON.stringify(saved);
|
|
264
|
+
};
|
|
265
|
+
// ---- Componenti comuni riutilizzati in entrambe le modalità (copy/zip) ----
|
|
266
|
+
const folderSelector = isDirectoryPickerSupported() ? (_jsx("div", { style: { flex: '1 1 280px', minWidth: '280px' }, children: _jsx(TMTextBox, { label: SDKUI_Localizator.FolderName, value: settings.destinationFolder, validationItems: folderValidationItems, onValueChanged: handleFolderValueChange, readOnly: true, placeHolder: "Download", onClick: handleSelectFolder, buttons: [
|
|
267
|
+
{
|
|
268
|
+
icon: _jsx(IconFolderOpen, {}),
|
|
269
|
+
text: SDKUI_Localizator.SelectFolder,
|
|
270
|
+
onClick: handleSelectFolder
|
|
271
|
+
},
|
|
272
|
+
...(!isUsingDefaultDownloads ? [{
|
|
273
|
+
icon: _jsx(IconUndo, {}),
|
|
274
|
+
text: SDKUI_Localizator.RestoreDownload,
|
|
275
|
+
onClick: () => {
|
|
276
|
+
skipSelectFolderRef.current = true;
|
|
277
|
+
updateSettings('destinationFolder', 'Download');
|
|
278
|
+
folderHandleRef.current = null;
|
|
279
|
+
}
|
|
280
|
+
}] : [])
|
|
281
|
+
] }) })) : (_jsx("div", { style: { flex: '1 1 280px', minWidth: '280px' }, children: _jsxs("div", { style: { position: 'relative', marginTop: '16px' }, children: [_jsx("span", { style: {
|
|
282
|
+
position: 'absolute',
|
|
283
|
+
top: '-10px',
|
|
284
|
+
left: '12px',
|
|
285
|
+
fontSize: '0.9rem',
|
|
286
|
+
color: TMColors.label_normal,
|
|
287
|
+
padding: '0 3px',
|
|
288
|
+
userSelect: 'none',
|
|
289
|
+
WebkitTouchCallout: 'none',
|
|
290
|
+
WebkitUserSelect: 'none',
|
|
291
|
+
width: 'max-content',
|
|
292
|
+
backgroundColor: TMColors.default_background,
|
|
293
|
+
zIndex: 1,
|
|
294
|
+
}, children: SDKUI_Localizator.Path }), _jsxs("div", { style: { border: `1px solid ${TMColors.border_normal}`, borderRadius: '5px', padding: '4px 10px 4px 13px', display: 'flex', alignItems: 'center', gap: '8px', backgroundColor: '#fafafa' }, children: [_jsx(IconFolderOpen, {}), _jsx("span", { style: { fontSize: '0.9rem', color: '#333' }, children: "Download" })] }), _jsx("span", { style: { fontSize: '0.8rem', color: '#888', fontStyle: 'italic', marginTop: '4px', display: 'block' }, children: SDKUI_Localizator.BrowserDoesNotSupportFolderSelection })] }) }));
|
|
295
|
+
const fileNamingRow = (_jsxs("div", { style: {
|
|
296
|
+
display: 'flex',
|
|
297
|
+
flexWrap: 'wrap',
|
|
298
|
+
alignItems: 'flex-end',
|
|
299
|
+
gap: '10px',
|
|
300
|
+
width: '100%',
|
|
301
|
+
}, children: [_jsx(TMDropDown, { label: SDKUI_Localizator.UseForFileName, value: settings.fileNamingMode, dataSource: [
|
|
302
|
+
{ value: 'onlyDid', display: SDKUI_Localizator.OnlyDID },
|
|
303
|
+
{ value: 'documentTypeAndDid', display: SDKUI_Localizator.DocumentTypeNameAndDID },
|
|
304
|
+
{ value: 'documentTypeAndCustomMetadata', display: SDKUI_Localizator.DocumentTypeNameAndCustomMetadata },
|
|
305
|
+
{ value: 'onlyCustomMetadata', display: SDKUI_Localizator.OnlyCustomMetadata },
|
|
306
|
+
], onValueChanged: handleFileNamingModeChange, width: '400px' }), _jsx(TMTextBox, { label: SDKUI_Localizator.Separator, value: settings.separatorChar, maxLength: 1, onValueChanged: (e) => handleSeparatorChange(e), width: '100px', elementStyle: { textAlign: 'center' } }), _jsx("div", { style: { paddingBottom: '7px' }, children: _jsx(TMCheckBox, { label: SDKUI_Localizator.RemoveSignatureIfPresent, value: settings.removeSignature, onValueChanged: (value) => updateSettings('removeSignature', value) }) })] }));
|
|
307
|
+
const formatSelectorsRow = (_jsxs("div", { style: { display: 'flex', flexWrap: 'wrap', columnGap: '10px', width: '100%' }, children: [_jsx("div", { style: { flex: '1 1 280px', minWidth: '280px' }, children: _jsx(TMInvoiceRetrieveFormats, { width: '100%', label: SDKUI_Localizator.ElectronicInvoice + ' - ' + SDKUI_Localizator.DisplayFormat, onValueChanged: (newValue) => updateSettings('invoiceFormat', newValue), value: settings.invoiceFormat, valueOrig: settings.invoiceFormat }) }), _jsx("div", { style: { flex: '1 1 280px', minWidth: '280px' }, children: _jsx(TMOrderRetrieveFormats, { width: '100%', label: SDKUI_Localizator.ElectronicOrder + ' - ' + SDKUI_Localizator.DisplayFormat, value: settings.orderFormat, valueOrig: settings.orderFormat, onValueChanged: (newValue) => updateSettings('orderFormat', newValue) }) })] }));
|
|
308
|
+
// ---- Render della sezione configurazione ----
|
|
309
|
+
const configSection = (_jsxs("div", { style: {
|
|
310
|
+
position: 'relative',
|
|
311
|
+
border: `1px solid ${TMColors.border_normal}`,
|
|
312
|
+
borderRadius: '8px',
|
|
313
|
+
padding: '10px 6px 6px 6px',
|
|
314
|
+
height: showTMRelationViewer ? 'calc(100% - 7px)' : undefined,
|
|
315
|
+
marginTop: '7px',
|
|
316
|
+
flex: showTMRelationViewer ? undefined : 1,
|
|
317
|
+
minHeight: 0,
|
|
318
|
+
display: 'flex',
|
|
319
|
+
flexDirection: 'column',
|
|
320
|
+
boxSizing: 'border-box'
|
|
321
|
+
}, children: [_jsx("span", { style: { ...getFloatingLabelStyle(), fontWeight: 600 }, children: SDKUI_Localizator.ConfigurationParameters }), _jsxs("div", { style: {
|
|
322
|
+
position: 'absolute',
|
|
323
|
+
top: '-8px',
|
|
324
|
+
right: '12px',
|
|
325
|
+
display: 'flex',
|
|
326
|
+
alignItems: 'center',
|
|
327
|
+
gap: '4px',
|
|
328
|
+
backgroundColor: 'white',
|
|
329
|
+
padding: '0 4px',
|
|
330
|
+
zIndex: 1
|
|
331
|
+
}, children: [_jsx(TMButton, { btnStyle: "toolbar", icon: _jsx(IconSave, {}), caption: SDKUI_Localizator.SaveLayout, color: "success", disabled: isLayoutSameAsSaved(), onClick: saveLayout }), hasSavedLayout && (_jsx(TMButton, { btnStyle: "toolbar", icon: _jsx(IconDelete, {}), caption: SDKUI_Localizator.RemoveLayout, color: "error", onClick: removeLayout }))] }), _jsxs("div", { style: {
|
|
332
|
+
display: 'flex',
|
|
333
|
+
flexDirection: 'column',
|
|
334
|
+
flex: 1,
|
|
335
|
+
overflowY: 'auto',
|
|
336
|
+
minHeight: 0,
|
|
337
|
+
}, children: [_jsx("div", { style: { display: 'flex', justifyContent: 'flex-start', alignItems: 'center', marginTop: "8px" }, children: _jsx(TMRadioButton, { dataSource: [
|
|
338
|
+
{ value: 'copy', display: SDKUI_Localizator.CopyToFolder },
|
|
339
|
+
{ value: 'zip', display: SDKUI_Localizator.CompressToZipFile }
|
|
340
|
+
], value: settings.exportMode, direction: "row", onValueChanged: (value) => updateSettings('exportMode', value) }) }), settings.exportMode === 'copy' && (_jsxs("div", { style: { display: 'flex', flexWrap: 'wrap', columnGap: '10px' }, children: [folderSelector, _jsx("div", { style: { flex: '1.5 1 420px', minWidth: '350px', width: '100%' }, children: _jsxs("div", { style: { position: 'relative', marginTop: '16px' }, children: [_jsx("span", { style: {
|
|
341
|
+
position: 'absolute',
|
|
342
|
+
top: '-10px',
|
|
343
|
+
left: '12px',
|
|
344
|
+
fontSize: '0.9rem',
|
|
345
|
+
color: TMColors.label_normal,
|
|
346
|
+
padding: '0 3px',
|
|
347
|
+
userSelect: 'none',
|
|
348
|
+
WebkitTouchCallout: 'none',
|
|
349
|
+
WebkitUserSelect: 'none',
|
|
350
|
+
width: 'max-content',
|
|
351
|
+
backgroundColor: TMColors.default_background,
|
|
352
|
+
zIndex: 1,
|
|
353
|
+
}, children: SDKUI_Localizator.IfFileExists }), _jsx("div", { style: { border: `1px solid ${TMColors.border_normal}`, borderRadius: '5px', padding: '4px 10px 4px 13px' }, children: _jsx(TMRadioButton, { dataSource: [
|
|
354
|
+
{ value: 'overwrite', display: SDKUI_Localizator.CopyAndReplace },
|
|
355
|
+
{ value: 'skip', display: SDKUI_Localizator.DoNotCopy },
|
|
356
|
+
{ value: 'rename', display: SDKUI_Localizator.CopyButRename },
|
|
357
|
+
], value: isUsingDefaultDownloads ? 'rename' : settings.fileExistsMode, direction: "row", disabled: isUsingDefaultDownloads, onValueChanged: (value) => updateSettings('fileExistsMode', value), fontSize: '0.9rem' }) }), isUsingDefaultDownloads && (_jsx("span", { style: { fontSize: '0.8rem', color: '#888', fontStyle: 'italic', marginTop: '4px', display: 'block' }, children: SDKUI_Localizator.BrowserAutoRenamesDuplicateFilesInDownloadsFolder }))] }) }), fileNamingRow, formatSelectorsRow] })), settings.exportMode === 'zip' && (_jsxs("div", { style: { display: 'flex', flexWrap: 'wrap', columnGap: '10px' }, children: [_jsxs("div", { style: { display: 'flex', flexWrap: 'wrap', columnGap: '10px', width: '100%' }, children: [folderSelector, _jsx("div", { style: { flex: '1 1 280px', minWidth: '280px' }, children: _jsx(TMTextBox, { label: SDKUI_Localizator.ZipFileName, value: settings.zipFileName, validationItems: zipValidationItems, autoComplete: "one-time-code", onValueChanged: (e) => updateSettings('zipFileName', e.target.value) }) }), _jsx("div", { style: { flex: '1 1 280px', minWidth: '280px' }, children: _jsx(TMTextBox, { label: SDKUI_Localizator.ProtectWithPasswordOptional, value: settings.zipPassword, type: "password", autoComplete: "one-time-code", onValueChanged: (e) => updateSettings('zipPassword', e.target.value) }) })] }), fileNamingRow, formatSelectorsRow] }))] })] }));
|
|
358
|
+
return (_jsx(TMModal, { width: calcResponsiveSizes(deviceType, showTMRelationViewer ? '95%' : '950px', '95%', '95%'), height: showTMRelationViewer ? '95%' : 'auto', title: getTitle(), onClose: onClose, showCloseButton: true, children: _jsx(TMLayoutWaitingContainer, { direction: 'vertical', showWaitPanel: showWaitPanel, showWaitPanelPrimary: showPrimary, showWaitPanelSecondary: showSecondary, waitPanelTitle: waitPanelTitle, waitPanelTextPrimary: waitPanelTextPrimary, waitPanelValuePrimary: waitPanelValuePrimary, waitPanelMaxValuePrimary: waitPanelMaxValuePrimary, waitPanelTextSecondary: waitPanelTextSecondary, waitPanelValueSecondary: waitPanelValueSecondary, waitPanelMaxValueSecondary: waitPanelMaxValueSecondary, isCancelable: true, abortController: abortController, children: _jsxs("div", { onContextMenu: (e) => e.preventDefault(), style: { display: 'flex', flexDirection: 'column', padding: '4px 4px 16px 4px', width: '100%', height: '100%', boxSizing: 'border-box', overflow: 'hidden' }, children: [showTMRelationViewer ? (_jsx("div", { style: { flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }, children: _jsxs(TMSplitterLayout, { direction: 'vertical', showSeparator: true, separatorSize: 8, separatorColor: 'transparent', separatorActiveColor: 'transparent', overflow: 'hidden', min: ["50", "50"], start: ['65%', '35%'], children: [_jsx(TMDownloadRelationViewerSection, { selectedDcmtInfos: selectedDcmtInfos, onSelectionChanged: setSelectedItemsRelationViewer, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), configSection] }, "TMCopyToFolder-relation-config") })) : (configSection), _jsx("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', flexShrink: 0, marginTop: '12px' }, children: _jsxs("button", { disabled: !isFormValid() || (showTMRelationViewer && selectedItemsRelationViewer.filter(i => i.isDcmt).length === 0), onClick: run, style: {
|
|
359
|
+
display: 'flex',
|
|
360
|
+
alignItems: 'center',
|
|
361
|
+
justifyContent: 'center',
|
|
362
|
+
gap: '6px',
|
|
363
|
+
padding: '8px 20px',
|
|
364
|
+
fontSize: '0.95rem',
|
|
365
|
+
fontWeight: 600,
|
|
366
|
+
color: '#fff',
|
|
367
|
+
background: (!isFormValid() || (showTMRelationViewer && selectedItemsRelationViewer.filter(i => i.isDcmt).length === 0))
|
|
368
|
+
? '#b0b0b0'
|
|
369
|
+
: 'linear-gradient(135deg, #28a745 0%, #218838 100%)',
|
|
370
|
+
border: 'none',
|
|
371
|
+
borderRadius: '6px',
|
|
372
|
+
cursor: (!isFormValid() || (showTMRelationViewer && selectedItemsRelationViewer.filter(i => i.isDcmt).length === 0)) ? 'not-allowed' : 'pointer',
|
|
373
|
+
boxShadow: (!isFormValid() || (showTMRelationViewer && selectedItemsRelationViewer.filter(i => i.isDcmt).length === 0))
|
|
374
|
+
? 'none'
|
|
375
|
+
: '0 2px 8px rgba(40, 167, 69, 0.35)',
|
|
376
|
+
transition: 'all 0.2s ease',
|
|
377
|
+
}, children: [_jsx(IconPlay, {}), _jsx("span", { children: SDKUI_Localizator.Execute })] }) })] }) }) }));
|
|
378
|
+
};
|
|
379
|
+
export default TMCopyToFolderForm;
|