@topconsultnpm/sdkui-react 6.20.0-dev1.4 → 6.20.0-dev1.5
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/editors/TMHtmlEditor.js +1 -1
- package/lib/components/features/documents/TMDcmtBlog.d.ts +1 -7
- package/lib/components/features/documents/TMDcmtBlog.js +29 -2
- package/lib/components/features/documents/TMDcmtForm.js +8 -23
- package/lib/components/features/search/TMSearchResult.js +146 -43
- package/lib/components/features/search/TMSearchResultCheckoutInfoForm.js +3 -3
- package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +1 -1
- package/lib/components/features/search/TMSearchResultsMenuItems.js +16 -16
- package/lib/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -1
- package/lib/helper/SDKUI_Globals.d.ts +3 -14
- package/lib/helper/SDKUI_Localizator.d.ts +7 -0
- package/lib/helper/SDKUI_Localizator.js +88 -0
- package/lib/helper/TMUtils.d.ts +3 -1
- package/lib/helper/TMUtils.js +51 -0
- package/lib/helper/checkinCheckoutManager.d.ts +55 -0
- package/lib/helper/checkinCheckoutManager.js +271 -0
- package/lib/helper/index.d.ts +1 -0
- package/lib/helper/index.js +1 -0
- package/lib/services/platform_services.d.ts +1 -1
- package/package.json +1 -1
- package/lib/helper/cicoHelper.d.ts +0 -31
- package/lib/helper/cicoHelper.js +0 -155
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { AccessLevels, CICO_MetadataNames, SDK_Globals } from "@topconsultnpm/sdk-ts";
|
|
3
|
+
import TMTooltip from "../components/base/TMTooltip";
|
|
4
|
+
import { Globalization, SDKUI_Globals, SDKUI_Localizator } from "./index";
|
|
5
|
+
import { DownloadTypes } from "../ts/types";
|
|
6
|
+
const findCheckOutUserName = (users, checkoutUserId) => {
|
|
7
|
+
let checkOutUser = users.find(user => user.id === checkoutUserId);
|
|
8
|
+
return checkOutUser ? checkOutUser.name : '-';
|
|
9
|
+
};
|
|
10
|
+
const colors = {
|
|
11
|
+
MEDIUM_GREEN: "#28a745",
|
|
12
|
+
};
|
|
13
|
+
export const getCicoDownloadFileName = (source, checkout, withTimestampAndExt) => {
|
|
14
|
+
const archiveID = SDK_Globals.tmSession?.SessionDescr?.archiveID;
|
|
15
|
+
if (!archiveID)
|
|
16
|
+
return '';
|
|
17
|
+
let baseName;
|
|
18
|
+
let tid;
|
|
19
|
+
let did;
|
|
20
|
+
let ext;
|
|
21
|
+
if (source.type === 'fileItem') {
|
|
22
|
+
// fileItem source
|
|
23
|
+
const { name, tid: tidValue, did: didValue, ext: extValue } = source.fileItem;
|
|
24
|
+
baseName = name.includes('.') ? name.substring(0, name.lastIndexOf('.')) : name;
|
|
25
|
+
tid = Number(tidValue);
|
|
26
|
+
did = Number(didValue);
|
|
27
|
+
ext = extValue;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// dcmtInfo source
|
|
31
|
+
const { dcmtInfo, originalFileName } = source;
|
|
32
|
+
const { TID, DID, FILEEXT } = dcmtInfo;
|
|
33
|
+
baseName = originalFileName.includes('.') ? originalFileName.substring(0, originalFileName.lastIndexOf('.')) : originalFileName;
|
|
34
|
+
tid = TID;
|
|
35
|
+
did = DID;
|
|
36
|
+
ext = FILEEXT;
|
|
37
|
+
}
|
|
38
|
+
const fileIdentifier = `${archiveID}~${baseName}~${tid}~${did}`;
|
|
39
|
+
const extension = withTimestampAndExt && ext ? `.${ext}` : '';
|
|
40
|
+
let timestamp = '';
|
|
41
|
+
if (checkout && withTimestampAndExt) {
|
|
42
|
+
const now = new Date();
|
|
43
|
+
const pad = (n) => n.toString().padStart(2, '0');
|
|
44
|
+
timestamp = `~${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
45
|
+
}
|
|
46
|
+
return `${checkout ? 'checkout~' : ''}${fileIdentifier}${timestamp}${extension}`;
|
|
47
|
+
};
|
|
48
|
+
export const cicoDownloadFilesCallback = async (sources, checkout, downloadDcmtsAsync) => {
|
|
49
|
+
const files = [];
|
|
50
|
+
sources.forEach(source => {
|
|
51
|
+
let tid;
|
|
52
|
+
let did;
|
|
53
|
+
let ext;
|
|
54
|
+
if (source.type === 'fileItem') {
|
|
55
|
+
tid = Number(source.fileItem.tid);
|
|
56
|
+
did = Number(source.fileItem.did);
|
|
57
|
+
ext = source.fileItem.ext;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
tid = source.dcmtInfo.TID;
|
|
61
|
+
did = source.dcmtInfo.DID;
|
|
62
|
+
ext = source.dcmtInfo.FILEEXT;
|
|
63
|
+
}
|
|
64
|
+
if (tid && did && ext) {
|
|
65
|
+
let fileName = getCicoDownloadFileName(source, checkout, true);
|
|
66
|
+
if (checkout) {
|
|
67
|
+
const newItem = {
|
|
68
|
+
TID: tid.toString(),
|
|
69
|
+
DID: did.toString(),
|
|
70
|
+
checkoutFolder: "",
|
|
71
|
+
checkoutName: fileName
|
|
72
|
+
};
|
|
73
|
+
updateCheckoutItem(newItem, source.type, "addOrUpdate");
|
|
74
|
+
}
|
|
75
|
+
files.push({ TID: tid, DID: did, FILEEXT: ext, fileName });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (files.length > 0)
|
|
79
|
+
await downloadDcmtsAsync(files, DownloadTypes.Dcmt, "download");
|
|
80
|
+
};
|
|
81
|
+
export const updateCheckoutItem = (item, type, action = "addOrUpdate") => {
|
|
82
|
+
// Select the appropriate array based on type
|
|
83
|
+
const currentItems = type === 'dcmtInfo' ? [...SDKUI_Globals.userSettings.dcmtCheckoutInfo] : [...SDKUI_Globals.userSettings.wgDraftCheckoutInfo];
|
|
84
|
+
// Find the index of an existing item that has the same TID and DID as the new item
|
|
85
|
+
const index = currentItems.findIndex(i => i.TID === item.TID && i.DID === item.DID);
|
|
86
|
+
// If the action is to add a new item or update an existing one
|
|
87
|
+
if (action === "addOrUpdate") {
|
|
88
|
+
if (index >= 0) {
|
|
89
|
+
// If the item exists, overwrite it with the new values
|
|
90
|
+
currentItems[index] = item;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// If the item does not exist, push it into the array
|
|
94
|
+
currentItems.push(item);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (action === "remove" && index >= 0) {
|
|
98
|
+
// If the action is to remove an item, remove it from the array
|
|
99
|
+
currentItems.splice(index, 1);
|
|
100
|
+
}
|
|
101
|
+
// Update the global array with the modified copy
|
|
102
|
+
if (type === 'dcmtInfo') {
|
|
103
|
+
SDKUI_Globals.userSettings.dcmtCheckoutInfo = currentItems;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
SDKUI_Globals.userSettings.wgDraftCheckoutInfo = currentItems;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
export const validateCicoFileName = (source, fileName) => {
|
|
110
|
+
const archiveID = SDK_Globals.tmSession?.SessionDescr?.archiveID;
|
|
111
|
+
let baseName;
|
|
112
|
+
let tid;
|
|
113
|
+
let did;
|
|
114
|
+
let ext;
|
|
115
|
+
if (source.type === 'fileItem') {
|
|
116
|
+
// fileItem source
|
|
117
|
+
const { name: originalName, tid: tidValue, did: didValue, ext: extValue } = source.fileItem;
|
|
118
|
+
baseName = originalName.includes('.') ? originalName.substring(0, originalName.lastIndexOf('.')) : originalName;
|
|
119
|
+
tid = Number(tidValue);
|
|
120
|
+
did = Number(didValue);
|
|
121
|
+
ext = extValue;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
// dcmtInfo source
|
|
125
|
+
const { dcmtInfo, originalFileName } = source;
|
|
126
|
+
const { TID, DID, FILEEXT } = dcmtInfo;
|
|
127
|
+
baseName = originalFileName.includes('.') ? originalFileName.substring(0, originalFileName.lastIndexOf('.')) : originalFileName;
|
|
128
|
+
tid = TID;
|
|
129
|
+
did = DID;
|
|
130
|
+
ext = FILEEXT;
|
|
131
|
+
}
|
|
132
|
+
// Ensure originalName has the extension
|
|
133
|
+
const normalizedExt = ext?.toLowerCase() ?? '';
|
|
134
|
+
const name = baseName.toLowerCase().endsWith(`.${normalizedExt}`) ? baseName : `${baseName}.${normalizedExt}`;
|
|
135
|
+
let fileNameToValidate = fileName;
|
|
136
|
+
const fileExtensionCheck = fileNameToValidate.split('.').pop() ?? '';
|
|
137
|
+
// Remove extension part
|
|
138
|
+
fileNameToValidate = fileNameToValidate.slice(0, -fileExtensionCheck.length - 1);
|
|
139
|
+
// Check and remove 'checkout~' prefix if present
|
|
140
|
+
const hasCheckoutPrefix = fileNameToValidate.startsWith('checkout~');
|
|
141
|
+
if (hasCheckoutPrefix) {
|
|
142
|
+
fileNameToValidate = fileNameToValidate.replace(/^checkout~/, '');
|
|
143
|
+
}
|
|
144
|
+
// Split the remaining string by underscores (~)
|
|
145
|
+
const parts = fileNameToValidate.split('~');
|
|
146
|
+
if (parts.length !== 5) {
|
|
147
|
+
return {
|
|
148
|
+
isValid: false,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
// Extract components starting from the end
|
|
152
|
+
const archiveCheck = parts[0];
|
|
153
|
+
const nameCheck = parts[1];
|
|
154
|
+
const tidCheck = parts[2];
|
|
155
|
+
const didCheck = parts[3];
|
|
156
|
+
// Validation checks
|
|
157
|
+
const expectedFullName = `${nameCheck}.${fileExtensionCheck}`.toLowerCase();
|
|
158
|
+
const isValidName = expectedFullName === name.toLowerCase();
|
|
159
|
+
const isValidDid = didCheck ? did.toString() === parseInt(didCheck, 10).toString() : false;
|
|
160
|
+
const isValidTid = tidCheck ? tid.toString() === parseInt(tidCheck, 10).toString() : false;
|
|
161
|
+
const isValidArchive = archiveCheck ? archiveCheck === archiveID : false;
|
|
162
|
+
const isValidExt = ext ? ext.toLowerCase() === fileExtensionCheck.toLowerCase() : false;
|
|
163
|
+
// Return validation results as an object
|
|
164
|
+
return {
|
|
165
|
+
isValid: !!(isValidName && isValidArchive && isValidDid && isValidTid && isValidExt),
|
|
166
|
+
validationResults: {
|
|
167
|
+
archiveID: {
|
|
168
|
+
expected: archiveID,
|
|
169
|
+
current: archiveCheck,
|
|
170
|
+
isValid: isValidArchive
|
|
171
|
+
},
|
|
172
|
+
name: {
|
|
173
|
+
expected: name.toLowerCase(),
|
|
174
|
+
current: expectedFullName,
|
|
175
|
+
isValid: isValidName
|
|
176
|
+
},
|
|
177
|
+
did: {
|
|
178
|
+
expected: did?.toString(),
|
|
179
|
+
current: didCheck,
|
|
180
|
+
isValid: isValidDid
|
|
181
|
+
},
|
|
182
|
+
tid: {
|
|
183
|
+
expected: tid.toString(),
|
|
184
|
+
current: tidCheck,
|
|
185
|
+
isValid: isValidTid
|
|
186
|
+
},
|
|
187
|
+
fileExtension: {
|
|
188
|
+
expected: ext?.toLowerCase(),
|
|
189
|
+
current: fileExtensionCheck.toLowerCase(),
|
|
190
|
+
isValid: isValidExt
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
export const renderCicoCheckInContent = (source, selectedFilename, isValid, validationItems, color = "#996300") => {
|
|
196
|
+
const fileName = source.type === 'fileItem' ? source.fileItem.name : (source.dcmtInfo.fileName ?? SDKUI_Localizator.SearchResult);
|
|
197
|
+
return _jsxs("div", { style: { width: "100%", height: "100%" }, children: [SDKUI_Localizator.CheckInElementConfirm.replaceParams(fileName), !isValid && _jsxs("div", { style: { width: "100%", height: "100%", marginTop: '15px' }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { fontSize: '12px', color, marginBottom: '12px' }, children: SDKUI_Localizator.ElementNameConventionError }), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '6px' }, children: [_jsxs("div", { style: { color }, children: [_jsx("strong", { style: { color }, children: SDKUI_Localizator.Expected }), ":", ' ', _jsx("span", { style: { fontStyle: 'italic' }, children: getCicoDownloadFileName(source, true, false) })] }), _jsxs("div", { style: { color }, children: [_jsx("strong", { style: { color }, children: SDKUI_Localizator.SelectedSingular }), ":", ' ', _jsx("span", { style: { fontStyle: 'italic' }, children: selectedFilename.name })] })] })] }), validationItems && Object.entries(validationItems).filter(([_, value]) => !value.isValid).length > 0 && (_jsxs("div", { style: { width: "100%", height: "100%", marginTop: '15px' }, children: [_jsx("hr", {}), _jsxs("table", { style: { width: "100%", borderCollapse: "collapse", color }, children: [_jsx("caption", { style: { textAlign: "center", fontWeight: "bold", marginBottom: "5px" }, children: SDKUI_Localizator.Anomalies }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: { textAlign: "left", borderBottom: "1px solid #eee" }, children: SDKUI_Localizator.Value }), _jsx("th", { style: { textAlign: "left", borderBottom: "1px solid #eee" }, children: SDKUI_Localizator.Expected }), _jsx("th", { style: { textAlign: "left", borderBottom: "1px solid #eee" }, children: SDKUI_Localizator.Current })] }) }), _jsx("tbody", { children: Object.entries(validationItems).filter(([_, value]) => !value.isValid).map(([key, result]) => (_jsxs("tr", { children: [_jsx("td", { style: { borderBottom: "1px solid #eee" }, children: _jsx("strong", { style: { textTransform: "capitalize" }, children: key }) }), _jsxs("td", { style: { borderBottom: "1px solid #eee" }, children: [" ", result.expected || "-"] }), _jsxs("td", { style: { borderBottom: "1px solid #eee" }, children: [" ", result.current || "-"] })] }, key))) })] }), _jsx("hr", {})] })), _jsx("div", { style: { fontSize: '12px', marginTop: '15px', marginBottom: '15px' }, children: SDKUI_Localizator.ProceedAnyway })] })] });
|
|
198
|
+
};
|
|
199
|
+
const getDcmtCicoInfo = (dtd) => {
|
|
200
|
+
const cico = {
|
|
201
|
+
CICO: 0,
|
|
202
|
+
CanCICO: AccessLevels.No,
|
|
203
|
+
CanDelChronology: AccessLevels.No,
|
|
204
|
+
UserID_MID: 0,
|
|
205
|
+
Date_MID: 0,
|
|
206
|
+
Ver_MID: 0,
|
|
207
|
+
UserID_CanViewOrUpdate: AccessLevels.No,
|
|
208
|
+
Date_CanViewOrUpdate: AccessLevels.No,
|
|
209
|
+
Ver_CanViewOrUpdate: AccessLevels.No,
|
|
210
|
+
};
|
|
211
|
+
if (dtd === undefined)
|
|
212
|
+
return cico;
|
|
213
|
+
cico.CICO = dtd.cico ?? 0;
|
|
214
|
+
cico.CanCICO = dtd.perm?.canCICO ?? AccessLevels.No;
|
|
215
|
+
cico.CanDelChronology = dtd.perm?.canDelChron ?? AccessLevels.No;
|
|
216
|
+
const mdCheckout = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutUserID);
|
|
217
|
+
if (mdCheckout) {
|
|
218
|
+
cico.UserID_MID = mdCheckout.fromMID;
|
|
219
|
+
cico.UserID_CanViewOrUpdate = (mdCheckout.perm?.canView == AccessLevels.Yes || mdCheckout.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
220
|
+
}
|
|
221
|
+
const mdDate = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutDate);
|
|
222
|
+
if (mdDate) {
|
|
223
|
+
cico.Date_MID = mdDate.fromMID;
|
|
224
|
+
cico.Date_CanViewOrUpdate = (mdDate.perm?.canView == AccessLevels.Yes || mdDate.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
225
|
+
}
|
|
226
|
+
const mdVer = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_Version);
|
|
227
|
+
if (mdVer) {
|
|
228
|
+
cico.Ver_MID = mdVer.fromMID;
|
|
229
|
+
cico.Ver_CanViewOrUpdate = (mdVer.perm?.canView == AccessLevels.Yes || mdVer.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
230
|
+
}
|
|
231
|
+
return cico;
|
|
232
|
+
};
|
|
233
|
+
export const getDcmtCicoStatus = (dcmt, allUsers, dtd) => {
|
|
234
|
+
if (dcmt === undefined || dtd === undefined) {
|
|
235
|
+
return {
|
|
236
|
+
cicoEnabled: false,
|
|
237
|
+
checkoutStatus: { isCheckedOut: false, mode: '', version: 1, icon: null }
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
const cicoInfo = getDcmtCicoInfo(dtd);
|
|
241
|
+
const CICO_CheckoutUserID_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutUserID);
|
|
242
|
+
const CICO_CheckoutDate_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutDate);
|
|
243
|
+
const CICO_Version_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_Version);
|
|
244
|
+
const keyVersion = dcmt.TID + "_" + (CICO_Version_Meta?.id ?? 0);
|
|
245
|
+
const versionRaw = CICO_Version_Meta?.id ? dcmt[keyVersion] : undefined;
|
|
246
|
+
const version = (versionRaw != null && !isNaN(Number(versionRaw))) ? Number(versionRaw) : 1;
|
|
247
|
+
let checkoutStatus = { isCheckedOut: false, mode: '', version: version, icon: null, };
|
|
248
|
+
const userID = SDK_Globals.tmSession?.SessionDescr?.userID;
|
|
249
|
+
if (dcmt && CICO_CheckoutUserID_Meta?.id) {
|
|
250
|
+
const keyUserID = dcmt.TID + "_" + CICO_CheckoutUserID_Meta.id;
|
|
251
|
+
const checkoutUserIdValue = dcmt[keyUserID];
|
|
252
|
+
const checkoutUserId = Number(checkoutUserIdValue);
|
|
253
|
+
if (userID && checkoutUserIdValue && !isNaN(checkoutUserId) && checkoutUserId > 0) {
|
|
254
|
+
// editMode: l'utente corrente è quello che ha fatto il checkout
|
|
255
|
+
// lockMode: un altro utente ha fatto il checkout
|
|
256
|
+
const mode = (userID && userID === checkoutUserId) ? 'editMode' : 'lockMode';
|
|
257
|
+
// Recupera i dati aggiuntivi per il tooltip
|
|
258
|
+
const keyDate = dcmt.TID + "_" + (CICO_CheckoutDate_Meta?.id ?? 0);
|
|
259
|
+
const checkoutDate = CICO_CheckoutDate_Meta?.id ? dcmt[keyDate] : undefined;
|
|
260
|
+
const editLockTooltipText = _jsxs(_Fragment, { children: [_jsxs("div", { style: { textAlign: "center" }, children: [mode === 'editMode' && (_jsxs(_Fragment, { children: [_jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-edit" }), SDKUI_Localizator.CurrentUserExtract] })), mode === 'lockMode' && (_jsxs(_Fragment, { children: [_jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-lock" }), SDKUI_Localizator.ExtractedFromOtherUser] }))] }), _jsx("hr", {}), _jsxs("div", { style: { textAlign: "left" }, children: [_jsxs("ul", { children: [_jsxs("li", { children: ["- ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDKUI_Localizator.ExtractedBy }), ": ", findCheckOutUserName(allUsers, checkoutUserId), " (ID: ", checkoutUserId, ")"] }), _jsxs("li", { children: ["- ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDKUI_Localizator.ExtractedOn }), ": ", Globalization.getDateTimeDisplayValue(checkoutDate?.toString())] })] }), _jsx("hr", {}), _jsx("ul", { children: _jsxs("li", { children: ["- ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDKUI_Localizator.Version }), ": ", version ?? 1] }) })] })] });
|
|
261
|
+
const icon = mode === 'editMode'
|
|
262
|
+
? _jsx(TMTooltip, { content: editLockTooltipText, children: _jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-edit" }) })
|
|
263
|
+
: _jsx(TMTooltip, { content: editLockTooltipText, children: _jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-lock" }) });
|
|
264
|
+
checkoutStatus = { isCheckedOut: true, mode: mode, icon: icon, version: version };
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
cicoEnabled: cicoInfo.CICO === 1 && cicoInfo.CanCICO === AccessLevels.Yes,
|
|
269
|
+
checkoutStatus: checkoutStatus
|
|
270
|
+
};
|
|
271
|
+
};
|
package/lib/helper/index.d.ts
CHANGED
package/lib/helper/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export declare class PlatformObjectService {
|
|
|
6
6
|
static readonly retrieveAllAdminAsync: (objClass: ObjectClasses, jobType?: JobTypes) => Promise<import("@topconsultnpm/sdk-ts").UserDescriptor[] | DcmtTypeDescriptor[] | import("@topconsultnpm/sdk-ts").AreaDescriptor[] | import("@topconsultnpm/sdk-ts").RelationDescriptor[] | import("@topconsultnpm/sdk-ts").FEDistillerJobDescriptor[] | import("@topconsultnpm/sdk-ts").DataListDescriptor[] | import("@topconsultnpm/sdk-ts").DiskDescriptor[] | import("@topconsultnpm/sdk-ts").GroupDescriptor[] | import("@topconsultnpm/sdk-ts").LDAPDescriptor[] | import("@topconsultnpm/sdk-ts").NumeratorDescriptor[] | ProcessDescriptor[] | import("@topconsultnpm/sdk-ts").SAPLoginDescriptor[] | import("@topconsultnpm/sdk-ts").SignCertDescriptor[] | import("@topconsultnpm/sdk-ts").SignServerDescriptor[] | import("@topconsultnpm/sdk-ts").TreeDescriptor[] | import("@topconsultnpm/sdk-ts").TSADescriptor[] | import("@topconsultnpm/sdk-ts").WFDescriptor[] | undefined>;
|
|
7
7
|
private static readonly loadCacheForJobAsync;
|
|
8
8
|
private static readonly retrieveAdminJobAsync;
|
|
9
|
-
static readonly retrieveAdminAsync: (objClass: ObjectClasses, jobType: JobTypes, id: number) => Promise<import("@topconsultnpm/sdk-ts").UserDescriptor | import("@topconsultnpm/sdk-ts").MailSenderJobDescriptor |
|
|
9
|
+
static readonly retrieveAdminAsync: (objClass: ObjectClasses, jobType: JobTypes, id: number) => Promise<import("@topconsultnpm/sdk-ts").UserDescriptor | DcmtTypeDescriptor | import("@topconsultnpm/sdk-ts").MailSenderJobDescriptor | import("@topconsultnpm/sdk-ts").SavedQueryDescriptor | import("@topconsultnpm/sdk-ts").DataListDescriptor | import("@topconsultnpm/sdk-ts").AreaDescriptor | import("@topconsultnpm/sdk-ts").BasketTypeDescriptor | import("@topconsultnpm/sdk-ts").RelationDescriptor | import("@topconsultnpm/sdk-ts").TaskDescriptor | import("@topconsultnpm/sdk-ts").WorkingGroupDescriptor | import("@topconsultnpm/sdk-ts").BarcodeArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").BatchUpdaterJobDescriptor | import("@topconsultnpm/sdk-ts").CassettoDoganaleJobDescriptor | import("@topconsultnpm/sdk-ts").CassettoDoganalePlusJobDescriptor | import("@topconsultnpm/sdk-ts").CassettoFiscaleQueryJobDescriptor | import("@topconsultnpm/sdk-ts").CassettoFiscaleSenderJobDescriptor | import("@topconsultnpm/sdk-ts").CheckSequenceJobDescriptor | import("@topconsultnpm/sdk-ts").COSCheckerJobDescriptor | import("@topconsultnpm/sdk-ts").DcmtConverterJobDescriptor | import("@topconsultnpm/sdk-ts").DcmtDeleterJobDescriptor | import("@topconsultnpm/sdk-ts").DcmtNoteJobDescriptor | import("@topconsultnpm/sdk-ts").DcmtPrinterJobDescriptor | import("@topconsultnpm/sdk-ts").FEAttacherJobDescriptor | import("@topconsultnpm/sdk-ts").FECreatorTxtJobDescriptor | import("@topconsultnpm/sdk-ts").FEDetacherJobDescriptor | import("@topconsultnpm/sdk-ts").FEDistillerJobDescriptor | import("@topconsultnpm/sdk-ts").FESenderWsJobDescriptor | import("@topconsultnpm/sdk-ts").FESplitterJobDescriptor | import("@topconsultnpm/sdk-ts").FEValidatorJobDescriptor | import("@topconsultnpm/sdk-ts").FileArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").FileCheckerJobDescriptor | import("@topconsultnpm/sdk-ts").FileExecJobDescriptor | import("@topconsultnpm/sdk-ts").FileExportJobDescriptor | import("@topconsultnpm/sdk-ts").FileMoverJobDescriptor | import("@topconsultnpm/sdk-ts").LexJobDescriptor | import("@topconsultnpm/sdk-ts").LinkerJobDescriptor | import("@topconsultnpm/sdk-ts").MailArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").MailQueryJobDescriptor | import("@topconsultnpm/sdk-ts").MigrationJobDescriptor | import("@topconsultnpm/sdk-ts").PdDCreatorJobDescriptor | import("@topconsultnpm/sdk-ts").PDFArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").PdVArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").PdVQueryJobDescriptor | import("@topconsultnpm/sdk-ts").PdVSenderJobDescriptor | import("@topconsultnpm/sdk-ts").PeppolQueryJobDescriptor | import("@topconsultnpm/sdk-ts").PeppolSenderJobDescriptor | import("@topconsultnpm/sdk-ts").PostelQueryJobDescriptor | import("@topconsultnpm/sdk-ts").PostelSenderJobDescriptor | import("@topconsultnpm/sdk-ts").ReplicatorJobDescriptor | import("@topconsultnpm/sdk-ts").SAPAlignerJobDescriptor | import("@topconsultnpm/sdk-ts").SAPBarcodeJobDescriptor | import("@topconsultnpm/sdk-ts").SAPDataReaderJobDescriptor | import("@topconsultnpm/sdk-ts").SAPDataWriterJobDescriptor | import("@topconsultnpm/sdk-ts").SignerJobDescriptor | import("@topconsultnpm/sdk-ts").SpoolArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").UpdaterJobDescriptor | import("@topconsultnpm/sdk-ts").DiskDescriptor | import("@topconsultnpm/sdk-ts").GroupDescriptor | import("@topconsultnpm/sdk-ts").LDAPDescriptor | import("@topconsultnpm/sdk-ts").NumeratorDescriptor | ProcessDescriptor | import("@topconsultnpm/sdk-ts").SAPLoginDescriptor | import("@topconsultnpm/sdk-ts").SignCertDescriptor | import("@topconsultnpm/sdk-ts").SignServerDescriptor | import("@topconsultnpm/sdk-ts").TreeDescriptor | import("@topconsultnpm/sdk-ts").TSADescriptor | import("@topconsultnpm/sdk-ts").WFDescriptor | undefined>;
|
|
10
10
|
private static readonly updateJobAsync;
|
|
11
11
|
static readonly updateAsync: (objClass: ObjectClasses, jobType: JobTypes, d: any, ...args: any[]) => Promise<number | undefined>;
|
|
12
12
|
private static readonly createJobAsync;
|
package/package.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { AccessLevels, DcmtTypeDescriptor, FileDescriptor, UserDescriptor } from "@topconsultnpm/sdk-ts";
|
|
3
|
-
import { DcmtCheckoutInfo } from "./index";
|
|
4
|
-
import { DcmtInfo, DownloadModes, DownloadTypes } from "../ts/types";
|
|
5
|
-
export interface CheckInCheckOutInfo {
|
|
6
|
-
CICO: number;
|
|
7
|
-
CanCICO: AccessLevels;
|
|
8
|
-
CanDelChronology: AccessLevels;
|
|
9
|
-
UserID_MID: number;
|
|
10
|
-
Date_MID: number;
|
|
11
|
-
Ver_MID: number;
|
|
12
|
-
UserID_CanViewOrUpdate: AccessLevels;
|
|
13
|
-
Date_CanViewOrUpdate: AccessLevels;
|
|
14
|
-
Ver_CanViewOrUpdate: AccessLevels;
|
|
15
|
-
}
|
|
16
|
-
export declare const colors: {
|
|
17
|
-
MEDIUM_GREEN: string;
|
|
18
|
-
};
|
|
19
|
-
export interface CheckoutStatusResult {
|
|
20
|
-
isCheckedOut: boolean;
|
|
21
|
-
mode: 'editMode' | 'lockMode' | '';
|
|
22
|
-
version: number;
|
|
23
|
-
icon: React.ReactNode | null;
|
|
24
|
-
}
|
|
25
|
-
export declare const cicoIsEnabled: (dcmt: any, allUsers: Array<UserDescriptor>, dtd: DcmtTypeDescriptor | undefined) => {
|
|
26
|
-
cicoEnabled: boolean;
|
|
27
|
-
checkoutStatus: CheckoutStatusResult;
|
|
28
|
-
};
|
|
29
|
-
export declare const getCicoDownloadFileName: (originalFileName: string, fileItem: DcmtInfo | undefined, checkout: boolean, withTimestampAndExt: boolean) => string;
|
|
30
|
-
export declare const updateDcmtCheckoutItem: (item: DcmtCheckoutInfo, action?: "addOrUpdate" | "remove") => void;
|
|
31
|
-
export declare const downloadFilesCallback: (originalFileName: string, dcmt: Array<DcmtInfo>, checkout: boolean, downloadDcmtsAsync: (inputDcmts: Array<DcmtInfo> | undefined, downloadType?: DownloadTypes, downloadMode?: DownloadModes, onFileDownloaded?: (dcmtFile: File) => void, confirmAttachments?: (list: FileDescriptor[]) => Promise<string[] | undefined>, skipConfirmation?: boolean) => Promise<void>) => Promise<void>;
|
package/lib/helper/cicoHelper.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AccessLevels, CICO_MetadataNames, SDK_Globals } from "@topconsultnpm/sdk-ts";
|
|
3
|
-
import TMTooltip from "../components/base/TMTooltip";
|
|
4
|
-
import { Globalization, SDKUI_Globals, SDKUI_Localizator } from "./index";
|
|
5
|
-
import { DownloadTypes } from "../ts/types";
|
|
6
|
-
export const colors = {
|
|
7
|
-
MEDIUM_GREEN: "#28a745",
|
|
8
|
-
};
|
|
9
|
-
const getCicoInfo = (dtd) => {
|
|
10
|
-
const cico = {
|
|
11
|
-
CICO: 0,
|
|
12
|
-
CanCICO: AccessLevels.No,
|
|
13
|
-
CanDelChronology: AccessLevels.No,
|
|
14
|
-
UserID_MID: 0,
|
|
15
|
-
Date_MID: 0,
|
|
16
|
-
Ver_MID: 0,
|
|
17
|
-
UserID_CanViewOrUpdate: AccessLevels.No,
|
|
18
|
-
Date_CanViewOrUpdate: AccessLevels.No,
|
|
19
|
-
Ver_CanViewOrUpdate: AccessLevels.No,
|
|
20
|
-
};
|
|
21
|
-
if (dtd === undefined)
|
|
22
|
-
return cico;
|
|
23
|
-
cico.CICO = dtd.cico ?? 0;
|
|
24
|
-
cico.CanCICO = dtd.perm?.canCICO ?? AccessLevels.No;
|
|
25
|
-
cico.CanDelChronology = dtd.perm?.canDelChron ?? AccessLevels.No;
|
|
26
|
-
const mdCheckout = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutUserID);
|
|
27
|
-
if (mdCheckout) {
|
|
28
|
-
cico.UserID_MID = mdCheckout.fromMID;
|
|
29
|
-
cico.UserID_CanViewOrUpdate = (mdCheckout.perm?.canView == AccessLevels.Yes || mdCheckout.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
30
|
-
}
|
|
31
|
-
const mdDate = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutDate);
|
|
32
|
-
if (mdDate) {
|
|
33
|
-
cico.Date_MID = mdDate.fromMID;
|
|
34
|
-
cico.Date_CanViewOrUpdate = (mdDate.perm?.canView == AccessLevels.Yes || mdDate.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
35
|
-
}
|
|
36
|
-
const mdVer = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_Version);
|
|
37
|
-
if (mdVer) {
|
|
38
|
-
cico.Ver_MID = mdVer.fromMID;
|
|
39
|
-
cico.Ver_CanViewOrUpdate = (mdVer.perm?.canView == AccessLevels.Yes || mdVer.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
40
|
-
}
|
|
41
|
-
return cico;
|
|
42
|
-
};
|
|
43
|
-
const findCheckOutUserName = (allUsers, checkoutUserId) => {
|
|
44
|
-
let checkOutUser = allUsers.find(user => user.id === checkoutUserId);
|
|
45
|
-
return checkOutUser ? checkOutUser.name : '-';
|
|
46
|
-
};
|
|
47
|
-
export const cicoIsEnabled = (dcmt, allUsers, dtd) => {
|
|
48
|
-
if (dcmt === undefined || dtd === undefined) {
|
|
49
|
-
return {
|
|
50
|
-
cicoEnabled: false,
|
|
51
|
-
checkoutStatus: { isCheckedOut: false, mode: '', version: 1, icon: null }
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
const cicoInfo = getCicoInfo(dtd);
|
|
55
|
-
const CICO_CheckoutUserID_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutUserID);
|
|
56
|
-
const CICO_CheckoutDate_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutDate);
|
|
57
|
-
const CICO_Version_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_Version);
|
|
58
|
-
const keyVersion = dcmt.TID + "_" + (CICO_Version_Meta?.id ?? 0);
|
|
59
|
-
const versionRaw = CICO_Version_Meta?.id ? dcmt[keyVersion] : undefined;
|
|
60
|
-
const version = (versionRaw != null && !isNaN(Number(versionRaw))) ? Number(versionRaw) : 1;
|
|
61
|
-
let checkoutStatus = { isCheckedOut: false, mode: '', version: version, icon: null, };
|
|
62
|
-
const userID = SDK_Globals.tmSession?.SessionDescr?.userID;
|
|
63
|
-
if (dcmt && CICO_CheckoutUserID_Meta?.id) {
|
|
64
|
-
const keyUserID = dcmt.TID + "_" + CICO_CheckoutUserID_Meta.id;
|
|
65
|
-
const checkoutUserIdValue = dcmt[keyUserID];
|
|
66
|
-
const checkoutUserId = Number(checkoutUserIdValue);
|
|
67
|
-
if (userID && checkoutUserIdValue && !isNaN(checkoutUserId) && checkoutUserId > 0) {
|
|
68
|
-
// editMode: l'utente corrente è quello che ha fatto il checkout
|
|
69
|
-
// lockMode: un altro utente ha fatto il checkout
|
|
70
|
-
const mode = (userID && userID === checkoutUserId) ? 'editMode' : 'lockMode';
|
|
71
|
-
// Recupera i dati aggiuntivi per il tooltip
|
|
72
|
-
const keyDate = dcmt.TID + "_" + (CICO_CheckoutDate_Meta?.id ?? 0);
|
|
73
|
-
const checkoutDate = CICO_CheckoutDate_Meta?.id ? dcmt[keyDate] : undefined;
|
|
74
|
-
const editLockTooltipText = _jsxs(_Fragment, { children: [_jsxs("div", { style: { textAlign: "center" }, children: [mode === 'editMode' && (_jsxs(_Fragment, { children: [_jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-edit" }), SDKUI_Localizator.CurrentUserExtract] })), mode === 'lockMode' && (_jsxs(_Fragment, { children: [_jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-lock" }), SDKUI_Localizator.ExtractedFromOtherUser] }))] }), _jsx("hr", {}), _jsxs("div", { style: { textAlign: "left" }, children: [_jsxs("ul", { children: [_jsxs("li", { children: ["- ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDKUI_Localizator.ExtractedBy }), ": ", findCheckOutUserName(allUsers, checkoutUserId), " (ID: ", checkoutUserId, ")"] }), _jsxs("li", { children: ["- ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDKUI_Localizator.ExtractedOn }), ": ", Globalization.getDateTimeDisplayValue(checkoutDate?.toString())] })] }), _jsx("hr", {}), _jsx("ul", { children: _jsxs("li", { children: ["- ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDKUI_Localizator.Version }), ": ", version ?? 1] }) })] })] });
|
|
75
|
-
const icon = mode === 'editMode'
|
|
76
|
-
? _jsx(TMTooltip, { content: editLockTooltipText, children: _jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-edit" }) })
|
|
77
|
-
: _jsx(TMTooltip, { content: editLockTooltipText, children: _jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-lock" }) });
|
|
78
|
-
checkoutStatus = { isCheckedOut: true, mode: mode, icon: icon, version: version };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
cicoEnabled: cicoInfo.CICO === 1 && cicoInfo.CanCICO === AccessLevels.Yes,
|
|
83
|
-
checkoutStatus: checkoutStatus
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
export const getCicoDownloadFileName = (originalFileName, fileItem, checkout, withTimestampAndExt) => {
|
|
87
|
-
// If no fileItem is provided, return an empty string immediately
|
|
88
|
-
if (fileItem === undefined)
|
|
89
|
-
return '';
|
|
90
|
-
// Retrieve the archiveID from the global session object
|
|
91
|
-
const archiveID = SDK_Globals.tmSession?.SessionDescr?.archiveID;
|
|
92
|
-
// Destructure the fileItem object into properties
|
|
93
|
-
const { DID, TID, FILEEXT } = fileItem;
|
|
94
|
-
// Determine the base name of the file (without its extension)
|
|
95
|
-
// If the file name contains '.', only take the substring before the last dot
|
|
96
|
-
const baseName = originalFileName.includes('.') ? originalFileName.substring(0, originalFileName.lastIndexOf('.')) : originalFileName;
|
|
97
|
-
// Construct a unique identifier for the file combining archiveID, baseName, tid, and did.
|
|
98
|
-
const fileIdentifier = `${archiveID}~${baseName}~${TID}~${DID}`;
|
|
99
|
-
// Determine the extension to append to the file name
|
|
100
|
-
const extension = withTimestampAndExt && FILEEXT ? `.${FILEEXT}` : '';
|
|
101
|
-
// Initialize an empty string for the timestamp (to be appended if needed)
|
|
102
|
-
let timestamp = '';
|
|
103
|
-
// If this is a checkout and timestamps should be added, generate a formatted timestamp
|
|
104
|
-
if (checkout && withTimestampAndExt) {
|
|
105
|
-
const now = new Date();
|
|
106
|
-
const pad = (n) => n.toString().padStart(2, '0');
|
|
107
|
-
// Format the timestamp as YYYYMMDDHHMMSS and prefix with '~'
|
|
108
|
-
timestamp = `~${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
109
|
-
}
|
|
110
|
-
// Construct and return the final file name: [archiveID]~[name]~[tid]~[did]~[timestamp].[extension]
|
|
111
|
-
return `${checkout ? 'checkout~' : ''}${fileIdentifier}${timestamp}${extension}`;
|
|
112
|
-
};
|
|
113
|
-
export const updateDcmtCheckoutItem = (item, action = "addOrUpdate") => {
|
|
114
|
-
// Make a shallow copy of the global draft checkout items array to avoid direct mutation
|
|
115
|
-
const currentItems = [...SDKUI_Globals.userSettings.dcmtCheckoutInfo];
|
|
116
|
-
// Find the index of an existing item that has the same TID and DID as the new item
|
|
117
|
-
const index = currentItems.findIndex(i => i.TID === item.TID && i.DID === item.DID);
|
|
118
|
-
// If the action is to add a new item or update an existing one
|
|
119
|
-
if (action === "addOrUpdate") {
|
|
120
|
-
if (index >= 0) {
|
|
121
|
-
// If the item exists, overwrite it with the new values
|
|
122
|
-
currentItems[index] = item;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
// If the item does not exist, push it into the array
|
|
126
|
-
currentItems.push(item);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else if (action === "remove" && index >= 0) { // If the action is to remove an item
|
|
130
|
-
// Remove the item from the array
|
|
131
|
-
currentItems.splice(index, 1);
|
|
132
|
-
}
|
|
133
|
-
// Update the global array with the modified copy
|
|
134
|
-
SDKUI_Globals.userSettings.dcmtCheckoutInfo = currentItems;
|
|
135
|
-
};
|
|
136
|
-
export const downloadFilesCallback = async (originalFileName, dcmt, checkout, downloadDcmtsAsync) => {
|
|
137
|
-
const files = [];
|
|
138
|
-
dcmt.forEach(file => {
|
|
139
|
-
if (file.TID && file.DID && file.FILEEXT) {
|
|
140
|
-
let fileName = getCicoDownloadFileName(originalFileName, file, checkout, true);
|
|
141
|
-
if (checkout) {
|
|
142
|
-
const newItem = {
|
|
143
|
-
TID: file.TID.toString(),
|
|
144
|
-
DID: file.DID.toString(),
|
|
145
|
-
checkoutFolder: "",
|
|
146
|
-
checkoutName: fileName
|
|
147
|
-
};
|
|
148
|
-
updateDcmtCheckoutItem(newItem, "addOrUpdate");
|
|
149
|
-
}
|
|
150
|
-
files.push({ TID: file.TID, DID: file.DID, FILEEXT: file.FILEEXT, fileName });
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
if (files.length > 0)
|
|
154
|
-
await downloadDcmtsAsync(files, DownloadTypes.Dcmt, "download");
|
|
155
|
-
};
|