@topconsultnpm/sdkui-react 6.20.0-dev1.6 → 6.20.0-dev1.9
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/features/documents/TMDcmtPreview.js +93 -58
- package/lib/components/features/search/TMSearchResult.js +3 -3
- package/lib/components/features/search/TMSearchResultCheckoutInfoForm.js +3 -8
- package/lib/helper/checkinCheckoutManager.d.ts +1 -1
- package/lib/helper/checkinCheckoutManager.js +3 -8
- package/package.json +1 -1
|
@@ -136,32 +136,32 @@ export const TMFileViewer = ({ fileBlob, isResizingActive }) => {
|
|
|
136
136
|
const [blobUrl, setBlobUrl] = useState(undefined);
|
|
137
137
|
const [fileType, setFileType] = useState(undefined);
|
|
138
138
|
const [formattedXml, setFormattedXml] = useState(undefined);
|
|
139
|
-
const [isMobile, setIsMobile] = useState(false);
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}, []);
|
|
139
|
+
// const [isMobile, setIsMobile] = useState<boolean>(false);
|
|
140
|
+
// useEffect(() => {
|
|
141
|
+
// const checkIsMobile = () => {
|
|
142
|
+
// const userAgent = navigator.userAgent || navigator.vendor || (window as any).opera;
|
|
143
|
+
// // Only detect actual mobile/tablet devices, NOT desktop browsers
|
|
144
|
+
// const isMobileDevice =
|
|
145
|
+
// // Traditional mobile detection (phones and tablets)
|
|
146
|
+
// /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent) ||
|
|
147
|
+
// // Additional Android tablet detection (covers tablets in landscape)
|
|
148
|
+
// /android.*tablet|android.*mobile/i.test(userAgent) ||
|
|
149
|
+
// // Touch-only devices (excludes laptops with touchscreen)
|
|
150
|
+
// (('ontouchstart' in window || navigator.maxTouchPoints > 0) &&
|
|
151
|
+
// !/Windows NT|Macintosh|Linux/.test(userAgent)) ||
|
|
152
|
+
// // Small screen mobile devices only
|
|
153
|
+
// (window.screen.width <= 768 && /Mobi|Android/i.test(userAgent));
|
|
154
|
+
// setIsMobile(isMobileDevice);
|
|
155
|
+
// };
|
|
156
|
+
// checkIsMobile();
|
|
157
|
+
// // Listen for orientation changes (important for tablets)
|
|
158
|
+
// window.addEventListener('orientationchange', checkIsMobile);
|
|
159
|
+
// window.addEventListener('resize', checkIsMobile);
|
|
160
|
+
// return () => {
|
|
161
|
+
// window.removeEventListener('orientationchange', checkIsMobile);
|
|
162
|
+
// window.removeEventListener('resize', checkIsMobile);
|
|
163
|
+
// };
|
|
164
|
+
// }, []);
|
|
165
165
|
useEffect(() => {
|
|
166
166
|
if (fileBlob) {
|
|
167
167
|
setFileType(fileBlob.type);
|
|
@@ -222,38 +222,73 @@ export const TMFileViewer = ({ fileBlob, isResizingActive }) => {
|
|
|
222
222
|
if (fileBlob.type.includes('image')) {
|
|
223
223
|
return (_jsx(ImageViewer, { fileBlob: fileBlob, alt: '' }));
|
|
224
224
|
}
|
|
225
|
-
if (fileType === 'application/pdf' && isMobile) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
225
|
+
// if (fileType === 'application/pdf' && isMobile) {
|
|
226
|
+
// return (
|
|
227
|
+
// <object
|
|
228
|
+
// key={blobUrl}
|
|
229
|
+
// data={blobUrl}
|
|
230
|
+
// type="application/pdf"
|
|
231
|
+
// width="100%"
|
|
232
|
+
// height="100%"
|
|
233
|
+
// style={{
|
|
234
|
+
// border: 'none',
|
|
235
|
+
// zIndex: 0,
|
|
236
|
+
// pointerEvents: isResizingActive === true ? "none" : "auto"
|
|
237
|
+
// }}
|
|
238
|
+
// >
|
|
239
|
+
// {/* Fallback UI if <object> tag fails to render PDF */}
|
|
240
|
+
// <div style={{
|
|
241
|
+
// padding: '40px',
|
|
242
|
+
// textAlign: 'center',
|
|
243
|
+
// display: 'flex',
|
|
244
|
+
// flexDirection: 'column',
|
|
245
|
+
// alignItems: 'center',
|
|
246
|
+
// justifyContent: 'center',
|
|
247
|
+
// height: '100%',
|
|
248
|
+
// gap: '20px'
|
|
249
|
+
// }}>
|
|
250
|
+
// <IconPreview fontSize={96} />
|
|
251
|
+
// <div>
|
|
252
|
+
// <h3>{SDKUI_Localizator.PDFDocument}</h3>
|
|
253
|
+
// <p>{SDKUI_Localizator.PreviewNotAvailableOnDevice}</p>
|
|
254
|
+
// </div>
|
|
255
|
+
// <div style={{ display: 'flex', gap: '10px', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'center' }}>
|
|
256
|
+
// <a
|
|
257
|
+
// href={blobUrl}
|
|
258
|
+
// download="document.pdf"
|
|
259
|
+
// style={{
|
|
260
|
+
// minWidth: '180px',
|
|
261
|
+
// padding: '12px 24px',
|
|
262
|
+
// backgroundColor: TMColors.primaryColor,
|
|
263
|
+
// color: 'white',
|
|
264
|
+
// textDecoration: 'none',
|
|
265
|
+
// borderRadius: '4px',
|
|
266
|
+
// display: 'inline-block'
|
|
267
|
+
// }}
|
|
268
|
+
// >
|
|
269
|
+
// {SDKUI_Localizator.DownloadFile}
|
|
270
|
+
// </a>
|
|
271
|
+
// <a
|
|
272
|
+
// href={blobUrl}
|
|
273
|
+
// target="_blank"
|
|
274
|
+
// rel="noopener noreferrer"
|
|
275
|
+
// style={{
|
|
276
|
+
// minWidth: '180px',
|
|
277
|
+
// padding: '12px 24px',
|
|
278
|
+
// backgroundColor: TMColors.primaryColor,
|
|
279
|
+
// color: 'white',
|
|
280
|
+
// textDecoration: 'none',
|
|
281
|
+
// borderRadius: '4px',
|
|
282
|
+
// display: 'inline-block'
|
|
283
|
+
// }}
|
|
284
|
+
// >
|
|
285
|
+
// {SDKUI_Localizator.OpenInNewTab}
|
|
286
|
+
// </a>
|
|
287
|
+
// </div>
|
|
288
|
+
// </div>
|
|
289
|
+
// </object>
|
|
290
|
+
// );
|
|
291
|
+
// }
|
|
257
292
|
return (_jsx("iframe", { srcDoc: formattedXml ? `<html><body>${formattedXml}</body></html>` : undefined, src: !formattedXml
|
|
258
293
|
? (fileType === 'application/pdf' ? `${blobUrl}#view=FitH&scrollbar=1` : blobUrl)
|
|
259
294
|
: undefined, title: "File Viewer", width: "100%", height: "100%", style: { border: 'none', zIndex: 0, pointerEvents: isResizingActive === true ? "none" : "auto" } }, blobUrl));
|
|
@@ -43,7 +43,7 @@ import { TMResultManager } from '../../forms/TMResultDialog';
|
|
|
43
43
|
import TMCustomButton from '../../base/TMCustomButton';
|
|
44
44
|
import ToppyDraggableHelpCenter from '../assistant/ToppyDraggableHelpCenter';
|
|
45
45
|
import TMSignSettingsForm from './TMSignSettingsForm';
|
|
46
|
-
import { getDcmtCicoStatus, cicoDownloadFilesCallback, getCicoDownloadFileName, renderCicoCheckInContent, validateCicoFileName,
|
|
46
|
+
import { getDcmtCicoStatus, cicoDownloadFilesCallback, getCicoDownloadFileName, renderCicoCheckInContent, validateCicoFileName, updateCicoCheckoutStorageItem } from '../../../helper/checkinCheckoutManager';
|
|
47
47
|
import TMSearchResultCheckoutInfoForm from './TMSearchResultCheckoutInfoForm';
|
|
48
48
|
import TMViewHistoryDcmt from './TMViewHistoryDcmt';
|
|
49
49
|
import TMBlogCommentForm from '../blog/TMBlogCommentForm';
|
|
@@ -468,7 +468,7 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
468
468
|
.then(async () => {
|
|
469
469
|
result.push({ rowIndex: i, id1: firstDoc.TID, id2: firstDoc.DID, description: SDKUI_Localizator.UpdateCompletedSuccessfully, resultType: ResultTypes.SUCCESS });
|
|
470
470
|
// Remove the corresponding draft checkout item
|
|
471
|
-
|
|
471
|
+
updateCicoCheckoutStorageItem({ TID: firstDoc.TID.toString(), DID: firstDoc.DID.toString(), checkoutFolder: "", checkoutName: "" }, "dcmtInfo", "remove");
|
|
472
472
|
await refreshFocusedDataRowAsync(firstDoc.TID, firstDoc.DID, true);
|
|
473
473
|
})
|
|
474
474
|
.catch((error) => {
|
|
@@ -541,7 +541,7 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
541
541
|
ue.DID = firstDoc.DID;
|
|
542
542
|
await ue.CheckInAsync(file, "", abortControllerLocal.signal);
|
|
543
543
|
// Remove the corresponding draft checkout item
|
|
544
|
-
|
|
544
|
+
updateCicoCheckoutStorageItem({ TID: firstDoc.TID.toString(), DID: firstDoc.DID.toString(), checkoutFolder: "", checkoutName: "" }, "dcmtInfo", "remove");
|
|
545
545
|
result.push({ rowIndex: i, id1: firstDoc.DID, id2: firstDoc.DID, description: SDKUI_Localizator.UpdateCompletedSuccessfully, resultType: ResultTypes.SUCCESS });
|
|
546
546
|
await refreshFocusedDataRowAsync(firstDoc.TID, firstDoc.DID, true);
|
|
547
547
|
const cacheKey = `${firstDoc.TID}-${firstDoc.DID}`;
|
|
@@ -5,7 +5,7 @@ import { IconBxInfo, IconFileDots, IconFolder, SDKUI_Globals, SDKUI_Localizator
|
|
|
5
5
|
import { FormModes } from "../../../ts";
|
|
6
6
|
import { ResultTypes, ValidationItem } from "@topconsultnpm/sdk-ts";
|
|
7
7
|
import { SaveFormOptions, useSaveForm } from "../../../hooks/useForm";
|
|
8
|
-
import { getCicoDownloadFileName,
|
|
8
|
+
import { getCicoDownloadFileName, updateCicoCheckoutStorageItem } from "../../../helper/checkinCheckoutManager";
|
|
9
9
|
import { TMColors } from "../../../utils/theme";
|
|
10
10
|
import TMLayoutContainer, { TMLayoutItem } from "../../base/TMLayout";
|
|
11
11
|
import TMTooltip from "../../base/TMTooltip";
|
|
@@ -57,13 +57,8 @@ const TMSearchResultCheckoutInfoForm = (props) => {
|
|
|
57
57
|
// Check: formData must exist, selectedDcmtOrFocused.TID and selectedDcmtOrFocused.DID must exist, and at least one of checkoutFolder or checkoutName must be filled
|
|
58
58
|
if (formData && selectedDcmtOrFocused.TID && selectedDcmtOrFocused.DID) {
|
|
59
59
|
// Create a new draft checkout item with TID, DID, and folder/name values
|
|
60
|
-
const newItem = {
|
|
61
|
-
|
|
62
|
-
DID: selectedDcmtOrFocused.DID.toString(),
|
|
63
|
-
checkoutFolder: formData.checkoutFolder ?? "",
|
|
64
|
-
checkoutName: formData.checkoutName ?? ""
|
|
65
|
-
};
|
|
66
|
-
updateCheckoutItem(newItem, "dcmtInfo", "addOrUpdate");
|
|
60
|
+
const newItem = { TID: selectedDcmtOrFocused.TID.toString(), DID: selectedDcmtOrFocused.DID.toString(), checkoutFolder: formData.checkoutFolder ?? "", checkoutName: formData.checkoutName ?? "" };
|
|
61
|
+
updateCicoCheckoutStorageItem(newItem, "dcmtInfo", "addOrUpdate");
|
|
67
62
|
onClose();
|
|
68
63
|
ShowAlert({ mode: 'success', title: SDKUI_Localizator.CheckoutInfo, message: SDKUI_Localizator.OperationSuccess, duration: 3000 });
|
|
69
64
|
}
|
|
@@ -29,7 +29,7 @@ export type DownloadSource = {
|
|
|
29
29
|
};
|
|
30
30
|
export declare const getCicoDownloadFileName: (source: DownloadSource, checkout: boolean, withTimestampAndExt: boolean) => string;
|
|
31
31
|
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>;
|
|
32
|
-
export declare const
|
|
32
|
+
export declare const updateCicoCheckoutStorageItem: (item: CheckoutInfo, type: "fileItem" | "dcmtInfo", action?: "addOrUpdate" | "remove") => void;
|
|
33
33
|
export declare const validateCicoFileName: (source: DownloadSource, fileName: string) => FileNameValidation;
|
|
34
34
|
type ValidationResult = {
|
|
35
35
|
expected: string | number | undefined;
|
|
@@ -64,13 +64,8 @@ export const cicoDownloadFilesCallback = async (sources, checkout, downloadDcmts
|
|
|
64
64
|
if (tid && did && ext) {
|
|
65
65
|
let fileName = getCicoDownloadFileName(source, checkout, true);
|
|
66
66
|
if (checkout) {
|
|
67
|
-
const newItem = {
|
|
68
|
-
|
|
69
|
-
DID: did.toString(),
|
|
70
|
-
checkoutFolder: "",
|
|
71
|
-
checkoutName: fileName
|
|
72
|
-
};
|
|
73
|
-
updateCheckoutItem(newItem, source.type, "addOrUpdate");
|
|
67
|
+
const newItem = { TID: tid.toString(), DID: did.toString(), checkoutFolder: "", checkoutName: fileName };
|
|
68
|
+
updateCicoCheckoutStorageItem(newItem, source.type, "addOrUpdate");
|
|
74
69
|
}
|
|
75
70
|
files.push({ TID: tid, DID: did, FILEEXT: ext, fileName });
|
|
76
71
|
}
|
|
@@ -78,7 +73,7 @@ export const cicoDownloadFilesCallback = async (sources, checkout, downloadDcmts
|
|
|
78
73
|
if (files.length > 0)
|
|
79
74
|
await downloadDcmtsAsync(files, DownloadTypes.Dcmt, "download");
|
|
80
75
|
};
|
|
81
|
-
export const
|
|
76
|
+
export const updateCicoCheckoutStorageItem = (item, type, action = "addOrUpdate") => {
|
|
82
77
|
// Select the appropriate array based on type
|
|
83
78
|
const currentItems = type === 'dcmtInfo' ? [...SDKUI_Globals.userSettings.dcmtCheckoutInfo] : [...SDKUI_Globals.userSettings.wgDraftCheckoutInfo];
|
|
84
79
|
// Find the index of an existing item that has the same TID and DID as the new item
|