@topconsultnpm/sdkui-react 6.21.0-dev1.42 → 6.21.0-dev1.43
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.
|
@@ -28,6 +28,10 @@ export interface CheckoutStatusResult {
|
|
|
28
28
|
version: number;
|
|
29
29
|
icon: React.ReactNode | null;
|
|
30
30
|
editLockTooltipText: React.ReactNode | null;
|
|
31
|
+
checkoutUserId: number | undefined;
|
|
32
|
+
checkoutDate: any;
|
|
33
|
+
fileExt: string | null;
|
|
34
|
+
isMetadata: boolean;
|
|
31
35
|
}
|
|
32
36
|
export type DownloadSource = {
|
|
33
37
|
type: 'fileItem';
|
|
@@ -40,7 +44,7 @@ export type DownloadSource = {
|
|
|
40
44
|
export declare const getCicoDownloadFileName: (source: DownloadSource, checkout: boolean, withTimestampAndExt: boolean) => string;
|
|
41
45
|
export declare const cicoDownloadFilesCallback: (sources: Array<DownloadSource>, 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>;
|
|
42
46
|
export declare const updateCicoCheckoutStorageItem: (item: CheckoutInfo, type: "fileItem" | "dcmtInfo", action?: "addOrUpdate" | "remove") => void;
|
|
43
|
-
export declare const validateCicoFileName: (source: DownloadSource, fileName: string) => FileNameValidation;
|
|
47
|
+
export declare const validateCicoFileName: (source: DownloadSource, fileName: string, checkoutDate?: string | null) => FileNameValidation;
|
|
44
48
|
type ValidationResult = {
|
|
45
49
|
expected: string | number | undefined;
|
|
46
50
|
current: string | number | undefined;
|
|
@@ -52,6 +56,7 @@ type FileNameValidationItems = {
|
|
|
52
56
|
did: ValidationResult;
|
|
53
57
|
tid: ValidationResult;
|
|
54
58
|
fileExtension: ValidationResult;
|
|
59
|
+
checkoutDate?: ValidationResult;
|
|
55
60
|
};
|
|
56
61
|
type FileNameValidation = {
|
|
57
62
|
isValid: boolean;
|
|
@@ -105,7 +105,7 @@ export const updateCicoCheckoutStorageItem = (item, type, action = "addOrUpdate"
|
|
|
105
105
|
SDKUI_Globals.userSettings.wgDraftCheckoutInfo = currentItems;
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
|
-
export const validateCicoFileName = (source, fileName) => {
|
|
108
|
+
export const validateCicoFileName = (source, fileName, checkoutDate) => {
|
|
109
109
|
const archiveID = SDK_Globals.tmSession?.SessionDescr?.archiveID;
|
|
110
110
|
let baseName;
|
|
111
111
|
let tid;
|
|
@@ -152,6 +152,7 @@ export const validateCicoFileName = (source, fileName) => {
|
|
|
152
152
|
const nameCheck = parts[1];
|
|
153
153
|
const tidCheck = parts[2];
|
|
154
154
|
const didCheck = parts[3];
|
|
155
|
+
const timestampCheck = parts[4]; // Timestamp from filename: YYYYMMDDHHmmss
|
|
155
156
|
// Validation checks
|
|
156
157
|
const expectedFullName = `${nameCheck}.${fileExtensionCheck}`.toLowerCase();
|
|
157
158
|
const isValidName = expectedFullName === name.toLowerCase();
|
|
@@ -159,9 +160,53 @@ export const validateCicoFileName = (source, fileName) => {
|
|
|
159
160
|
const isValidTid = tidCheck ? tid.toString() === parseInt(tidCheck, 10).toString() : false;
|
|
160
161
|
const isValidArchive = archiveCheck ? archiveCheck === archiveID : false;
|
|
161
162
|
const isValidExt = ext ? ext.toLowerCase() === fileExtensionCheck.toLowerCase() : false;
|
|
163
|
+
// First phase validation result
|
|
164
|
+
const isFirstPhaseValid = !!(isValidName && isValidArchive && isValidDid && isValidTid && isValidExt);
|
|
165
|
+
// Second phase: validate checkoutDate timestamp (only if first phase passed and checkoutDate is a valid string)
|
|
166
|
+
let checkoutDateValidation;
|
|
167
|
+
let isSecondPhaseValid = true;
|
|
168
|
+
if (isFirstPhaseValid && checkoutDate && typeof checkoutDate === "string") {
|
|
169
|
+
try {
|
|
170
|
+
// Convert checkoutDate to timestamp format YYYYMMDDHHmmss
|
|
171
|
+
const dt = new Date(checkoutDate);
|
|
172
|
+
// Check if date is valid
|
|
173
|
+
if (isNaN(dt.getTime())) {
|
|
174
|
+
// Skip second phase validation if date is invalid
|
|
175
|
+
console.warn("validateCicoFileName: invalid checkoutDate, skipping timestamp validation");
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
const pad = (n) => n.toString().padStart(2, '0');
|
|
179
|
+
const expectedTimestamp = `${dt.getFullYear()}${pad(dt.getMonth() + 1)}${pad(dt.getDate())}${pad(dt.getHours())}${pad(dt.getMinutes())}${pad(dt.getSeconds())}`;
|
|
180
|
+
isSecondPhaseValid = timestampCheck === expectedTimestamp;
|
|
181
|
+
// Format dates for display: readable date + (raw timestamp)
|
|
182
|
+
const expectedDisplayDate = Globalization.getDateTimeDisplayValue(dt);
|
|
183
|
+
// Parse timestampCheck to readable format (YYYYMMDDHHmmss -> Date)
|
|
184
|
+
let currentDisplayDate = timestampCheck;
|
|
185
|
+
if (timestampCheck && timestampCheck.length === 14) {
|
|
186
|
+
const year = parseInt(timestampCheck.substring(0, 4), 10);
|
|
187
|
+
const month = parseInt(timestampCheck.substring(4, 6), 10) - 1;
|
|
188
|
+
const day = parseInt(timestampCheck.substring(6, 8), 10);
|
|
189
|
+
const hours = parseInt(timestampCheck.substring(8, 10), 10);
|
|
190
|
+
const minutes = parseInt(timestampCheck.substring(10, 12), 10);
|
|
191
|
+
const seconds = parseInt(timestampCheck.substring(12, 14), 10);
|
|
192
|
+
const parsedDate = new Date(year, month, day, hours, minutes, seconds);
|
|
193
|
+
currentDisplayDate = Globalization.getDateTimeDisplayValue(parsedDate);
|
|
194
|
+
}
|
|
195
|
+
checkoutDateValidation = {
|
|
196
|
+
expected: `${expectedDisplayDate} (${expectedTimestamp})`,
|
|
197
|
+
current: `${currentDisplayDate} (${timestampCheck})`,
|
|
198
|
+
isValid: isSecondPhaseValid
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
// If anything goes wrong, skip second phase validation
|
|
204
|
+
console.warn("validateCicoFileName: error processing checkoutDate, skipping timestamp validation", error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
162
207
|
// Return validation results as an object
|
|
163
208
|
return {
|
|
164
|
-
isValid:
|
|
209
|
+
isValid: isFirstPhaseValid && isSecondPhaseValid,
|
|
165
210
|
validationResults: {
|
|
166
211
|
archiveID: {
|
|
167
212
|
expected: archiveID,
|
|
@@ -187,13 +232,155 @@ export const validateCicoFileName = (source, fileName) => {
|
|
|
187
232
|
expected: ext?.toLowerCase(),
|
|
188
233
|
current: fileExtensionCheck.toLowerCase(),
|
|
189
234
|
isValid: isValidExt
|
|
190
|
-
}
|
|
235
|
+
},
|
|
236
|
+
...(checkoutDateValidation && { checkoutDate: checkoutDateValidation })
|
|
191
237
|
}
|
|
192
238
|
};
|
|
193
239
|
};
|
|
240
|
+
/**
|
|
241
|
+
* Rimuove il timestamp di checkout e l'estensione dal nome file se presenti.
|
|
242
|
+
* Es: checkout~Z1~(CP) CICO A~10683~9894334~20260420090234.TXT -> checkout~Z1~(CP) CICO A~10683~9894334
|
|
243
|
+
* Non lancia mai errori, ritorna il nome originale in caso di problemi.
|
|
244
|
+
*/
|
|
245
|
+
const stripCheckoutTimestamp = (filename) => {
|
|
246
|
+
try {
|
|
247
|
+
if (!filename || typeof filename !== 'string')
|
|
248
|
+
return filename;
|
|
249
|
+
// Check if it's a checkout filename (starts with 'checkout~')
|
|
250
|
+
if (!filename.startsWith('checkout~'))
|
|
251
|
+
return filename;
|
|
252
|
+
// Remove extension if present
|
|
253
|
+
const lastDotIndex = filename.lastIndexOf('.');
|
|
254
|
+
const nameWithoutExt = lastDotIndex !== -1 ? filename.substring(0, lastDotIndex) : filename;
|
|
255
|
+
// Check if the last part is a 14-digit timestamp
|
|
256
|
+
const lastTildeIndex = nameWithoutExt.lastIndexOf('~');
|
|
257
|
+
if (lastTildeIndex === -1)
|
|
258
|
+
return nameWithoutExt;
|
|
259
|
+
const potentialTimestamp = nameWithoutExt.substring(lastTildeIndex + 1);
|
|
260
|
+
// Validate it's a 14-digit number (YYYYMMDDHHmmss)
|
|
261
|
+
if (potentialTimestamp.length === 14 && /^\d{14}$/.test(potentialTimestamp)) {
|
|
262
|
+
// Remove the timestamp part
|
|
263
|
+
return nameWithoutExt.substring(0, lastTildeIndex);
|
|
264
|
+
}
|
|
265
|
+
return nameWithoutExt;
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
// Never throw, return original
|
|
269
|
+
return filename;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
194
272
|
export const renderCicoCheckInContent = (source, selectedFilename, isValid, validationItems, color = "#996300") => {
|
|
195
273
|
const fileName = source.type === 'fileItem' ? source.fileItem.name : (source.dcmtInfo.fileName ?? SDKUI_Localizator.SearchResult);
|
|
196
|
-
|
|
274
|
+
const warningBgColor = "#fff8e6";
|
|
275
|
+
const warningBorderColor = "#f5c518";
|
|
276
|
+
return (_jsxs("div", { style: { width: "100%", padding: "8px 0", userSelect: 'text' }, children: [_jsx("div", { style: {
|
|
277
|
+
fontSize: '1rem',
|
|
278
|
+
marginBottom: isValid ? 0 : '16px',
|
|
279
|
+
lineHeight: 1.5
|
|
280
|
+
}, children: SDKUI_Localizator.CheckInElementConfirm.replaceParams(fileName) }), !isValid && (_jsxs("div", { style: {
|
|
281
|
+
background: warningBgColor,
|
|
282
|
+
border: `1px solid ${warningBorderColor}`,
|
|
283
|
+
borderRadius: '8px',
|
|
284
|
+
padding: '16px',
|
|
285
|
+
marginTop: '8px'
|
|
286
|
+
}, children: [_jsxs("div", { style: {
|
|
287
|
+
display: 'flex',
|
|
288
|
+
alignItems: 'center',
|
|
289
|
+
gap: '8px',
|
|
290
|
+
marginBottom: '16px'
|
|
291
|
+
}, children: [_jsx("i", { className: "dx-icon-warning", style: { fontSize: '20px', color } }), _jsx("span", { style: { fontSize: '1rem', fontWeight: 600, color }, children: SDKUI_Localizator.ElementNameConventionError })] }), _jsxs("div", { style: {
|
|
292
|
+
display: 'flex',
|
|
293
|
+
flexDirection: 'column',
|
|
294
|
+
gap: '12px',
|
|
295
|
+
background: '#fff',
|
|
296
|
+
borderRadius: '6px',
|
|
297
|
+
padding: '12px',
|
|
298
|
+
marginBottom: '16px'
|
|
299
|
+
}, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'flex-start', gap: '8px' }, children: [_jsxs("span", { style: {
|
|
300
|
+
minWidth: '80px',
|
|
301
|
+
fontWeight: 600,
|
|
302
|
+
color: '#555',
|
|
303
|
+
fontSize: '0.875rem'
|
|
304
|
+
}, children: [SDKUI_Localizator.Expected, ":"] }), _jsx("code", { style: {
|
|
305
|
+
fontFamily: 'monospace',
|
|
306
|
+
fontSize: '0.875rem',
|
|
307
|
+
background: '#e8f5e9',
|
|
308
|
+
padding: '2px 8px',
|
|
309
|
+
borderRadius: '4px',
|
|
310
|
+
color: '#2e7d32',
|
|
311
|
+
wordBreak: 'break-all'
|
|
312
|
+
}, children: getCicoDownloadFileName(source, true, false) })] }), _jsxs("div", { style: { display: 'flex', alignItems: 'flex-start', gap: '8px' }, children: [_jsxs("span", { style: {
|
|
313
|
+
minWidth: '80px',
|
|
314
|
+
fontWeight: 600,
|
|
315
|
+
color: '#555',
|
|
316
|
+
fontSize: '0.875rem'
|
|
317
|
+
}, children: [SDKUI_Localizator.SelectedSingular, ":"] }), _jsx("code", { style: {
|
|
318
|
+
fontFamily: 'monospace',
|
|
319
|
+
fontSize: '0.875rem',
|
|
320
|
+
background: '#ffebee',
|
|
321
|
+
padding: '2px 8px',
|
|
322
|
+
borderRadius: '4px',
|
|
323
|
+
color: '#c62828',
|
|
324
|
+
wordBreak: 'break-all'
|
|
325
|
+
}, children: stripCheckoutTimestamp(selectedFilename.name) })] })] }), validationItems && Object.entries(validationItems).filter(([_, value]) => !value.isValid).length > 0 && (_jsxs("div", { style: {
|
|
326
|
+
background: '#fff',
|
|
327
|
+
borderRadius: '6px',
|
|
328
|
+
padding: '12px',
|
|
329
|
+
marginBottom: '16px'
|
|
330
|
+
}, children: [_jsx("div", { style: {
|
|
331
|
+
fontWeight: 600,
|
|
332
|
+
marginBottom: '12px',
|
|
333
|
+
color: '#555',
|
|
334
|
+
fontSize: '0.875rem',
|
|
335
|
+
textTransform: 'uppercase',
|
|
336
|
+
letterSpacing: '0.5px'
|
|
337
|
+
}, children: SDKUI_Localizator.Anomalies }), _jsxs("table", { style: {
|
|
338
|
+
width: "100%",
|
|
339
|
+
borderCollapse: "separate",
|
|
340
|
+
borderSpacing: 0,
|
|
341
|
+
fontSize: '0.875rem'
|
|
342
|
+
}, children: [_jsx("thead", { children: _jsxs("tr", { style: { background: '#f5f5f5' }, children: [_jsx("th", { style: {
|
|
343
|
+
textAlign: "left",
|
|
344
|
+
padding: '10px 12px',
|
|
345
|
+
borderBottom: "2px solid #ddd",
|
|
346
|
+
fontWeight: 600,
|
|
347
|
+
color: '#333'
|
|
348
|
+
}, children: SDKUI_Localizator.Value }), _jsx("th", { style: {
|
|
349
|
+
textAlign: "left",
|
|
350
|
+
padding: '10px 12px',
|
|
351
|
+
borderBottom: "2px solid #ddd",
|
|
352
|
+
fontWeight: 600,
|
|
353
|
+
color: '#2e7d32'
|
|
354
|
+
}, children: SDKUI_Localizator.Expected }), _jsx("th", { style: {
|
|
355
|
+
textAlign: "left",
|
|
356
|
+
padding: '10px 12px',
|
|
357
|
+
borderBottom: "2px solid #ddd",
|
|
358
|
+
fontWeight: 600,
|
|
359
|
+
color: '#c62828'
|
|
360
|
+
}, children: SDKUI_Localizator.Current })] }) }), _jsx("tbody", { children: Object.entries(validationItems)
|
|
361
|
+
.filter(([_, value]) => !value.isValid)
|
|
362
|
+
.map(([key, result], index, arr) => (_jsxs("tr", { style: {
|
|
363
|
+
background: index % 2 === 0 ? '#fafafa' : '#fff'
|
|
364
|
+
}, children: [_jsx("td", { style: {
|
|
365
|
+
padding: '10px 12px',
|
|
366
|
+
borderBottom: index === arr.length - 1 ? 'none' : "1px solid #eee",
|
|
367
|
+
fontWeight: 500,
|
|
368
|
+
textTransform: "capitalize"
|
|
369
|
+
}, children: key.toUpperCase() }), _jsx("td", { style: {
|
|
370
|
+
padding: '10px 12px',
|
|
371
|
+
borderBottom: index === arr.length - 1 ? 'none' : "1px solid #eee",
|
|
372
|
+
color: '#2e7d32',
|
|
373
|
+
fontFamily: 'monospace'
|
|
374
|
+
}, children: result.expected || "-" }), _jsx("td", { style: {
|
|
375
|
+
padding: '10px 12px',
|
|
376
|
+
borderBottom: index === arr.length - 1 ? 'none' : "1px solid #eee",
|
|
377
|
+
color: '#c62828',
|
|
378
|
+
fontFamily: 'monospace'
|
|
379
|
+
}, children: result.current || "-" })] }, key))) })] })] }))] })), !isValid && (_jsx("div", { style: {
|
|
380
|
+
fontSize: '1rem',
|
|
381
|
+
lineHeight: 1.5,
|
|
382
|
+
marginTop: '16px'
|
|
383
|
+
}, children: SDKUI_Localizator.ProceedAnyway }))] }));
|
|
197
384
|
};
|
|
198
385
|
export const getDcmtCicoInfo = (dtd) => {
|
|
199
386
|
const cico = {
|
|
@@ -245,7 +432,7 @@ export const getDcmtCicoStatus = (dcmt, allUsers, dtd) => {
|
|
|
245
432
|
if (dcmt === undefined || dtd === undefined) {
|
|
246
433
|
return {
|
|
247
434
|
cicoEnabled: false,
|
|
248
|
-
checkoutStatus: { isCheckedOut: false, mode: '', version: 1, icon: null, editLockTooltipText: null }
|
|
435
|
+
checkoutStatus: { isCheckedOut: false, mode: '', version: 1, icon: null, editLockTooltipText: null, checkoutUserId: undefined, checkoutDate: undefined, fileExt: null, isMetadata: false }
|
|
249
436
|
};
|
|
250
437
|
}
|
|
251
438
|
// ========================================================================
|
|
@@ -320,7 +507,7 @@ export const getDcmtCicoStatus = (dcmt, allUsers, dtd) => {
|
|
|
320
507
|
if (isMetadata) {
|
|
321
508
|
return {
|
|
322
509
|
cicoEnabled: false,
|
|
323
|
-
checkoutStatus: { isCheckedOut: false, mode: '', version: 1, icon: null, editLockTooltipText: null }
|
|
510
|
+
checkoutStatus: { isCheckedOut: false, mode: '', version: 1, icon: null, editLockTooltipText: null, checkoutUserId: undefined, checkoutDate: undefined, fileExt: fileExt, isMetadata: true }
|
|
324
511
|
};
|
|
325
512
|
}
|
|
326
513
|
// ========================================================================
|
|
@@ -331,7 +518,11 @@ export const getDcmtCicoStatus = (dcmt, allUsers, dtd) => {
|
|
|
331
518
|
mode: '',
|
|
332
519
|
version: version,
|
|
333
520
|
icon: null,
|
|
334
|
-
editLockTooltipText: null
|
|
521
|
+
editLockTooltipText: null,
|
|
522
|
+
checkoutUserId: checkoutUserId,
|
|
523
|
+
checkoutDate: checkoutDate,
|
|
524
|
+
fileExt: fileExt,
|
|
525
|
+
isMetadata: isMetadata
|
|
335
526
|
};
|
|
336
527
|
// Verifica se il documento è effettivamente in stato di checkout
|
|
337
528
|
if (userID && checkoutUserId && !isNaN(checkoutUserId) && checkoutUserId > 0) {
|
|
@@ -352,7 +543,11 @@ export const getDcmtCicoStatus = (dcmt, allUsers, dtd) => {
|
|
|
352
543
|
mode: mode,
|
|
353
544
|
icon: icon,
|
|
354
545
|
version: version,
|
|
355
|
-
editLockTooltipText: editLockTooltipText
|
|
546
|
+
editLockTooltipText: editLockTooltipText,
|
|
547
|
+
checkoutUserId: checkoutUserId,
|
|
548
|
+
checkoutDate: checkoutDate,
|
|
549
|
+
fileExt: fileExt,
|
|
550
|
+
isMetadata: isMetadata
|
|
356
551
|
};
|
|
357
552
|
}
|
|
358
553
|
// ========================================================================
|
|
@@ -18,7 +18,7 @@ export interface UseCheckInOutOperationsReturn {
|
|
|
18
18
|
hideCommentFormCallback: () => void;
|
|
19
19
|
copyCheckoutPathToClipboardCallback: (dcmt: DcmtInfo, filename: string) => void;
|
|
20
20
|
handleCheckOutCallback: (dcmt: DcmtInfo, checkout: boolean, filename: string, downloadDcmtsAsync: (inputDcmts: Array<DcmtInfo> | undefined, downloadType?: DownloadTypes, downloadMode?: DownloadModes, onFileDownloaded?: (dcmtFile: File) => void, confirmAttachments?: (list: FileDescriptor[]) => Promise<string[] | undefined>, skipConfirmation?: boolean) => Promise<void>, onRefreshAsync?: (tid: number | undefined, did: number | undefined, refreshUI?: boolean, metadataResult?: SearchResultDescriptor | null) => Promise<void>) => Promise<void>;
|
|
21
|
-
handleCheckInCallback: (dcmt: DcmtInfo, onRefreshAsync?: (tid: number | undefined, did: number | undefined, refreshUI?: boolean, metadataResult?: SearchResultDescriptor | null) => Promise<void>) => Promise<void>;
|
|
21
|
+
handleCheckInCallback: (dcmt: DcmtInfo, checkoutDate?: string | null, onRefreshAsync?: (tid: number | undefined, did: number | undefined, refreshUI?: boolean, metadataResult?: SearchResultDescriptor | null) => Promise<void>) => Promise<void>;
|
|
22
22
|
showCicoWaitPanel: boolean;
|
|
23
23
|
cicoWaitPanelTitle: string;
|
|
24
24
|
showCicoPrimaryProgress: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useCallback, useState } from 'react';
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
2
2
|
import { cicoDownloadFilesCallback, dcmtsFileCachePreview, getCicoDownloadFileName, getExceptionMessage, removeDcmtsFileCache, renderCicoCheckInContent, SDKUI_Globals, SDKUI_Localizator, updateCicoCheckoutStorageItem, validateCicoFileName } from '../helper';
|
|
3
|
-
import { ButtonNames, ShowAlert, TMMessageBoxManager, TMResultManager } from '../components';
|
|
3
|
+
import { ButtonNames, DeviceType, ShowAlert, TMMessageBoxManager, TMResultManager, useDeviceType } from '../components';
|
|
4
4
|
import { ResultTypes, SDK_Globals } from '@topconsultnpm/sdk-ts';
|
|
5
5
|
let abortController = new AbortController();
|
|
6
6
|
export const useCheckInOutOperations = (props) => {
|
|
@@ -14,6 +14,10 @@ export const useCheckInOutOperations = (props) => {
|
|
|
14
14
|
show: false,
|
|
15
15
|
isRequired: false
|
|
16
16
|
});
|
|
17
|
+
// Get the current device type (e.g., mobile, tablet, desktop) using a custom hook.
|
|
18
|
+
const deviceType = useDeviceType();
|
|
19
|
+
// This avoids unnecessary re-renders by only recalculating when deviceType changes.
|
|
20
|
+
let isMobile = useMemo(() => { return deviceType === DeviceType.MOBILE; }, [deviceType]);
|
|
17
21
|
// State variable to control the visibility of the wait panel
|
|
18
22
|
const [showCicoWaitPanel, setShowCicoWaitPanel] = useState(false);
|
|
19
23
|
// State variable to store the title of the wait panel
|
|
@@ -127,7 +131,7 @@ export const useCheckInOutOperations = (props) => {
|
|
|
127
131
|
});
|
|
128
132
|
}
|
|
129
133
|
};
|
|
130
|
-
const handleCheckInCallback = async (dcmt, onRefreshAsync) => {
|
|
134
|
+
const handleCheckInCallback = async (dcmt, checkoutDate, onRefreshAsync) => {
|
|
131
135
|
if (!dcmt)
|
|
132
136
|
throw new Error("Document info is required");
|
|
133
137
|
// Create a new file input element
|
|
@@ -144,12 +148,13 @@ export const useCheckInOutOperations = (props) => {
|
|
|
144
148
|
if (!fileInput.files || fileInput.files.length === 0)
|
|
145
149
|
return;
|
|
146
150
|
const file = fileInput.files[0];
|
|
147
|
-
const validateFileName = validateCicoFileName({ type: 'dcmtInfo', dcmtInfo: dcmt, originalFileName: dcmt.fileName ?? SDKUI_Localizator.SearchResult }, file.name);
|
|
151
|
+
const validateFileName = validateCicoFileName({ type: 'dcmtInfo', dcmtInfo: dcmt, originalFileName: dcmt.fileName ?? SDKUI_Localizator.SearchResult }, file.name, checkoutDate);
|
|
148
152
|
TMMessageBoxManager.show({
|
|
149
153
|
resizable: true,
|
|
150
154
|
buttons: [ButtonNames.YES, ButtonNames.NO],
|
|
151
155
|
message: renderCicoCheckInContent({ type: 'dcmtInfo', dcmtInfo: dcmt, originalFileName: dcmt.fileName ?? SDKUI_Localizator.SearchResult }, file, validateFileName.isValid, validateFileName.validationResults),
|
|
152
156
|
title: "Check in",
|
|
157
|
+
initialWidth: !validateFileName.isValid && !isMobile ? '800px' : undefined,
|
|
153
158
|
onButtonClick: async (e) => {
|
|
154
159
|
if (e !== ButtonNames.YES)
|
|
155
160
|
return;
|
|
@@ -617,12 +617,18 @@ export const useDocumentOperations = (props) => {
|
|
|
617
617
|
const firstDoc = selectedDcmtInfos?.[0];
|
|
618
618
|
if (!firstDoc)
|
|
619
619
|
return;
|
|
620
|
+
// Take the first document (used for validation checks)
|
|
621
|
+
let dcmt = focusedItem;
|
|
622
|
+
if (isDcmtFormContext || isMasterDetailContext) {
|
|
623
|
+
dcmt = dcmtDataRowForCicoStatus;
|
|
624
|
+
}
|
|
625
|
+
const { checkoutStatus } = getDcmtCicoStatus(dcmt, allUsers, dtd);
|
|
620
626
|
firstDoc.fileName = dtd?.name ?? SDKUI_Localizator.SearchResult;
|
|
621
627
|
const onRefreshAsync = async () => {
|
|
622
628
|
await updateCurrentDcmt?.();
|
|
623
629
|
await refreshFocusedDataRowAsync?.(firstDoc.TID, firstDoc.DID, true);
|
|
624
630
|
};
|
|
625
|
-
await handleCheckInCallback(firstDoc, onRefreshAsync);
|
|
631
|
+
await handleCheckInCallback(firstDoc, checkoutStatus.checkoutDate, onRefreshAsync);
|
|
626
632
|
};
|
|
627
633
|
const copyCheckoutPathToClipboardOperationCallback = () => {
|
|
628
634
|
const firstDoc = selectedDcmtInfos?.[0];
|