@topconsultnpm/sdkui-react 6.19.0-dev2.39 → 6.19.0-dev2.40
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.
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { SDK_Globals } from '@topconsultnpm/sdk-ts';
|
|
3
2
|
import { useEffect, useRef, useState, useMemo } from 'react';
|
|
4
3
|
import TMModal from './TMModal';
|
|
5
4
|
import styled from 'styled-components';
|
|
@@ -93,10 +92,7 @@ const TMCustomButton = (props) => {
|
|
|
93
92
|
}
|
|
94
93
|
else if (iframeRef.current?.contentWindow) {
|
|
95
94
|
// Modalità RunOnce: invia dati all'iframe quando è caricato
|
|
96
|
-
iframeRef.current.contentWindow.postMessage({
|
|
97
|
-
"options": attributes,
|
|
98
|
-
"session": SDK_Globals.tmSession
|
|
99
|
-
}, targetOrigin);
|
|
95
|
+
iframeRef.current.contentWindow.postMessage({ "options": attributes }, targetOrigin);
|
|
100
96
|
//clearTimeout(timeoutIframe);
|
|
101
97
|
}
|
|
102
98
|
}, [loading, error, RunOnce]);
|
|
@@ -6,6 +6,7 @@ interface TMBlogCommentFormProps {
|
|
|
6
6
|
participants: Array<UserDescriptor>;
|
|
7
7
|
onClose: () => void;
|
|
8
8
|
showAttachmentsSection?: boolean;
|
|
9
|
+
removeAndEditAttachment?: boolean;
|
|
9
10
|
selectedAttachments?: Array<FileItem>;
|
|
10
11
|
selectedAttachmentDid?: Array<number>;
|
|
11
12
|
title?: string;
|
|
@@ -29,7 +29,7 @@ const getNonDirectoryFiles = (items, exclude) => {
|
|
|
29
29
|
};
|
|
30
30
|
const TMBlogCommentForm = (props) => {
|
|
31
31
|
const maxLength = 1000;
|
|
32
|
-
const { title = SDKUI_Localizator.AddNewComment, participants, selectedAttachments, selectedAttachmentDid, allFileItems, allArchivedDocumentsFileItems = [], onClose, context, showAttachmentsSection = true, onSavedCallback, onFilterCreated, refreshCallback } = props;
|
|
32
|
+
const { title = SDKUI_Localizator.AddNewComment, participants, selectedAttachments, selectedAttachmentDid, allFileItems, allArchivedDocumentsFileItems = [], onClose, context, showAttachmentsSection = true, removeAndEditAttachment = true, onSavedCallback, onFilterCreated, refreshCallback } = props;
|
|
33
33
|
// Initialize state with combined array
|
|
34
34
|
const [dataSource, setDataSource] = useState(() => [...getNonDirectoryFiles(allFileItems?.items || [], []), ...allArchivedDocumentsFileItems]);
|
|
35
35
|
const [isEditorEnabled, setIsEditorEnabled] = useState(true);
|
|
@@ -220,7 +220,7 @@ const TMBlogCommentForm = (props) => {
|
|
|
220
220
|
setCurrentDraftAttachments(selectedDraftItems);
|
|
221
221
|
};
|
|
222
222
|
return _jsx(TMSaveForm, { id: 1, title: title, showTitleFormMode: false, showErrorCount: false, customSaveButton: _jsx("i", { className: 'dx-icon-send' }), customTooltipSaveButton: SDKUI_Localizator.Send, showUndoButton: false, hasNavigation: false, skipIsModifiedCheck: true, isModal: true, width: calcResponsiveSizes(deviceType, '800px', '800px', '95%'), height: '550px', formMode: FormModes.Create, validationItems: validationItems, exception: exception, isModified: calcIsModified(formData, formDataOrig), onSaveAsync: onSaveAsync, onClose: onCloseCallback, customToolbarElements: _jsx("div", { style: { display: 'flex', gap: '2px' }, children: _jsx(TMButton, { btnStyle: "toolbar", icon: isEditorEnabled ? _jsx("i", { className: 'dx-icon-font' }) : _jsx("i", { className: 'dx-icon-background' }), caption: isEditorEnabled ? SDKUI_Localizator.HideFormattingOptions : SDKUI_Localizator.ShowFormattingOptions, onClick: toggleEditorMode }) }), children: _jsxs("div", { style: { width: "100%", height: "100%" }, children: [_jsxs("div", { style: { width: "100%", height: "100%" }, children: [_jsx("div", { style: { width: "100%", height: showAttachmentsSection ? "calc(100% - 60px)" : "100%" }, children: _jsx(TMHtmlEditor, { width: '100%', height: '100%', isEditorEnabled: isEditorEnabled, validationItems: validationItems, onValueChanged: onValueChanged, mentionsConfig: mentionsConfig, autoFocus: true, maxLength: maxLength }) }), showAttachmentsSection && _jsxs("div", { style: { display: 'flex', alignItems: 'center', height: '60px', marginTop: '10px' }, children: [_jsx("div", { style: {
|
|
223
|
-
width:
|
|
223
|
+
width: `calc(100% - ${removeAndEditAttachment ? 60 : 0}px)`,
|
|
224
224
|
overflowX: 'auto',
|
|
225
225
|
whiteSpace: 'nowrap',
|
|
226
226
|
height: '50px',
|
|
@@ -234,7 +234,7 @@ const TMBlogCommentForm = (props) => {
|
|
|
234
234
|
const tooltipContent = (_jsxs("div", { style: { textAlign: 'left' }, children: [_jsxs("div", { children: [_jsxs("span", { style: { fontWeight: 'bold' }, children: [SDKUI_Localizator.Name, ":"] }), " ", draft.name ?? '-'] }), _jsxs("div", { children: [_jsxs("span", { style: { fontWeight: 'bold' }, children: [SDKUI_Localizator.Author, ":"] }), " ", draft.updaterName ?? '-'] }), _jsx("hr", {}), _jsxs("div", { children: [_jsxs("span", { style: { fontWeight: 'bold' }, children: [SDKUI_Localizator.Version, ":"] }), " ", draft.version] }), _jsxs("div", { children: [_jsxs("span", { style: { fontWeight: 'bold' }, children: [SDKUI_Localizator.Size, ":"] }), " ", formatBytes(draft.size ?? 0)] }), _jsx("hr", {}), _jsxs("div", { children: [_jsxs("span", { style: { fontWeight: 'bold' }, children: [SDKUI_Localizator.CreationTime, ":"] }), " ", Globalization.getDateTimeDisplayValue(draft.creationTime)] }), _jsxs("div", { children: [_jsxs("span", { style: { fontWeight: 'bold' }, children: [SDKUI_Localizator.LastUpdateTime, ":"] }), " ", Globalization.getDateTimeDisplayValue(draft.lastUpdateTime)] })] }));
|
|
235
235
|
return _jsxs("div", { style: {
|
|
236
236
|
display: 'inline-flex',
|
|
237
|
-
alignItems: 'center',
|
|
237
|
+
alignItems: 'center',
|
|
238
238
|
padding: '4px 8px',
|
|
239
239
|
margin: '4px',
|
|
240
240
|
border: '1px solid #ddd',
|
|
@@ -261,7 +261,7 @@ const TMBlogCommentForm = (props) => {
|
|
|
261
261
|
fontWeight: 'bold',
|
|
262
262
|
marginRight: '8px',
|
|
263
263
|
boxShadow: '1px 1px 2px #00000020',
|
|
264
|
-
}, children: _jsx(TMTooltip, { content: SDKUI_Localizator.Version, children: draft.version }) })), _jsx(TMTooltip, { content: SDKUI_Localizator.RemoveAttachment, children: _jsx("span", { onClick: () => removeAttachment(draft), style: {
|
|
264
|
+
}, children: _jsx(TMTooltip, { content: SDKUI_Localizator.Version, children: draft.version }) })), removeAndEditAttachment && _jsx(TMTooltip, { content: SDKUI_Localizator.RemoveAttachment, children: _jsx("span", { onClick: () => removeAttachment(draft), style: {
|
|
265
265
|
display: 'inline-flex',
|
|
266
266
|
width: '20px',
|
|
267
267
|
height: '20px',
|
|
@@ -273,7 +273,7 @@ const TMBlogCommentForm = (props) => {
|
|
|
273
273
|
cursor: 'pointer',
|
|
274
274
|
boxShadow: '1px 1px 2px #00000020',
|
|
275
275
|
}, children: _jsx("span", { style: { fontSize: '15px' }, children: "\u00D7" }) }) })] }, draft.did);
|
|
276
|
-
})) : (_jsx("div", { style: { color: '#999', width: '100%', textAlign: 'center' }, children: SDKUI_Localizator.NoAttachments })) }), _jsx(TMTooltip, { content: SDKUI_Localizator.Attachments + ": " + currentDraftAttachments.length, children: _jsxs("div", { style: { position: 'relative', display: 'inline-block' }, children: [_jsx("i", { className: "dx-icon-attach", style: {
|
|
276
|
+
})) : (_jsx("div", { style: { color: '#999', width: '100%', textAlign: 'center' }, children: SDKUI_Localizator.NoAttachments })) }), removeAndEditAttachment && _jsx(TMTooltip, { content: SDKUI_Localizator.Attachments + ": " + currentDraftAttachments.length, children: _jsxs("div", { style: { position: 'relative', display: 'inline-block' }, children: [_jsx("i", { className: "dx-icon-attach", style: {
|
|
277
277
|
width: '50px',
|
|
278
278
|
height: '50px',
|
|
279
279
|
marginLeft: '10px',
|
|
@@ -4,4 +4,4 @@ export declare const hasDetailRelations: (mTID: number | undefined) => Promise<b
|
|
|
4
4
|
/** Check if dcmtType (mTID) has configured Master or Many-to-Many relations */
|
|
5
5
|
export declare const hasMasterRelations: (mTID: number | undefined) => Promise<boolean>;
|
|
6
6
|
export declare const isXMLFileExt: (fileExt: string | undefined) => boolean;
|
|
7
|
-
export declare const processButtonAttributes: (args: string | undefined, formData: MetadataValueDescriptorEx[] | undefined, selectedItems: Array<any> | undefined) =>
|
|
7
|
+
export declare const processButtonAttributes: (args: string | undefined, formData: MetadataValueDescriptorEx[] | undefined, selectedItems: Array<any> | undefined) => Record<string, any> | undefined;
|
|
@@ -26,68 +26,66 @@ export const isXMLFileExt = (fileExt) => {
|
|
|
26
26
|
/*utility functions for TMCustomButton*/
|
|
27
27
|
export const processButtonAttributes = (args, formData, selectedItems) => args && formData ? formDataMap(formData, args, selectedItems) : undefined;
|
|
28
28
|
const processSelectedItems = (selectedItems) => selectedItems && selectedItems.map(item => item["DID"]) || [];
|
|
29
|
-
const formDataMap = (data, args, selectedItems
|
|
30
|
-
// Regex per catturare sia chiave={@campo} che {@campo} o {valore}
|
|
31
|
-
const tokens = args.match(/(\w+)=\{@?[^}]+\}|\{@?[^}]+\}/g) || [];
|
|
29
|
+
const formDataMap = (data, args, selectedItems) => {
|
|
32
30
|
const session = SDK_Globals.tmSession;
|
|
33
31
|
const sessionDescr = session?.SessionDescr;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
// Formato:
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
const result = {};
|
|
33
|
+
// Regex per catturare: chiave=[{@campo} ...] o chiave={valore} o {@campo}
|
|
34
|
+
const keyValueRegex = /(\w+)=\[([^\]]+)\]|(\w+)=\{([^}]+)\}|\{@([^}]+)\}/g;
|
|
35
|
+
let match;
|
|
36
|
+
while ((match = keyValueRegex.exec(args)) !== null) {
|
|
37
|
+
if (match[1]) {
|
|
38
|
+
// Formato: chiave=[{@campo} {@campo} ...]
|
|
39
|
+
const key = match[1];
|
|
40
|
+
const content = match[2];
|
|
41
|
+
// Estrai tutti i {@campo} e concatenali
|
|
42
|
+
const fields = content.match(/\{@([^}]+)\}/g) || [];
|
|
43
|
+
const values = fields.map(field => {
|
|
44
|
+
const fieldName = field.slice(2, -1);
|
|
45
|
+
const md = data.find(md => md.md?.name === fieldName);
|
|
46
|
+
return md?.value ?? '';
|
|
47
|
+
}).filter(v => v);
|
|
48
|
+
result[key] = values.join(' ');
|
|
45
49
|
}
|
|
46
|
-
else if (
|
|
50
|
+
else if (match[3]) {
|
|
51
|
+
// Formato: chiave={valore}
|
|
52
|
+
const key = match[3];
|
|
53
|
+
const value = match[4];
|
|
54
|
+
result[key] = value;
|
|
55
|
+
}
|
|
56
|
+
else if (match[5]) {
|
|
47
57
|
// Formato: {@campo}
|
|
48
|
-
fieldName =
|
|
58
|
+
const fieldName = match[5];
|
|
49
59
|
const md = data.find(md => md.md?.name === fieldName);
|
|
50
60
|
switch (fieldName) {
|
|
51
61
|
case 'SelectedDIDs':
|
|
52
|
-
|
|
62
|
+
result[fieldName] = processSelectedItems(selectedItems);
|
|
53
63
|
break;
|
|
54
64
|
case 'AuthenticationMode':
|
|
55
|
-
|
|
65
|
+
result[fieldName] = sessionDescr?.authenticationMode ?? null;
|
|
56
66
|
break;
|
|
57
67
|
case 'ArchiveID':
|
|
58
|
-
|
|
68
|
+
result[fieldName] = sessionDescr?.archiveID ?? null;
|
|
59
69
|
break;
|
|
60
70
|
case 'CultureID':
|
|
61
|
-
|
|
71
|
+
result[fieldName] = sessionDescr?.cultureID ?? null;
|
|
62
72
|
break;
|
|
63
73
|
case 'Domain':
|
|
64
|
-
|
|
74
|
+
result[fieldName] = sessionDescr?.domain ?? null;
|
|
65
75
|
break;
|
|
66
76
|
case 'UserID':
|
|
67
|
-
|
|
77
|
+
result[fieldName] = sessionDescr?.userID ?? null;
|
|
68
78
|
break;
|
|
69
79
|
case 'UserName':
|
|
70
|
-
|
|
80
|
+
result[fieldName] = sessionDescr?.userName ?? null;
|
|
71
81
|
break;
|
|
72
82
|
case 'Session':
|
|
73
|
-
|
|
83
|
+
result[fieldName] = session ?? null;
|
|
74
84
|
break;
|
|
75
85
|
default:
|
|
76
|
-
|
|
86
|
+
result[fieldName] = md?.value;
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
|
-
else {
|
|
80
|
-
// Formato: {valore}
|
|
81
|
-
fieldName = token.slice(1, -1);
|
|
82
|
-
value = fieldName;
|
|
83
|
-
}
|
|
84
|
-
return { fieldName, value };
|
|
85
|
-
});
|
|
86
|
-
if (returnObject) {
|
|
87
|
-
return results.reduce((acc, { fieldName, value }) => {
|
|
88
|
-
acc[fieldName] = value;
|
|
89
|
-
return acc;
|
|
90
|
-
}, {});
|
|
91
89
|
}
|
|
92
|
-
return
|
|
90
|
+
return result;
|
|
93
91
|
};
|