@topconsultnpm/sdkui-react 6.19.0-dev2.40 → 6.19.0-dev2.42
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/base/TMCustomButton.js +13 -6
- package/lib/components/base/TMFileManagerDataGridView.js +1 -1
- package/lib/components/features/blog/TMBlogCommentForm.d.ts +0 -3
- package/lib/components/features/blog/TMBlogCommentForm.js +7 -10
- package/lib/helper/dcmtsHelper.d.ts +2 -1
- package/lib/helper/dcmtsHelper.js +22 -63
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { SDK_Globals } from '@topconsultnpm/sdk-ts';
|
|
2
3
|
import { useEffect, useRef, useState, useMemo } from 'react';
|
|
3
4
|
import TMModal from './TMModal';
|
|
4
5
|
import styled from 'styled-components';
|
|
5
6
|
import { TMLayoutWaitingContainer } from '../..';
|
|
6
|
-
import { processButtonAttributes } from '../../helper/dcmtsHelper';
|
|
7
|
+
import { processButtonAttributes, processSelectedItems } from '../../helper/dcmtsHelper';
|
|
7
8
|
const IframeContainer = styled.div `
|
|
8
9
|
display: flex;
|
|
9
10
|
height: 100%;
|
|
@@ -18,9 +19,8 @@ const TMCustomButton = (props) => {
|
|
|
18
19
|
const { button, isModal = true, formData, selectedItems, onClose } = props;
|
|
19
20
|
const { appName: scriptUrl, arguments: args } = button;
|
|
20
21
|
const iframeRef = useRef(null);
|
|
21
|
-
const attributes = useMemo(() => processButtonAttributes(args, formData
|
|
22
|
-
const selectedItemsProcessed = [];
|
|
23
|
-
//const selectedItemsProcessed = useMemo(() => processSelectedItems(args, formData, selectedItems), [args, formData, selectedItems]);
|
|
22
|
+
const attributes = useMemo(() => processButtonAttributes(args, formData), [args, formData]);
|
|
23
|
+
const selectedItemsProcessed = useMemo(() => processSelectedItems(args, formData, selectedItems), [args, formData, selectedItems]);
|
|
24
24
|
const RunOnce = button.mode === "RunOnce";
|
|
25
25
|
const [loading, setLoading] = useState(true);
|
|
26
26
|
const [error, setError] = useState(false);
|
|
@@ -61,7 +61,10 @@ const TMCustomButton = (props) => {
|
|
|
61
61
|
const checkIframe = setInterval(() => {
|
|
62
62
|
if (iframeRef.current?.contentWindow) {
|
|
63
63
|
clearInterval(checkIframe);
|
|
64
|
-
iframeRef.current.contentWindow.postMessage({
|
|
64
|
+
iframeRef.current.contentWindow.postMessage({
|
|
65
|
+
"options": item,
|
|
66
|
+
"session": SDK_Globals.tmSession
|
|
67
|
+
}, targetOrigin);
|
|
65
68
|
// Attendi prima di passare al prossimo
|
|
66
69
|
setTimeout(() => {
|
|
67
70
|
setWaitPanelValue(index + 1);
|
|
@@ -92,7 +95,11 @@ const TMCustomButton = (props) => {
|
|
|
92
95
|
}
|
|
93
96
|
else if (iframeRef.current?.contentWindow) {
|
|
94
97
|
// Modalità RunOnce: invia dati all'iframe quando è caricato
|
|
95
|
-
|
|
98
|
+
const mergedAttributes = { ...attributes, selectedItems: selectedItemsProcessed };
|
|
99
|
+
iframeRef.current.contentWindow.postMessage({
|
|
100
|
+
"options": mergedAttributes,
|
|
101
|
+
"session": SDK_Globals.tmSession
|
|
102
|
+
}, targetOrigin);
|
|
96
103
|
//clearTimeout(timeoutIframe);
|
|
97
104
|
}
|
|
98
105
|
}, [loading, error, RunOnce]);
|
|
@@ -96,6 +96,6 @@ const TMFileManagerDataGridView = (props) => {
|
|
|
96
96
|
{ dataField: "creationTime", caption: SDKUI_Localizator.CreationTime, dataType: 'datetime', format: 'dd/MM/yyyy HH:mm', cellRender: cellDatetimeRender },
|
|
97
97
|
];
|
|
98
98
|
}, [searchText]);
|
|
99
|
-
return _jsx(TMDataGrid, { dataSource: items ?? [], dataColumns: dataColumns, focusedRowKey: focusedRowKey, selectedRowKeys: selectedRowKeys, onFocusedRowChanged: onFocusedRowChanged, onSelectionChanged: onSelectionChanged, onCellDblClick: onCellDblClick, onContextMenuPreparing: onContextMenuPreparing, showSearchPanel: false, noDataText: SDKUI_Localizator.FolderIsEmpty }
|
|
99
|
+
return _jsx(TMDataGrid, { dataSource: items ?? [], dataColumns: dataColumns, focusedRowKey: focusedRowKey, selectedRowKeys: selectedRowKeys, onFocusedRowChanged: onFocusedRowChanged, onSelectionChanged: onSelectionChanged, onCellDblClick: onCellDblClick, onContextMenuPreparing: onContextMenuPreparing, showSearchPanel: false, noDataText: SDKUI_Localizator.FolderIsEmpty });
|
|
100
100
|
};
|
|
101
101
|
export default TMFileManagerDataGridView;
|
|
@@ -6,13 +6,10 @@ interface TMBlogCommentFormProps {
|
|
|
6
6
|
participants: Array<UserDescriptor>;
|
|
7
7
|
onClose: () => void;
|
|
8
8
|
showAttachmentsSection?: boolean;
|
|
9
|
-
removeAndEditAttachment?: boolean;
|
|
10
9
|
selectedAttachments?: Array<FileItem>;
|
|
11
10
|
selectedAttachmentDid?: Array<number>;
|
|
12
|
-
title?: string;
|
|
13
11
|
allFileItems?: FileItem;
|
|
14
12
|
allArchivedDocumentsFileItems?: Array<FileItem>;
|
|
15
|
-
onSavedCallback?: () => void;
|
|
16
13
|
onFilterCreated?: (predicate: (post: BlogPost) => boolean) => void;
|
|
17
14
|
refreshCallback?: () => Promise<void>;
|
|
18
15
|
}
|
|
@@ -29,7 +29,7 @@ const getNonDirectoryFiles = (items, exclude) => {
|
|
|
29
29
|
};
|
|
30
30
|
const TMBlogCommentForm = (props) => {
|
|
31
31
|
const maxLength = 1000;
|
|
32
|
-
const {
|
|
32
|
+
const { participants, selectedAttachments, selectedAttachmentDid, allFileItems, allArchivedDocumentsFileItems = [], onClose, context, showAttachmentsSection = true, 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);
|
|
@@ -171,10 +171,7 @@ const TMBlogCommentForm = (props) => {
|
|
|
171
171
|
finally {
|
|
172
172
|
// Hide the loading spinner and close the operation (e.g., close a modal or cleanup)
|
|
173
173
|
TMSpinner.hide();
|
|
174
|
-
|
|
175
|
-
onSavedCallback();
|
|
176
|
-
else
|
|
177
|
-
onClose();
|
|
174
|
+
onClose();
|
|
178
175
|
}
|
|
179
176
|
};
|
|
180
177
|
const onCloseCallback = () => {
|
|
@@ -219,8 +216,8 @@ const TMBlogCommentForm = (props) => {
|
|
|
219
216
|
// Update the state with selected draft items
|
|
220
217
|
setCurrentDraftAttachments(selectedDraftItems);
|
|
221
218
|
};
|
|
222
|
-
return _jsx(TMSaveForm, { id: 1, title:
|
|
223
|
-
width:
|
|
219
|
+
return _jsx(TMSaveForm, { id: 1, title: SDKUI_Localizator.AddNewComment, 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: {
|
|
220
|
+
width: 'calc(100% - 60px)',
|
|
224
221
|
overflowX: 'auto',
|
|
225
222
|
whiteSpace: 'nowrap',
|
|
226
223
|
height: '50px',
|
|
@@ -234,7 +231,7 @@ const TMBlogCommentForm = (props) => {
|
|
|
234
231
|
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
232
|
return _jsxs("div", { style: {
|
|
236
233
|
display: 'inline-flex',
|
|
237
|
-
alignItems: 'center',
|
|
234
|
+
alignItems: 'center', // <-- this centers content vertically
|
|
238
235
|
padding: '4px 8px',
|
|
239
236
|
margin: '4px',
|
|
240
237
|
border: '1px solid #ddd',
|
|
@@ -261,7 +258,7 @@ const TMBlogCommentForm = (props) => {
|
|
|
261
258
|
fontWeight: 'bold',
|
|
262
259
|
marginRight: '8px',
|
|
263
260
|
boxShadow: '1px 1px 2px #00000020',
|
|
264
|
-
}, children: _jsx(TMTooltip, { content: SDKUI_Localizator.Version, children: draft.version }) })),
|
|
261
|
+
}, children: _jsx(TMTooltip, { content: SDKUI_Localizator.Version, children: draft.version }) })), _jsx(TMTooltip, { content: SDKUI_Localizator.RemoveAttachment, children: _jsx("span", { onClick: () => removeAttachment(draft), style: {
|
|
265
262
|
display: 'inline-flex',
|
|
266
263
|
width: '20px',
|
|
267
264
|
height: '20px',
|
|
@@ -273,7 +270,7 @@ const TMBlogCommentForm = (props) => {
|
|
|
273
270
|
cursor: 'pointer',
|
|
274
271
|
boxShadow: '1px 1px 2px #00000020',
|
|
275
272
|
}, children: _jsx("span", { style: { fontSize: '15px' }, children: "\u00D7" }) }) })] }, draft.did);
|
|
276
|
-
})) : (_jsx("div", { style: { color: '#999', width: '100%', textAlign: 'center' }, children: SDKUI_Localizator.NoAttachments })) }),
|
|
273
|
+
})) : (_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: {
|
|
277
274
|
width: '50px',
|
|
278
275
|
height: '50px',
|
|
279
276
|
marginLeft: '10px',
|
|
@@ -4,4 +4,5 @@ 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
|
|
7
|
+
export declare const processButtonAttributes: (args: string | undefined, formData: MetadataValueDescriptorEx[] | undefined) => (string | null)[] | undefined;
|
|
8
|
+
export declare const processSelectedItems: (args: string | undefined, formData: MetadataValueDescriptorEx[] | undefined, selectedItems: Array<any> | undefined) => any[][];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationCacheService, RelationTypes
|
|
1
|
+
import { RelationCacheService, RelationTypes } from "@topconsultnpm/sdk-ts";
|
|
2
2
|
/** Check if dcmtType (mTID) has configured Detail or Many-to-Many relations */
|
|
3
3
|
export const hasDetailRelations = async (mTID) => {
|
|
4
4
|
let allRelations = await RelationCacheService.GetAllAsync();
|
|
@@ -24,68 +24,27 @@ export const isXMLFileExt = (fileExt) => {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
/*utility functions for TMCustomButton*/
|
|
27
|
-
export const processButtonAttributes = (args, formData
|
|
28
|
-
const processSelectedItems = (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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(' ');
|
|
49
|
-
}
|
|
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]) {
|
|
57
|
-
// Formato: {@campo}
|
|
58
|
-
const fieldName = match[5];
|
|
27
|
+
export const processButtonAttributes = (args, formData) => args && formData ? formDataMap(formData, args) : undefined;
|
|
28
|
+
export const processSelectedItems = (args, formData, selectedItems) => {
|
|
29
|
+
if (!args || !selectedItems)
|
|
30
|
+
return [];
|
|
31
|
+
const MidList = formData ? formDataMap(formData, args, true) : [];
|
|
32
|
+
return selectedItems.map(item =>
|
|
33
|
+
//salvo il did come primo elemento dell'array
|
|
34
|
+
[item["DID"], ...MidList.map(key => key && item[key])]);
|
|
35
|
+
};
|
|
36
|
+
const formDataMap = (data, args, returnMid = false) => {
|
|
37
|
+
const tokens = args.match(/\{@?[^}]+\}/g) || [];
|
|
38
|
+
return tokens.map(token => {
|
|
39
|
+
if (token.startsWith('{@')) {
|
|
40
|
+
// Campo dinamico: {@campo} -> cerca in formData
|
|
41
|
+
const fieldName = token.slice(2, -1);
|
|
59
42
|
const md = data.find(md => md.md?.name === fieldName);
|
|
60
|
-
|
|
61
|
-
case 'SelectedDIDs':
|
|
62
|
-
result[fieldName] = processSelectedItems(selectedItems);
|
|
63
|
-
break;
|
|
64
|
-
case 'AuthenticationMode':
|
|
65
|
-
result[fieldName] = sessionDescr?.authenticationMode ?? null;
|
|
66
|
-
break;
|
|
67
|
-
case 'ArchiveID':
|
|
68
|
-
result[fieldName] = sessionDescr?.archiveID ?? null;
|
|
69
|
-
break;
|
|
70
|
-
case 'CultureID':
|
|
71
|
-
result[fieldName] = sessionDescr?.cultureID ?? null;
|
|
72
|
-
break;
|
|
73
|
-
case 'Domain':
|
|
74
|
-
result[fieldName] = sessionDescr?.domain ?? null;
|
|
75
|
-
break;
|
|
76
|
-
case 'UserID':
|
|
77
|
-
result[fieldName] = sessionDescr?.userID ?? null;
|
|
78
|
-
break;
|
|
79
|
-
case 'UserName':
|
|
80
|
-
result[fieldName] = sessionDescr?.userName ?? null;
|
|
81
|
-
break;
|
|
82
|
-
case 'Session':
|
|
83
|
-
result[fieldName] = session ?? null;
|
|
84
|
-
break;
|
|
85
|
-
default:
|
|
86
|
-
result[fieldName] = md?.value;
|
|
87
|
-
}
|
|
43
|
+
return returnMid ? (md ? `${md.tid}_${md.mid}` : null) : (md?.value ?? null);
|
|
88
44
|
}
|
|
89
|
-
|
|
90
|
-
|
|
45
|
+
else {
|
|
46
|
+
// Campo statico: {valore} -> ritorna il valore o null
|
|
47
|
+
return returnMid ? null : token.slice(1, -1);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
91
50
|
};
|