@topconsultnpm/sdkui-react 6.22.0-t1 → 6.22.0-t2
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/NewComponents/ContextMenu/TMContextMenu.js +1 -1
- package/lib/components/NewComponents/ContextMenu/styles.d.ts +45 -43
- package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.js +1 -1
- package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +67 -60
- package/lib/components/base/Styled.d.ts +92 -76
- package/lib/components/base/TMButton.d.ts +13 -0
- package/lib/components/base/TMButton.js +137 -5
- package/lib/components/base/TMDataGrid.d.ts +2 -0
- package/lib/components/base/TMDataGrid.js +260 -8
- package/lib/components/base/TMDataGridExportForm.js +39 -30
- package/lib/components/base/TMEditorBase.d.ts +2 -0
- package/lib/components/base/TMFileManager.js +5 -3
- package/lib/components/base/TMFileManagerDataGridView.js +11 -2
- package/lib/components/base/TMFileManagerThumbnailItems.js +19 -9
- package/lib/components/base/TMFileManagerUtils.d.ts +6 -6
- package/lib/components/base/TMFileManagerUtils.js +37 -1
- package/lib/components/base/TMModal.d.ts +11 -0
- package/lib/components/base/TMModal.js +47 -13
- package/lib/components/base/TMPanel.d.ts +6 -0
- package/lib/components/base/TMPanel.js +138 -25
- package/lib/components/base/TMPopUp.js +3 -0
- package/lib/components/base/TMTooltip.d.ts +2 -1
- package/lib/components/base/TMTooltip.js +24 -8
- package/lib/components/base/TMTreeView.d.ts +13 -7
- package/lib/components/base/TMTreeView.js +108 -67
- package/lib/components/choosers/TMDcmtTypeChooser.js +4 -3
- package/lib/components/choosers/TMDistinctValues.d.ts +9 -7
- package/lib/components/choosers/TMDistinctValues.js +149 -142
- package/lib/components/choosers/TMMetadataChooser.js +1 -1
- package/lib/components/choosers/TMQuickSearchInfo.d.ts +13 -0
- package/lib/components/choosers/TMQuickSearchInfo.js +279 -0
- package/lib/components/choosers/TMQuickSearchSettingsForm.d.ts +16 -0
- package/lib/components/choosers/TMQuickSearchSettingsForm.js +94 -0
- package/lib/components/choosers/TMSelectedValuesSummary.d.ts +13 -0
- package/lib/components/choosers/TMSelectedValuesSummary.js +91 -0
- package/lib/components/editors/TMDateBox.d.ts +16 -1
- package/lib/components/editors/TMDateBox.js +90 -22
- package/lib/components/editors/TMDropDown.d.ts +3 -0
- package/lib/components/editors/TMDropDown.js +197 -5
- package/lib/components/editors/TMEditorStyled.d.ts +20 -42
- package/lib/components/editors/TMMetadataEditor.d.ts +5 -1
- package/lib/components/editors/TMMetadataEditor.js +27 -23
- package/lib/components/editors/TMTextArea.d.ts +1 -0
- package/lib/components/editors/TMTextArea.js +23 -15
- package/lib/components/editors/TMTextBox.d.ts +2 -0
- package/lib/components/editors/TMTextBox.js +30 -19
- package/lib/components/features/archive/TMArchive.js +17 -3
- package/lib/components/features/documents/TMBatchUpdateForm.js +19 -5
- package/lib/components/features/documents/TMDcmtBlog.d.ts +3 -0
- package/lib/components/features/documents/TMDcmtBlog.js +4 -4
- package/lib/components/features/documents/TMDcmtForm.d.ts +7 -0
- package/lib/components/features/documents/TMDcmtForm.js +232 -53
- package/lib/components/features/documents/TMDcmtFormActionButtons.d.ts +11 -0
- package/lib/components/features/documents/TMDcmtFormActionButtons.js +77 -7
- package/lib/components/features/documents/TMDcmtIcon.js +5 -3
- package/lib/components/features/documents/TMDcmtPreview.d.ts +7 -5
- package/lib/components/features/documents/TMDcmtPreview.js +10 -6
- package/lib/components/features/documents/TMMasterDetailDcmts.js +95 -33
- package/lib/components/features/documents/TMMasterInfoFields.d.ts +20 -0
- package/lib/components/features/documents/TMMasterInfoFields.js +186 -0
- package/lib/components/features/documents/TMMergeToPdfForm.d.ts +1 -2
- package/lib/components/features/documents/TMMergeToPdfForm.js +30 -5
- package/lib/components/features/documents/TMMultiMasterDetailDcmtsForm.d.ts +46 -0
- package/lib/components/features/documents/TMMultiMasterDetailDcmtsForm.js +323 -0
- package/lib/components/features/documents/TMMultiMasterDetailDcmtsUtils.d.ts +370 -0
- package/lib/components/features/documents/TMMultiMasterDetailDcmtsUtils.js +283 -0
- package/lib/components/features/documents/TMRelationViewer.d.ts +14 -1
- package/lib/components/features/documents/TMRelationViewer.js +82 -52
- package/lib/components/features/search/TMSearch.js +103 -24
- package/lib/components/features/search/TMSearchQueryEditor.js +5 -3
- package/lib/components/features/search/TMSearchQueryPanel.d.ts +14 -4
- package/lib/components/features/search/TMSearchQueryPanel.js +152 -57
- package/lib/components/features/search/TMSearchResult.d.ts +16 -0
- package/lib/components/features/search/TMSearchResult.js +438 -145
- package/lib/components/features/search/TMTreeSelector.js +109 -64
- package/lib/components/features/workflow/TMWorkflowPopup.d.ts +10 -0
- package/lib/components/features/workflow/TMWorkflowPopup.js +8 -4
- package/lib/components/features/workflow/diagram/WorkitemRecipientsEditor.d.ts +3 -1
- package/lib/components/forms/Login/ChangePasswordInputs.d.ts +3 -1
- package/lib/components/grids/TMBlogAttachments.js +13 -2
- package/lib/components/grids/TMBlogHeader.js +5 -1
- package/lib/components/grids/TMBlogsPost.d.ts +2 -0
- package/lib/components/grids/TMBlogsPost.js +31 -4
- package/lib/components/grids/TMBlogsPostUtils.d.ts +1 -0
- package/lib/components/grids/TMBlogsPostUtils.js +14 -3
- package/lib/components/layout/panelManager/TMPanelManagerContainer.d.ts +1 -0
- package/lib/components/layout/panelManager/TMPanelManagerContainer.js +24 -14
- package/lib/components/layout/panelManager/TMPanelManagerContext.js +68 -93
- package/lib/components/layout/panelManager/TMPanelManagerToolbar.d.ts +4 -5
- package/lib/components/layout/panelManager/TMPanelWrapper.js +2 -2
- package/lib/components/layout/panelManager/types.d.ts +3 -0
- package/lib/components/layout/panelManager/utils.js +13 -11
- package/lib/components/query/TMQueryEditor.d.ts +14 -10
- package/lib/components/sidebar/TMCommandsPanel.d.ts +4 -4
- package/lib/components/sidebar/TMHeader.js +30 -20
- package/lib/components/viewers/TMMidViewer.js +5 -2
- package/lib/components/viewers/TMTidViewer.js +86 -25
- package/lib/css/tm-sdkui.css +1 -1
- package/lib/devextreme-license.d.ts +1 -0
- package/lib/devextreme-license.js +3 -0
- package/lib/helper/Globalization.d.ts +1 -1
- package/lib/helper/SDKUI_Globals.d.ts +110 -0
- package/lib/helper/SDKUI_Globals.js +151 -0
- package/lib/helper/SDKUI_Localizator.d.ts +55 -0
- package/lib/helper/SDKUI_Localizator.js +550 -0
- package/lib/helper/TMAppUpdatedModal.d.ts +2 -0
- package/lib/helper/TMAppUpdatedModal.js +134 -0
- package/lib/helper/TMIcons.d.ts +1 -0
- package/lib/helper/TMIcons.js +3 -0
- package/lib/helper/TMUtils.d.ts +51 -4
- package/lib/helper/TMUtils.js +272 -11
- package/lib/helper/dataGridSearchHelper.d.ts +28 -0
- package/lib/helper/dataGridSearchHelper.js +51 -0
- package/lib/helper/dcmtsHelper.d.ts +20 -0
- package/lib/helper/dcmtsHelper.js +58 -1
- package/lib/helper/helpers.d.ts +23 -1
- package/lib/helper/helpers.js +57 -1
- package/lib/helper/index.d.ts +2 -0
- package/lib/helper/index.js +2 -0
- package/lib/helper/queryHelper.d.ts +6 -1
- package/lib/helper/queryHelper.js +8 -3
- package/lib/hooks/tmDistinctValuesGridHelper.d.ts +16 -0
- package/lib/hooks/tmDistinctValuesGridHelper.js +31 -0
- package/lib/hooks/useArchiveListForm.d.ts +39 -0
- package/lib/hooks/useArchiveListForm.js +46 -0
- package/lib/hooks/useCaseFlowApprove.d.ts +56 -0
- package/lib/hooks/useCaseFlowApprove.js +157 -0
- package/lib/hooks/useDataUserIdItem.d.ts +1 -0
- package/lib/hooks/useDataUserIdItem.js +1 -0
- package/lib/hooks/useDocumentOperations.d.ts +4 -0
- package/lib/hooks/useDocumentOperations.js +52 -10
- package/lib/hooks/useMultiMasterDetailDcmts.d.ts +113 -0
- package/lib/hooks/useMultiMasterDetailDcmts.js +760 -0
- package/lib/hooks/useRelatedDocuments.d.ts +1 -0
- package/lib/hooks/useRelatedDocuments.js +22 -27
- package/lib/hooks/useShowDossiersV5.d.ts +12 -0
- package/lib/hooks/useShowDossiersV5.js +37 -0
- package/lib/hooks/useTMDistinctValuesMetadataDisplay.d.ts +18 -0
- package/lib/hooks/useTMDistinctValuesMetadataDisplay.js +103 -0
- package/lib/hooks/useTMDistinctValuesQuickSearch.d.ts +49 -0
- package/lib/hooks/useTMDistinctValuesQuickSearch.js +307 -0
- package/lib/hooks/useTMDistinctValuesSelection.d.ts +42 -0
- package/lib/hooks/useTMDistinctValuesSelection.js +103 -0
- package/lib/hooks/useTMDistinctValuesSource.d.ts +29 -0
- package/lib/hooks/useTMDistinctValuesSource.js +105 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +5 -2
- package/lib/services/caseflow/CaseFlowService.d.ts +236 -0
- package/lib/services/caseflow/CaseFlowService.js +693 -0
- package/lib/services/caseflow/CaseFlowTemplateCacheService.d.ts +28 -0
- package/lib/services/caseflow/CaseFlowTemplateCacheService.js +121 -0
- package/lib/services/caseflow/caseFlowNameCache.d.ts +32 -0
- package/lib/services/caseflow/caseFlowNameCache.js +116 -0
- package/lib/services/caseflow/caseFlowWorkItemUtils.d.ts +61 -0
- package/lib/services/caseflow/caseFlowWorkItemUtils.js +113 -0
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.js +4 -0
- package/lib/services/platform_services.d.ts +1 -1
- package/package.json +9 -5
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { AppModules, SDK_Globals } from '@topconsultnpm/sdk-ts';
|
|
5
|
+
import { useDeviceType, TMModal } from '../components';
|
|
6
|
+
import { calcResponsiveSizes, WHATS_NEWS_LINK_URL } from './helpers';
|
|
7
|
+
import { SDKUI_Globals } from './SDKUI_Globals';
|
|
8
|
+
import { SDKUI_Localizator } from './SDKUI_Localizator';
|
|
9
|
+
import { IconUpdate, IconOpenInNew } from './TMIcons';
|
|
10
|
+
import { getAppModuleButtonColors } from './TMUtils';
|
|
11
|
+
const Content = styled.div `
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
width: 100%;
|
|
15
|
+
background-color: #ffffff;
|
|
16
|
+
`;
|
|
17
|
+
const Header = styled.div `
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: 14px;
|
|
22
|
+
padding: 32px 30px 26px 30px;
|
|
23
|
+
background-color: ${({ $backgroundColor }) => $backgroundColor};
|
|
24
|
+
color: #ffffff;
|
|
25
|
+
text-align: center;
|
|
26
|
+
`;
|
|
27
|
+
const HeaderIcon = styled.div `
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
width: 68px;
|
|
32
|
+
height: 68px;
|
|
33
|
+
border-radius: 50%;
|
|
34
|
+
background-color: rgba(255, 255, 255, 0.18);
|
|
35
|
+
border: 1px solid rgba(255, 255, 255, 0.35);
|
|
36
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
|
|
37
|
+
`;
|
|
38
|
+
const HeaderTitle = styled.h2 `
|
|
39
|
+
margin: 0;
|
|
40
|
+
font-size: 22px;
|
|
41
|
+
font-weight: 600;
|
|
42
|
+
letter-spacing: 0.2px;
|
|
43
|
+
`;
|
|
44
|
+
const VersionBadge = styled.span `
|
|
45
|
+
display: inline-block;
|
|
46
|
+
padding: 4px 12px;
|
|
47
|
+
border-radius: 999px;
|
|
48
|
+
background-color: rgba(255, 255, 255, 0.22);
|
|
49
|
+
border: 1px solid rgba(255, 255, 255, 0.4);
|
|
50
|
+
font-size: 13px;
|
|
51
|
+
font-weight: 600;
|
|
52
|
+
letter-spacing: 0.3px;
|
|
53
|
+
`;
|
|
54
|
+
const Body = styled.div `
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
gap: 10px;
|
|
58
|
+
padding: 26px 30px 22px 30px;
|
|
59
|
+
text-align: center;
|
|
60
|
+
`;
|
|
61
|
+
const Message = styled.p `
|
|
62
|
+
margin: 0;
|
|
63
|
+
font-size: 15px;
|
|
64
|
+
line-height: 1.6;
|
|
65
|
+
color: #242424;
|
|
66
|
+
`;
|
|
67
|
+
const SubMessage = styled.p `
|
|
68
|
+
margin: 0;
|
|
69
|
+
font-size: 13px;
|
|
70
|
+
line-height: 1.6;
|
|
71
|
+
color: #6b6b6b;
|
|
72
|
+
`;
|
|
73
|
+
const Footer = styled.div `
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: row;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
align-items: center;
|
|
78
|
+
flex-wrap: wrap;
|
|
79
|
+
gap: 12px;
|
|
80
|
+
padding: 0 30px 28px 30px;
|
|
81
|
+
`;
|
|
82
|
+
const BaseButton = styled.button `
|
|
83
|
+
display: inline-flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
justify-content: center;
|
|
86
|
+
gap: 8px;
|
|
87
|
+
min-width: 150px;
|
|
88
|
+
padding: 10px 18px;
|
|
89
|
+
border-radius: 8px;
|
|
90
|
+
font-size: 14px;
|
|
91
|
+
font-weight: 600;
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
|
|
94
|
+
`;
|
|
95
|
+
const PrimaryButton = styled(BaseButton) `
|
|
96
|
+
border: 1px solid ${({ $base }) => $base};
|
|
97
|
+
background-color: ${({ $base }) => $base};
|
|
98
|
+
color: #ffffff;
|
|
99
|
+
|
|
100
|
+
&:hover {
|
|
101
|
+
background-color: ${({ $hover }) => $hover};
|
|
102
|
+
border-color: ${({ $hover }) => $hover};
|
|
103
|
+
box-shadow: 0 2px 8px ${({ $shadow }) => $shadow};
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
106
|
+
const SecondaryButton = styled(BaseButton) `
|
|
107
|
+
border: 1px solid #d5d5d5;
|
|
108
|
+
background-color: #ffffff;
|
|
109
|
+
color: #444444;
|
|
110
|
+
|
|
111
|
+
&:hover {
|
|
112
|
+
background-color: #f3f3f3;
|
|
113
|
+
border-color: #bdbdbd;
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
116
|
+
export const TMAppUpdatedModal = () => {
|
|
117
|
+
const deviceType = useDeviceType();
|
|
118
|
+
const currentVersion = SDK_Globals.appVersion ?? '';
|
|
119
|
+
const appModuleID = SDK_Globals.tmSession?.SessionDescr?.appModuleID ?? AppModules.SURFER;
|
|
120
|
+
const appModuleColors = useMemo(() => getAppModuleButtonColors(appModuleID), [appModuleID]);
|
|
121
|
+
const [previousVersion] = useState(() => SDKUI_Globals.userSettings.lastSeenAppVersion ?? '');
|
|
122
|
+
const [isOpen, setIsOpen] = useState(() => currentVersion !== '' && previousVersion !== currentVersion);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (!isOpen)
|
|
125
|
+
return;
|
|
126
|
+
SDKUI_Globals.userSettings.lastSeenAppVersion = currentVersion;
|
|
127
|
+
}, [isOpen, currentVersion]);
|
|
128
|
+
const onClose = () => { setIsOpen(false); };
|
|
129
|
+
if (!isOpen)
|
|
130
|
+
return null;
|
|
131
|
+
return (_jsx(TMModal, { width: calcResponsiveSizes(deviceType, '520px', '520px', '95%'), height: 'auto', showHeader: false, resizable: false, onClose: onClose, children: _jsxs(Content, { children: [_jsxs(Header, { "$backgroundColor": appModuleColors.base, children: [_jsx(HeaderIcon, { children: _jsx(IconUpdate, { fontSize: 34 }) }), _jsx(HeaderTitle, { children: SDKUI_Localizator.AppUpdatedTitle }), _jsx(VersionBadge, { children: `${SDK_Globals.appModule} ${currentVersion}` })] }), _jsxs(Body, { children: [_jsx(Message, { children: previousVersion
|
|
132
|
+
? SDKUI_Localizator.AppUpdatedMessageFromTo.replaceParams(previousVersion, currentVersion)
|
|
133
|
+
: SDKUI_Localizator.AppUpdatedMessage.replaceParams(currentVersion) }), _jsx(SubMessage, { children: SDKUI_Localizator.AppUpdatedSubMessage })] }), _jsxs(Footer, { children: [_jsxs(PrimaryButton, { "$base": appModuleColors.base, "$hover": appModuleColors.hover, "$shadow": appModuleColors.shadow, onClick: () => window.open(WHATS_NEWS_LINK_URL, '_blank', 'noopener,noreferrer'), children: [_jsx(IconOpenInNew, { fontSize: 18 }), SDKUI_Localizator.DiscoverWhatsNew] }), _jsx(SecondaryButton, { onClick: onClose, children: SDKUI_Localizator.Close })] })] }) }));
|
|
134
|
+
};
|
package/lib/helper/TMIcons.d.ts
CHANGED
|
@@ -271,6 +271,7 @@ export declare function IconWizard4(props: React.SVGProps<SVGSVGElement>): React
|
|
|
271
271
|
export declare function IconNew(props: React.SVGProps<SVGSVGElement>): React.JSX.Element;
|
|
272
272
|
export declare function IconFileOpenOutline(props: Readonly<React.SVGProps<SVGSVGElement>>): React.JSX.Element;
|
|
273
273
|
export declare function IconArchiveDetail(props: React.SVGProps<SVGSVGElement>): React.JSX.Element;
|
|
274
|
+
export declare function IconArchiveMultipleDetailDocuments(props: React.SVGProps<SVGSVGElement>): React.JSX.Element;
|
|
274
275
|
export declare function IconArchiveMaster(props: React.SVGProps<SVGSVGElement>): React.JSX.Element;
|
|
275
276
|
export declare function IconPair(props: React.SVGProps<SVGSVGElement>): React.JSX.Element;
|
|
276
277
|
export declare function IconUnpair(props: React.SVGProps<SVGSVGElement>): React.JSX.Element;
|
package/lib/helper/TMIcons.js
CHANGED
|
@@ -673,6 +673,9 @@ export function IconFileOpenOutline(props) {
|
|
|
673
673
|
export function IconArchiveDetail(props) {
|
|
674
674
|
return (_jsxs("svg", { fontSize: props.fontSize ?? FONTSIZE, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", ...props, children: [" ", _jsx("path", { fill: "currentColor", d: "m20.54 5.23l-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27M12 17.5L6.5 12H10v-2h4v2h3.5zM5.12 5l.81-1h12l.94 1z" }), " "] }));
|
|
675
675
|
}
|
|
676
|
+
export function IconArchiveMultipleDetailDocuments(props) {
|
|
677
|
+
return (_jsxs("svg", { fontSize: props.fontSize ?? FONTSIZE, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", width: "1em", height: "1em", ...props, children: [_jsx("path", { fill: "currentColor", d: "M40,35v5H8v-5H4v5c0,2.2,1.8,4,4,4h32c2.2,0,4-1.8,4-4v-5H40z" }), _jsxs("g", { fill: "currentColor", children: [_jsx("polygon", { points: "24,23.4 17,15 31,15" }), _jsx("rect", { x: "22", y: "4", width: "4", height: "14" }), _jsx("path", { d: "M31.5,26.9L30.8,28l3.5,1.9l0.6-1.2c1.6-3,2.6-4.7,3.5-5.2C39.3,23,41,23,44,23v-4C36.3,19,35.6,19.4,31.5,26.9z" }), _jsx("polygon", { points: "38.4,31 29.4,35 28,25" }), _jsx("path", { d: "M16.5,26.9l0.6,1.2L13.6,30L13,28.8c-1.6-3-2.6-4.7-3.5-5.2C8.7,23,7,23,4,23v-4C11.7,19,12.4,19.4,16.5,26.9z" }), _jsx("polygon", { points: "20,25 18.6,35 9.6,31" })] })] }));
|
|
678
|
+
}
|
|
676
679
|
export function IconArchiveMaster(props) {
|
|
677
680
|
return (_jsxs("svg", { fontSize: props.fontSize ?? FONTSIZE, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", ...props, children: [" ", _jsx("path", { fill: "currentColor", d: "m20.55 5.22l-1.39-1.68A1.51 1.51 0 0 0 18 3H6c-.47 0-.88.21-1.15.55L3.46 5.22C3.17 5.57 3 6.01 3 6.5V19a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V6.5c0-.49-.17-.93-.45-1.28M12 9.5l5.5 5.5H14v2h-4v-2H6.5zM5.12 5l.82-1h12l.93 1z" }), " "] }));
|
|
678
681
|
}
|
package/lib/helper/TMUtils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FileItem } from '../components';
|
|
3
|
-
import { AppModules, DataColumnDescriptor, DcmtTypeDescriptor, MetadataDescriptor, PdGs, SearchResultDescriptor } from '@topconsultnpm/sdk-ts';
|
|
3
|
+
import { AppModules, DataColumnDescriptor, DcmtTypeDescriptor, MetadataDescriptor, MetadataFormats, PdGs, SearchResultDescriptor } from '@topconsultnpm/sdk-ts';
|
|
4
4
|
/**
|
|
5
5
|
* Estensioni di firma/marca temporale note che possono avvolgere altre estensioni.
|
|
6
6
|
* Es: file.pdf.p7m, file.xml.p7m, file.docx.p7m, file.xml.p7m.ts
|
|
@@ -42,22 +42,41 @@ export declare const isCreateCertificateEnabled: (widgetsString: string) => bool
|
|
|
42
42
|
export declare const isPdfEditorEnabled: (widgetsString: string) => boolean;
|
|
43
43
|
/** Verifica se l'editor PDF è disponibile: richiede file PDF, licenza attiva e widget abilitato sul tipo documento. */
|
|
44
44
|
export declare const isPdfEditorAvailable: (fromDTD: DcmtTypeDescriptor | undefined, ext: string | undefined) => boolean;
|
|
45
|
+
/** Verifica se il tipo documento è quello delle bozze dei gruppi di lavoro. */
|
|
46
|
+
export declare const isDraftsDTD: (dtd: DcmtTypeDescriptor | undefined) => boolean;
|
|
47
|
+
/** Verifica se il tipo documento non è autorizzato per l'utente corrente. */
|
|
48
|
+
export declare const isNotGrantedDTD: (dtd: DcmtTypeDescriptor | undefined) => boolean;
|
|
49
|
+
/** Verifica se il tipo documento è quello delle bozze dei gruppi di lavoro non autorizzato, e quindi privo di permessi. */
|
|
50
|
+
export declare const isNotGrantedDraftsDTD: (dtd: DcmtTypeDescriptor | undefined) => boolean;
|
|
45
51
|
interface TabItemProps {
|
|
46
52
|
$isSelected: boolean;
|
|
47
53
|
$activeGradient?: string;
|
|
48
54
|
}
|
|
49
|
-
export declare const StyledTabItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
export declare const StyledTabItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
56
|
+
style?: React.CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
57
|
+
}, TabItemProps>> & string;
|
|
58
|
+
export declare const StyledTabIcon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "style"> & {
|
|
59
|
+
style?: React.CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
60
|
+
}, TabItemProps>> & string;
|
|
61
|
+
export declare const TMCountBadge: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
62
|
+
style?: React.CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
63
|
+
}> & string;
|
|
52
64
|
export declare const PDGS_COLORS: {
|
|
53
65
|
DOSSIER: string;
|
|
54
66
|
DOCUMENT: string;
|
|
55
67
|
WORKING_GROUP: string;
|
|
68
|
+
/** Istanza di CaseFlow: viola, per non confonderla ne' con la pratica (arancio) ne' con il gruppo di lavoro (verde). */
|
|
69
|
+
CASEFLOW: string;
|
|
56
70
|
};
|
|
57
71
|
export declare const getPdgsIconMap: (fontSize?: number) => Map<PdGs, JSX.Element>;
|
|
58
72
|
export declare const convertSearchResultDescriptorToFileItems: (documents: Array<SearchResultDescriptor>) => Array<FileItem>;
|
|
59
73
|
export declare const getAppModuleGradient: (appModuleID: AppModules) => string;
|
|
60
74
|
export declare const getPanelManagerToolbarColor: (appModuleID: AppModules) => string;
|
|
75
|
+
export declare const getAppModuleButtonColors: (appModuleID: AppModules) => {
|
|
76
|
+
base: string;
|
|
77
|
+
hover: string;
|
|
78
|
+
shadow: string;
|
|
79
|
+
};
|
|
61
80
|
export declare const getFileManagerFolderColor: (appModuleID: AppModules) => string;
|
|
62
81
|
type SearchToolbarVisibility = {
|
|
63
82
|
tmSearchResult: boolean;
|
|
@@ -109,4 +128,32 @@ export declare enum DcmtDisplayNameMethod {
|
|
|
109
128
|
* Se i metadati non sono presenti nel dtd, li recupera dalla cache.
|
|
110
129
|
*/
|
|
111
130
|
export declare const getDTDDisplayNameInfo: (dtd: DcmtTypeDescriptor | undefined) => Promise<string>;
|
|
131
|
+
export declare const getCurrencySymbol: (format: MetadataFormats | undefined) => string | undefined;
|
|
132
|
+
/** Estrae Format e FormatCulture dalle proprietà estese di una colonna. */
|
|
133
|
+
export declare const getColumnFormatInfo: (col: DataColumnDescriptor) => {
|
|
134
|
+
format: MetadataFormats;
|
|
135
|
+
formatCulture: string;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Restituisce il pattern di formato DevExtreme per DateBox basato su MetadataFormats e cultura.
|
|
139
|
+
* Usa la stessa logica di formatDateTimeByMetadataFormat per garantire coerenza.
|
|
140
|
+
* Supporta: IT (it-IT), GB (en-GB), US (en-US), JP (ja-JP)
|
|
141
|
+
*/
|
|
142
|
+
export declare const getDevExtremeDateDisplayFormat: (format: MetadataFormats | undefined, formatCulture?: string) => string;
|
|
143
|
+
/** Formatta una data secondo MetadataFormats e cultura. */
|
|
144
|
+
export declare const formatDateTimeByMetadataFormat: (value: Date, format: MetadataFormats | undefined, formatCulture: string | undefined | null) => string;
|
|
145
|
+
/** Formatta un numero secondo MetadataFormats e cultura. Valute con simbolo e 2 decimali (0 per Yen). */
|
|
146
|
+
export declare const formatNumberByMetadataFormat: (value: number | string, format: MetadataFormats | undefined, formatCulture: string) => string;
|
|
147
|
+
/** Converte un valore in data locale. Restituisce il valore originale se il parsing fallisce. */
|
|
148
|
+
export declare const safeParseDateToLocaleString: (value: any) => string;
|
|
149
|
+
/**
|
|
150
|
+
* Trova un DataColumnDescriptor corrispondente a un dataField (formato TID_MID).
|
|
151
|
+
* Cerca prima per MID nelle extendedProperties, poi per caption.
|
|
152
|
+
*/
|
|
153
|
+
export declare const findDataColumnByField: (columns: DataColumnDescriptor[], dataField: string | undefined, caption?: string) => DataColumnDescriptor | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Formatta un valore per l'export in base al tipo di colonna.
|
|
156
|
+
* Gestisce date, numeri e valute secondo il formato definito nella colonna.
|
|
157
|
+
*/
|
|
158
|
+
export declare const formatValueForExport: (value: any, dataCol: DataColumnDescriptor | undefined, fallbackDataType?: string) => string;
|
|
112
159
|
export {};
|
package/lib/helper/TMUtils.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import { TMTooltip } from '../components';
|
|
4
4
|
import { IconCADossier, IconKey, IconMenuCAWorkingGroups } from './TMIcons';
|
|
5
|
-
import { AccessLevels, AppModules, DataListCacheService, DcmtTypeListCacheService, LicenseModuleStatus, MetadataDataDomains, PdGs, SDK_Globals, SystemMIDs } from '@topconsultnpm/sdk-ts';
|
|
5
|
+
import { AccessLevels, AppModules, DataColumnTypes, DataListCacheService, DcmtTypeListCacheService, LicenseModuleStatus, MetadataDataDomains, MetadataFormats, PdGs, SDK_Globals, SystemMIDs, SystemTIDs } from '@topconsultnpm/sdk-ts';
|
|
6
6
|
import { SDKUI_Localizator } from './SDKUI_Localizator';
|
|
7
7
|
/**
|
|
8
8
|
* Estensioni di firma/marca temporale note che possono avvolgere altre estensioni.
|
|
@@ -242,6 +242,14 @@ export const isPdfEditorAvailable = (fromDTD, ext) => {
|
|
|
242
242
|
const isPdfEditorLicensed = SDK_Globals?.license?.dcmtArchiveLicenses?.[0]?.siX_60007?.status === LicenseModuleStatus.Licensed;
|
|
243
243
|
return isPdfEditorLicensed && isPdfEditorEnabled(fromDTD.widgets);
|
|
244
244
|
};
|
|
245
|
+
/** Valore di customData2 con cui il server marca i tipi documento non autorizzati per l'utente corrente. */
|
|
246
|
+
const NOT_GRANTED_DTD = 'NOTGRANTED';
|
|
247
|
+
/** Verifica se il tipo documento è quello delle bozze dei gruppi di lavoro. */
|
|
248
|
+
export const isDraftsDTD = (dtd) => dtd?.id === SystemTIDs.Drafts;
|
|
249
|
+
/** Verifica se il tipo documento non è autorizzato per l'utente corrente. */
|
|
250
|
+
export const isNotGrantedDTD = (dtd) => dtd?.customData2 === NOT_GRANTED_DTD;
|
|
251
|
+
/** Verifica se il tipo documento è quello delle bozze dei gruppi di lavoro non autorizzato, e quindi privo di permessi. */
|
|
252
|
+
export const isNotGrantedDraftsDTD = (dtd) => !!dtd && !dtd.perm && isDraftsDTD(dtd) && isNotGrantedDTD(dtd);
|
|
245
253
|
export const StyledTabItem = styled.div `
|
|
246
254
|
display: flex;
|
|
247
255
|
align-items: center;
|
|
@@ -270,6 +278,8 @@ export const PDGS_COLORS = {
|
|
|
270
278
|
DOSSIER: '#e65b00',
|
|
271
279
|
DOCUMENT: '#b38600',
|
|
272
280
|
WORKING_GROUP: '#009700',
|
|
281
|
+
/** Istanza di CaseFlow: viola, per non confonderla ne' con la pratica (arancio) ne' con il gruppo di lavoro (verde). */
|
|
282
|
+
CASEFLOW: '#6a3fb5',
|
|
273
283
|
};
|
|
274
284
|
export const getPdgsIconMap = (fontSize = 20) => {
|
|
275
285
|
return new Map([
|
|
@@ -336,7 +346,7 @@ export const getAppModuleGradient = (appModuleID) => {
|
|
|
336
346
|
case AppModules.SURFER:
|
|
337
347
|
return 'linear-gradient(270deg, #46B5A2 16%, #3BAABC 34%, #3BAABC 34%, #3681AD 54%, #3368A5 72%, #2F549D 88%, #304F99 100%)';
|
|
338
348
|
case AppModules.DESIGNER:
|
|
339
|
-
return 'linear-gradient(270deg, #A06A8E 16%, #885C77 34%, #6F4C5F 54%, #5A3446 72%, #482234 100%)
|
|
349
|
+
return 'linear-gradient(270deg, #A06A8E 16%, #885C77 34%, #6F4C5F 54%, #5A3446 72%, #482234 100%)';
|
|
340
350
|
case AppModules.ORCHESTRATOR:
|
|
341
351
|
return 'linear-gradient(270deg, #46B5A2 16%, #3BAA8A 34%, #2F8F6F 54%, #277A5A 72%, #216948 88%, #1d6f42 100%)';
|
|
342
352
|
default:
|
|
@@ -355,6 +365,18 @@ export const getPanelManagerToolbarColor = (appModuleID) => {
|
|
|
355
365
|
return 'transparent linear-gradient(90deg, #CCE0F4 0%, #7EC1E7 14%, #39A6DB 28%, #1E9CD7 35%, #0075BE 78%, #005B97 99%) 0% 0% no-repeat padding-box';
|
|
356
366
|
}
|
|
357
367
|
};
|
|
368
|
+
export const getAppModuleButtonColors = (appModuleID) => {
|
|
369
|
+
switch (appModuleID) {
|
|
370
|
+
case AppModules.SURFER:
|
|
371
|
+
return { base: '#2559a5', hover: '#1c4783', shadow: 'rgba(37, 89, 165, 0.35)' };
|
|
372
|
+
case AppModules.DESIGNER:
|
|
373
|
+
return { base: '#482234', hover: '#351826', shadow: 'rgba(72, 34, 52, 0.35)' };
|
|
374
|
+
case AppModules.ORCHESTRATOR:
|
|
375
|
+
return { base: '#1d6f42', hover: '#15532f', shadow: 'rgba(29, 111, 66, 0.35)' };
|
|
376
|
+
default:
|
|
377
|
+
return { base: '#2559a5', hover: '#1c4783', shadow: 'rgba(37, 89, 165, 0.35)' };
|
|
378
|
+
}
|
|
379
|
+
};
|
|
358
380
|
export const getFileManagerFolderColor = (appModuleID) => {
|
|
359
381
|
switch (appModuleID) {
|
|
360
382
|
case AppModules.SURFER:
|
|
@@ -439,16 +461,10 @@ export const buildDcmtDisplayName = (obj) => {
|
|
|
439
461
|
if (!obj)
|
|
440
462
|
return [];
|
|
441
463
|
const sysAbstractKey = Object.keys(obj).find(k => k.toUpperCase() === 'SYS_ABSTRACT');
|
|
442
|
-
if (sysAbstractKey) {
|
|
443
|
-
|
|
444
|
-
return [sysAbstractKey];
|
|
445
|
-
}
|
|
446
|
-
// SYS_Abstract esiste ma è vuoto: usa DID se presente, altrimenti continua con la logica standard
|
|
447
|
-
const didKey = Object.keys(obj).find(k => k.toUpperCase() === 'DID');
|
|
448
|
-
if (didKey && obj[didKey]?.value) {
|
|
449
|
-
return [didKey];
|
|
450
|
-
}
|
|
464
|
+
if (sysAbstractKey && obj[sysAbstractKey]?.value) {
|
|
465
|
+
return [sysAbstractKey];
|
|
451
466
|
}
|
|
467
|
+
// SYS_Abstract esiste ma è vuoto: continua con la logica standard
|
|
452
468
|
const keys = Object.keys(obj);
|
|
453
469
|
const sysMIDs = Object.values(SystemMIDs).map(o => o.toUpperCase());
|
|
454
470
|
const viewableMetadataKeys = keys.filter(k => obj?.[k]?.value &&
|
|
@@ -461,6 +477,7 @@ export const buildDcmtDisplayName = (obj) => {
|
|
|
461
477
|
if (specialOutputKeys.length > 0) {
|
|
462
478
|
return specialOutputKeys;
|
|
463
479
|
}
|
|
480
|
+
// Se non ci sono metadati speciali, restituisci i primi 5 metadati non di sistema con permesso canView
|
|
464
481
|
if (viewableMetadataKeys.length > 0) {
|
|
465
482
|
return viewableMetadataKeys.slice(0, 5);
|
|
466
483
|
}
|
|
@@ -533,3 +550,247 @@ export const getDTDDisplayNameInfo = async (dtd) => {
|
|
|
533
550
|
return SDKUI_Localizator.DisplayNameMethod_Top5;
|
|
534
551
|
}
|
|
535
552
|
};
|
|
553
|
+
export const getCurrencySymbol = (format) => {
|
|
554
|
+
switch (format) {
|
|
555
|
+
case MetadataFormats.CurrencyEuro: return '€';
|
|
556
|
+
case MetadataFormats.CurrencyDollar: return '$';
|
|
557
|
+
case MetadataFormats.CurrencyPound: return '£';
|
|
558
|
+
case MetadataFormats.CurrencyYen: return '¥';
|
|
559
|
+
default: return undefined;
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
/** Estrae Format e FormatCulture dalle proprietà estese di una colonna. */
|
|
563
|
+
export const getColumnFormatInfo = (col) => {
|
|
564
|
+
const format = MetadataFormats[(col.extendedProperties?.["Format"] ?? "None")];
|
|
565
|
+
const formatCulture = col.extendedProperties?.["FormatCulture"] ?? window.navigator.language;
|
|
566
|
+
return { format, formatCulture };
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* Restituisce il pattern di formato DevExtreme per DateBox basato su MetadataFormats e cultura.
|
|
570
|
+
* Usa la stessa logica di formatDateTimeByMetadataFormat per garantire coerenza.
|
|
571
|
+
* Supporta: IT (it-IT), GB (en-GB), US (en-US), JP (ja-JP)
|
|
572
|
+
*/
|
|
573
|
+
export const getDevExtremeDateDisplayFormat = (format, formatCulture) => {
|
|
574
|
+
try {
|
|
575
|
+
const culture = (formatCulture ?? window.navigator.language).toLowerCase();
|
|
576
|
+
const isItalian = culture === 'it-it' || culture.startsWith('it');
|
|
577
|
+
const isUS = culture === 'en-us';
|
|
578
|
+
const isGB = culture === 'en-gb';
|
|
579
|
+
const isJP = culture === 'ja-jp' || culture.startsWith('ja');
|
|
580
|
+
// Formati data base per cultura (coerenti con formatDateTimeByMetadataFormat)
|
|
581
|
+
const getShortDate = () => {
|
|
582
|
+
if (isItalian)
|
|
583
|
+
return 'dd/MM/yyyy'; // 17/07/2026
|
|
584
|
+
if (isUS)
|
|
585
|
+
return 'M/d/yyyy'; // 7/17/2026
|
|
586
|
+
if (isGB)
|
|
587
|
+
return 'dd/MM/yyyy'; // 17/07/2026
|
|
588
|
+
if (isJP)
|
|
589
|
+
return 'yyyy/MM/dd'; // 2026/07/17
|
|
590
|
+
return 'dd/MM/yyyy'; // default
|
|
591
|
+
};
|
|
592
|
+
const getLongDate = () => {
|
|
593
|
+
if (isItalian)
|
|
594
|
+
return 'EEEE d MMMM yyyy'; // lunedì 17 luglio 2026
|
|
595
|
+
if (isUS)
|
|
596
|
+
return 'EEEE, MMMM d, yyyy'; // Monday, July 17, 2026
|
|
597
|
+
if (isGB)
|
|
598
|
+
return 'd MMMM yyyy'; // 17 July 2026 (senza weekday)
|
|
599
|
+
if (isJP)
|
|
600
|
+
return 'yyyy年M月d日'; // 2026年7月17日 (senza weekday)
|
|
601
|
+
return 'd MMMM yyyy'; // default (senza weekday)
|
|
602
|
+
};
|
|
603
|
+
// Formati ora per cultura (US usa 12h con AM/PM, altri usano 24h)
|
|
604
|
+
const getShortTime = () => {
|
|
605
|
+
if (isUS)
|
|
606
|
+
return 'h:mm a'; // 3:30 PM
|
|
607
|
+
return 'HH:mm'; // 15:30
|
|
608
|
+
};
|
|
609
|
+
const getLongTime = () => {
|
|
610
|
+
if (isUS)
|
|
611
|
+
return 'h:mm:ss a'; // 3:30:45 PM
|
|
612
|
+
return 'HH:mm:ss'; // 15:30:45
|
|
613
|
+
};
|
|
614
|
+
const shortDate = getShortDate();
|
|
615
|
+
const longDate = getLongDate();
|
|
616
|
+
const shortTime = getShortTime();
|
|
617
|
+
const longTime = getLongTime();
|
|
618
|
+
switch (format) {
|
|
619
|
+
case MetadataFormats.ShortDate:
|
|
620
|
+
return shortDate;
|
|
621
|
+
case MetadataFormats.LongDate:
|
|
622
|
+
return longDate;
|
|
623
|
+
case MetadataFormats.ShortTime:
|
|
624
|
+
return shortTime;
|
|
625
|
+
case MetadataFormats.LongTime:
|
|
626
|
+
return longTime;
|
|
627
|
+
case MetadataFormats.ShortDateShortTime:
|
|
628
|
+
return `${shortDate} ${shortTime}`;
|
|
629
|
+
case MetadataFormats.ShortDateLongTime:
|
|
630
|
+
return `${shortDate} ${longTime}`;
|
|
631
|
+
case MetadataFormats.LongDateShortTime:
|
|
632
|
+
return `${longDate} ${shortTime}`;
|
|
633
|
+
case MetadataFormats.LongDateLongTime:
|
|
634
|
+
return `${longDate} ${longTime}`;
|
|
635
|
+
default:
|
|
636
|
+
return shortDate;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
catch {
|
|
640
|
+
// Fallback: restituisce formato data breve di default
|
|
641
|
+
return 'dd/MM/yyyy';
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
/** Formatta una data secondo MetadataFormats e cultura. */
|
|
645
|
+
export const formatDateTimeByMetadataFormat = (value, format, formatCulture) => {
|
|
646
|
+
try {
|
|
647
|
+
// Fallback sicuro per formatCulture
|
|
648
|
+
const safeCulture = (formatCulture && typeof formatCulture === 'string' && formatCulture.trim()) ? formatCulture.trim() : window.navigator.language;
|
|
649
|
+
const culture = safeCulture.toLowerCase();
|
|
650
|
+
// Culture che includono il giorno della settimana nei formati lunghi
|
|
651
|
+
const includeWeekday = culture === 'it-it' || culture === 'en-us';
|
|
652
|
+
// Opzioni per data lunga (con o senza giorno settimana)
|
|
653
|
+
const longDateOptions = includeWeekday
|
|
654
|
+
? { weekday: "long", year: "numeric", month: "long", day: "numeric" }
|
|
655
|
+
: { year: "numeric", month: "long", day: "numeric" };
|
|
656
|
+
// Opzioni ShortDate: IT usa dd/MM/yyyy, US usa M/d/yyyy (anno a 4 cifre), altri usano dateStyle: 'short'
|
|
657
|
+
const getShortDateOptions = () => {
|
|
658
|
+
if (culture === "it-it")
|
|
659
|
+
return { year: "numeric", month: "2-digit", day: "2-digit" };
|
|
660
|
+
if (culture === "en-us")
|
|
661
|
+
return { year: "numeric", month: "numeric", day: "numeric" };
|
|
662
|
+
return { dateStyle: 'short' };
|
|
663
|
+
};
|
|
664
|
+
switch (format) {
|
|
665
|
+
case MetadataFormats.ShortDate:
|
|
666
|
+
return value.toLocaleString(safeCulture, getShortDateOptions());
|
|
667
|
+
case MetadataFormats.ShortTime:
|
|
668
|
+
return value.toLocaleString(safeCulture, { timeStyle: 'short' });
|
|
669
|
+
case MetadataFormats.ShortDateLongTime:
|
|
670
|
+
if (culture === "it-it")
|
|
671
|
+
return value.toLocaleString(safeCulture, { year: "numeric", month: "2-digit", day: "2-digit", hour: '2-digit', minute: '2-digit', second: '2-digit' }).replace(',', '');
|
|
672
|
+
if (culture === "en-us")
|
|
673
|
+
return value.toLocaleString(safeCulture, { year: "numeric", month: "numeric", day: "numeric", hour: 'numeric', minute: '2-digit', second: '2-digit' }).replace(',', '');
|
|
674
|
+
return value.toLocaleString(safeCulture, { dateStyle: 'short', timeStyle: 'medium' }).replace(',', '');
|
|
675
|
+
case MetadataFormats.ShortDateShortTime:
|
|
676
|
+
if (culture === "it-it")
|
|
677
|
+
return value.toLocaleString(safeCulture, { year: "numeric", month: "2-digit", day: "2-digit", hour: '2-digit', minute: '2-digit' }).replace(',', '');
|
|
678
|
+
if (culture === "en-us")
|
|
679
|
+
return value.toLocaleString(safeCulture, { year: "numeric", month: "numeric", day: "numeric", hour: 'numeric', minute: '2-digit' }).replace(',', '');
|
|
680
|
+
return value.toLocaleString(safeCulture, { dateStyle: 'short', timeStyle: 'short' }).replace(',', '');
|
|
681
|
+
case MetadataFormats.LongDate:
|
|
682
|
+
return value.toLocaleString(safeCulture, longDateOptions);
|
|
683
|
+
case MetadataFormats.LongTime:
|
|
684
|
+
return value.toLocaleString(safeCulture, { timeStyle: 'medium' });
|
|
685
|
+
case MetadataFormats.LongDateLongTime: {
|
|
686
|
+
const datePart = value.toLocaleString(safeCulture, longDateOptions);
|
|
687
|
+
const timePart = value.toLocaleString(safeCulture, culture === "en-us" ? { hour: 'numeric', minute: '2-digit', second: '2-digit' } : { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
|
688
|
+
return `${datePart} ${timePart}`;
|
|
689
|
+
}
|
|
690
|
+
case MetadataFormats.LongDateShortTime: {
|
|
691
|
+
const datePart = value.toLocaleString(safeCulture, longDateOptions);
|
|
692
|
+
const timePart = value.toLocaleString(safeCulture, culture === "en-us" ? { hour: 'numeric', minute: '2-digit' } : { hour: '2-digit', minute: '2-digit' });
|
|
693
|
+
return `${datePart} ${timePart}`;
|
|
694
|
+
}
|
|
695
|
+
default:
|
|
696
|
+
return value.toLocaleString(safeCulture, getShortDateOptions());
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
catch {
|
|
700
|
+
// Fallback: restituisce la data in formato ISO se la conversione fallisce
|
|
701
|
+
return value?.toISOString?.() ?? String(value);
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
/** Formatta un numero secondo MetadataFormats e cultura. Valute con simbolo e 2 decimali (0 per Yen). */
|
|
705
|
+
export const formatNumberByMetadataFormat = (value, format, formatCulture) => {
|
|
706
|
+
try {
|
|
707
|
+
const numValue = typeof value === 'number' ? value : Number(value);
|
|
708
|
+
if (isNaN(numValue))
|
|
709
|
+
return String(value);
|
|
710
|
+
const currencySymbol = getCurrencySymbol(format);
|
|
711
|
+
if (currencySymbol) {
|
|
712
|
+
const decimals = format === MetadataFormats.CurrencyYen ? 0 : 2;
|
|
713
|
+
return `${currencySymbol} ${numValue.toLocaleString(formatCulture, { useGrouping: true, minimumFractionDigits: decimals, maximumFractionDigits: decimals })}`;
|
|
714
|
+
}
|
|
715
|
+
return numValue.toLocaleString(formatCulture, { useGrouping: format == MetadataFormats.NumberWithThousandsSeparator });
|
|
716
|
+
}
|
|
717
|
+
catch {
|
|
718
|
+
// Fallback: restituisce il valore come stringa se la conversione fallisce
|
|
719
|
+
return String(value);
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
/** Converte un valore in data locale. Restituisce il valore originale se il parsing fallisce. */
|
|
723
|
+
export const safeParseDateToLocaleString = (value) => {
|
|
724
|
+
try {
|
|
725
|
+
if (!value)
|
|
726
|
+
return value ?? '';
|
|
727
|
+
const parsedDate = new Date(value);
|
|
728
|
+
if (!isNaN(parsedDate.getTime())) {
|
|
729
|
+
return parsedDate.toLocaleDateString();
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
catch {
|
|
733
|
+
// Keep original value if parsing fails
|
|
734
|
+
}
|
|
735
|
+
return String(value ?? '');
|
|
736
|
+
};
|
|
737
|
+
/**
|
|
738
|
+
* Trova un DataColumnDescriptor corrispondente a un dataField (formato TID_MID).
|
|
739
|
+
* Cerca prima per MID nelle extendedProperties, poi per caption.
|
|
740
|
+
*/
|
|
741
|
+
export const findDataColumnByField = (columns, dataField, caption) => {
|
|
742
|
+
// Se l'array di colonne è vuoto/null o il dataField non è definito, ritorna undefined (nessuna corrispondenza possibile)
|
|
743
|
+
if (!columns || !dataField)
|
|
744
|
+
return undefined;
|
|
745
|
+
// Itera sulle colonne cercando la prima che soddisfa i criteri di matching
|
|
746
|
+
return columns.find(c => {
|
|
747
|
+
// Estrae il MID (Metadata ID) dalle proprietà estese della colonna corrente
|
|
748
|
+
const colMid = c.extendedProperties?.["MID"];
|
|
749
|
+
// Se la colonna ha un MID definito, prova a matchare per MID
|
|
750
|
+
if (colMid) {
|
|
751
|
+
// Converte il MID in stringa per il confronto
|
|
752
|
+
const midStr = String(colMid);
|
|
753
|
+
// Verifica se dataField termina con "_MID" (es: "123_456" dove 456 è il MID)
|
|
754
|
+
// oppure se dataField è esattamente uguale al MID (caso in cui dataField contiene solo il MID)
|
|
755
|
+
if (dataField.endsWith(`_${midStr}`) || dataField === midStr)
|
|
756
|
+
return true;
|
|
757
|
+
}
|
|
758
|
+
// Fallback: se il match per MID fallisce, prova a matchare per caption
|
|
759
|
+
// Confronta la caption della colonna con dataField o con il parametro caption opzionale
|
|
760
|
+
return c.caption === dataField || c.caption === caption;
|
|
761
|
+
});
|
|
762
|
+
};
|
|
763
|
+
/**
|
|
764
|
+
* Formatta un valore per l'export in base al tipo di colonna.
|
|
765
|
+
* Gestisce date, numeri e valute secondo il formato definito nella colonna.
|
|
766
|
+
*/
|
|
767
|
+
export const formatValueForExport = (value, dataCol, fallbackDataType) => {
|
|
768
|
+
try {
|
|
769
|
+
let result = value;
|
|
770
|
+
if (dataCol) {
|
|
771
|
+
const { format, formatCulture } = getColumnFormatInfo(dataCol);
|
|
772
|
+
// Date: il valore arriva come stringa e va prima convertito in Date
|
|
773
|
+
if (dataCol.dataType === DataColumnTypes.DateTime && result) {
|
|
774
|
+
const parsedDate = new Date(result);
|
|
775
|
+
if (!isNaN(parsedDate.getTime())) {
|
|
776
|
+
result = formatDateTimeByMetadataFormat(parsedDate, format, formatCulture);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
// Numeri (incluse valute)
|
|
780
|
+
if (dataCol.dataType === DataColumnTypes.Number && result !== null && result !== undefined && result !== '') {
|
|
781
|
+
result = formatNumberByMetadataFormat(result, format, formatCulture);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
// Fallback: formattazione base per date
|
|
786
|
+
if (fallbackDataType === 'datetime' && result) {
|
|
787
|
+
result = safeParseDateToLocaleString(result);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
// Pulisci il valore: rimuovi doppi apici per evitare problemi CSV
|
|
791
|
+
return (result ?? '').toString().replace(/"/g, '');
|
|
792
|
+
}
|
|
793
|
+
catch {
|
|
794
|
+
return String(value ?? '');
|
|
795
|
+
}
|
|
796
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MetadataFormats } from '@topconsultnpm/sdk-ts';
|
|
2
|
+
/** Testo mostrato in una colonna per una riga: è quello su cui va cercato ciò che l'utente digita */
|
|
3
|
+
export type SearchTextGetter = (rowData: any) => string;
|
|
4
|
+
/** Testo con cui una data viene mostrata nella griglia: è quello che l'utente vede e quindi quello che cerca */
|
|
5
|
+
export declare const getDateDisplayText: (value: any, format: MetadataFormats | undefined, formatCulture: string | undefined | null) => string;
|
|
6
|
+
/** Testo con cui un numero viene mostrato nella griglia (separatore delle migliaia, valuta, decimali) */
|
|
7
|
+
export declare const getNumberDisplayText: (value: any, format: MetadataFormats | undefined, formatCulture: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Dirotta la ricerca della griglia sul testo mostrato, per le colonne indicate (chiave: il `dataField`).
|
|
10
|
+
*
|
|
11
|
+
* La ricerca di DevExtreme lavora sul valore archiviato, quindi non trova nulla dove il testo mostrato è
|
|
12
|
+
* diverso:
|
|
13
|
+
* - **date**, che nei dati sono stringhe ISO: DevExtreme prova a interpretare il testo digitato con il
|
|
14
|
+
* formato della colonna, non riesce (il formato è un formatter personalizzato, non un pattern) e scarta
|
|
15
|
+
* la colonna dalla ricerca — cercando `29/01/2023` non trova nulla;
|
|
16
|
+
* - **numeri formattati**, per lo stesso motivo (separatore delle migliaia, simbolo di valuta);
|
|
17
|
+
* - **liste dati e utenti**, dove viene confrontata la chiave archiviata invece della descrizione
|
|
18
|
+
* visualizzata — cercando `FATTURA` non trova nulla, cercando `TD01` sì.
|
|
19
|
+
*
|
|
20
|
+
* Da passare a `customizeColumns` della griglia. Va fatto lì perché solo lì è disponibile la
|
|
21
|
+
* `calculateFilterExpression` predefinita di DevExtreme, che resta in uso per il filtro di intestazione e
|
|
22
|
+
* per il generatore di filtri: quelli funzionano già correttamente e vanno lasciati intatti.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const searchTextGetters = useMemo(() => new Map([['TM_1_2', (row) => getDateDisplayText(row?.TM_1_2, format, culture)]]), [...]);
|
|
26
|
+
* const customizeColumns = useMemo(() => customizeSearchByDisplayText(searchTextGetters), [searchTextGetters]);
|
|
27
|
+
*/
|
|
28
|
+
export declare const customizeSearchByDisplayText: (searchTextGetters: Map<string, SearchTextGetter>) => (columns: Array<any>) => void;
|