@topconsultnpm/sdkui-react-beta 6.6.31 → 6.6.33
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,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { MetadataDescriptor, QueryDescriptor, ValidationItem } from '@topconsultnpm/sdk-ts-beta';
|
|
3
3
|
import { ITMChooserFormProps, ITMChooserProps, TID_MID } from '../../ts';
|
|
4
4
|
import { TID_Alias } from '../../helper/queryHelper';
|
|
5
5
|
interface ITMMetadataChooserProps extends ITMChooserProps {
|
|
@@ -7,8 +7,6 @@ interface ITMMetadataChooserProps extends ITMChooserProps {
|
|
|
7
7
|
allowSysMetadata?: boolean;
|
|
8
8
|
/** TIDs dei tipi documento da cui recuperare i metadati */
|
|
9
9
|
tids?: number[];
|
|
10
|
-
/** Lista dei tipi documento da cui recuperare i metadati */
|
|
11
|
-
inputDcmtTypesList?: DcmtTypeDescriptor[];
|
|
12
10
|
/** Qd da cui recuperare i metadati */
|
|
13
11
|
qd?: QueryDescriptor;
|
|
14
12
|
/** Contiene i TID / MID selezionati */
|
|
@@ -17,6 +15,8 @@ interface ITMMetadataChooserProps extends ITMChooserProps {
|
|
|
17
15
|
showCompleteMetadataName?: boolean;
|
|
18
16
|
/** Se input è qd, visualizza solo i metadati presenti nella clausola Select */
|
|
19
17
|
qdShowOnlySelectItems?: boolean;
|
|
18
|
+
/** predicate function per filtrare i metadati. Significativo per un solo tid (tids) */
|
|
19
|
+
filterMetadata?: (value: MetadataDescriptor, index: number, array: MetadataDescriptor[]) => unknown;
|
|
20
20
|
getColorIndex?: (tid: TID_Alias) => string;
|
|
21
21
|
showBorder?: boolean;
|
|
22
22
|
borderRadius?: string;
|
|
@@ -26,11 +26,12 @@ interface ITMMetadataChooserProps extends ITMChooserProps {
|
|
|
26
26
|
declare const TMMetadataChooser: React.FunctionComponent<ITMMetadataChooserProps>;
|
|
27
27
|
export default TMMetadataChooser;
|
|
28
28
|
interface ITMMetadataChooserFormProps extends ITMChooserFormProps<MetadataDescriptor> {
|
|
29
|
+
/** Consente di visualizzare anche i metadati di sistema */
|
|
29
30
|
allowSysMetadata?: boolean;
|
|
30
|
-
/** Lista dei tipi documento da cui recuperare i metadati */
|
|
31
|
-
inputDcmtTypesList?: DcmtTypeDescriptor[];
|
|
32
31
|
/** TIDs dei tipi documento da cui recuperare i metadati */
|
|
33
32
|
tids?: number[];
|
|
33
|
+
/** predicate function per filtrare i metadati. Significativo per un solo tid (tids) */
|
|
34
|
+
filterMetadata?: (value: MetadataDescriptor, index: number, array: MetadataDescriptor[]) => unknown;
|
|
34
35
|
/** Qd da cui recuperare i metadati */
|
|
35
36
|
qd?: QueryDescriptor;
|
|
36
37
|
/** Se input è qd, visualizza solo i metadati presenti nella clausola Select */
|
|
@@ -12,16 +12,16 @@ import TMButton from '../base/TMButton';
|
|
|
12
12
|
import TMSummary from '../editors/TMSummary';
|
|
13
13
|
import TMChooserForm from '../forms/TMChooserForm';
|
|
14
14
|
import TMSpinner from '../base/TMSpinner';
|
|
15
|
-
const TMMetadataChooser = ({ tmSession, dataSource, buttons = [],
|
|
15
|
+
const TMMetadataChooser = ({ tmSession, dataSource, buttons = [], disabled, validationItems, getColorIndex, showCompleteMetadataName, qdShowOnlySelectItems, borderRadius = '4px', fontSize = FontSize.defaultFontSize, backgroundColor, openEditorOnSummaryClick, showBorder = true, showId = false, elementStyle, allowMultipleSelection, allowSysMetadata, value, values, isModifiedWhen, tids, label, width, height, showClearButton, qd, placeHolder, filterMetadata, onValueChanged }) => {
|
|
16
16
|
const [showChooser, setShowChooser] = useState(false);
|
|
17
17
|
const renderTemplate = () => {
|
|
18
18
|
return (_jsxs(StyledDivHorizontal, { style: { width: 'max-content', height: '100%' }, children: [values && _jsx(TMMidViewer, { tmSession: tmSession, tid_mid: values[0], showIcon: true, showId: showId, showCompleteName: showCompleteMetadataName }), values && values.length > 1 && _jsx("p", { style: { marginLeft: '10px' }, children: `(+${values.length - 1} ${values.length == 2 ? 'altro' : 'altri'})` }), (values == undefined || values.length == 0) && _jsx("p", { children: placeHolder })] }));
|
|
19
19
|
};
|
|
20
20
|
return (_jsxs(_Fragment, { children: [_jsx(TMSummary, { label: label, width: width, height: showBorder ? height : '24px', validationItems: validationItems, backgroundColor: backgroundColor, buttons: buttons, placeHolder: placeHolder, fontSize: fontSize, showBorder: showBorder, borderRadius: borderRadius, hasValue: values && values.length > 0, showClearButton: showClearButton, iconEditButton: _jsx(IconSearch, { fontSize: 16 }), openEditorOnSummaryClick: openEditorOnSummaryClick, onEditorClick: () => !disabled && setShowChooser(true), elementStyle: elementStyle, isModifiedWhen: isModifiedWhen, template: renderTemplate(), onClearClick: showClearButton ? () => { onValueChanged?.([]); } : undefined }), showChooser &&
|
|
21
|
-
_jsx(TMMetadataChooserForm, { tmSession: tmSession, allowMultipleSelection: allowMultipleSelection, height: '500px', width: '600px', allowSysMetadata: allowSysMetadata, getColorIndex: getColorIndex, dataSource: dataSource,
|
|
21
|
+
_jsx(TMMetadataChooserForm, { tmSession: tmSession, allowMultipleSelection: allowMultipleSelection, height: '500px', width: '600px', allowSysMetadata: allowSysMetadata, getColorIndex: getColorIndex, dataSource: dataSource, tids: tids, qd: qd, qdShowOnlySelectItems: qdShowOnlySelectItems, filterMetadata: filterMetadata, selectedIDs: values, onClose: () => setShowChooser(false), onChoose: (tid_mids) => { onValueChanged?.(tid_mids); } })] }));
|
|
22
22
|
};
|
|
23
23
|
export default TMMetadataChooser;
|
|
24
|
-
export const TMMetadataChooserForm = ({ tmSession, tids,
|
|
24
|
+
export const TMMetadataChooserForm = ({ tmSession, tids, qd, filterMetadata, qdShowOnlySelectItems, selectedIDs, dataSource, allowMultipleSelection, allowSysMetadata = true, width, height, getColorIndex, onClose, onChoose }) => {
|
|
25
25
|
const [showSysMetadata, setShowSysMetadata] = useState(false);
|
|
26
26
|
const [hasSysMetadata, setHasSysMetadata] = useState(false);
|
|
27
27
|
const [dcmtTypes, setDcmtTypes] = useState([]);
|
|
@@ -59,16 +59,6 @@ export const TMMetadataChooserForm = ({ tmSession, tids, inputDcmtTypesList, qd,
|
|
|
59
59
|
dtdList.push(dtd);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
else if (inputDcmtTypesList) {
|
|
63
|
-
if (refreshCache)
|
|
64
|
-
onRefreshCache?.();
|
|
65
|
-
for (const dtd of inputDcmtTypesList) {
|
|
66
|
-
const newDtd = new DcmtTypeDescriptor();
|
|
67
|
-
newDtd.init({ ...dtd });
|
|
68
|
-
newDtd.metadata?.forEach((md) => { md.customData1 = newDtd.id; });
|
|
69
|
-
dtdList.push(newDtd);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
62
|
else if (tids) {
|
|
73
63
|
if (tids.length <= 0)
|
|
74
64
|
return [];
|
|
@@ -77,11 +67,12 @@ export const TMMetadataChooserForm = ({ tmSession, tids, inputDcmtTypesList, qd,
|
|
|
77
67
|
for (const tid of tids) {
|
|
78
68
|
if (!tid)
|
|
79
69
|
continue;
|
|
80
|
-
let dtd = await DcmtTypeListCacheService.GetAsync(tid, true, tmSession,
|
|
70
|
+
let dtd = await DcmtTypeListCacheService.GetAsync(tid, true, tmSession, true, refreshCache);
|
|
81
71
|
if (!dtd)
|
|
82
72
|
throw new Error(`TID sconosciuto (${tid})`);
|
|
83
|
-
dtd
|
|
84
|
-
|
|
73
|
+
let mds = filterMetadata ? dtd.metadata?.filter(filterMetadata) : dtd.metadata;
|
|
74
|
+
mds?.forEach((md) => { md.customData1 = dtd?.id; });
|
|
75
|
+
dtdList.push({ ...dtd, metadata: mds });
|
|
85
76
|
}
|
|
86
77
|
if (refreshCache)
|
|
87
78
|
TMSpinner.hide();
|
|
@@ -121,5 +112,5 @@ export const TMMetadataChooserForm = ({ tmSession, tids, inputDcmtTypesList, qd,
|
|
|
121
112
|
};
|
|
122
113
|
const convertID = (md) => { return { tid: md.customData1, mid: md.id, aliasTID: md.customData2 }; };
|
|
123
114
|
const customFilter = (items) => { return showSysMetadata ? items : items.filter(o => o.isSystem != 1); };
|
|
124
|
-
return (_jsx(TMChooserForm, { title: SDK_Localizator.Metadatas, allowMultipleSelection: allowMultipleSelection, allowSorting: false, allowGrouping: dcmtTypes.length > 1, width: width, height: height, selectedIDs: selectedIDs?.map((item) => item.mid), convertID: convertID, customFilter: customFilter, cellRenderIcon: cellRenderIcon, cellRenderNameAndDesc: (data) => { return _jsx("p", { style: { textAlign: 'left', color: data.data.isRequired == 1 ? 'red' : '' }, children: data.value }); }, dataSource: dataSource, getItems: getItems, customButtons: renderCustomButtons(), columns: renderDataGridColumns, summaryItems: renderSummaryItems,
|
|
115
|
+
return (_jsx(TMChooserForm, { title: SDK_Localizator.Metadatas, allowMultipleSelection: allowMultipleSelection, allowSorting: false, allowGrouping: dcmtTypes.length > 1, width: width, height: height, selectedIDs: selectedIDs?.map((item) => item.mid), convertID: convertID, customFilter: customFilter, cellRenderIcon: cellRenderIcon, cellRenderNameAndDesc: (data) => { return _jsx("p", { style: { textAlign: 'left', color: data.data.isRequired == 1 ? 'red' : '' }, children: data.value }); }, dataSource: dataSource, getItems: getItems, customButtons: renderCustomButtons(), columns: renderDataGridColumns, summaryItems: renderSummaryItems, onClose: onClose, onChoose: (IDs) => onChoose?.(IDs) }));
|
|
125
116
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ITMChooserFormProps } from '../../ts';
|
|
2
|
-
declare const TMChooserForm: <T>({ children, title, allowMultipleSelection, hasShowOnlySelectedItems, allowGrouping, allowSorting, width, height, dataSource, selectedIDs, manageUseLocalizedName, hasShowId, keyName, customButtons, showDefaultColumns, columns, summaryItems, convertID, customFilter, getItems, cellRenderIcon, cellRenderNameAndDesc, onChoose, onClose, onShowIdChanged
|
|
2
|
+
declare const TMChooserForm: <T>({ children, title, allowMultipleSelection, hasShowOnlySelectedItems, allowGrouping, allowSorting, width, height, dataSource, selectedIDs, manageUseLocalizedName, hasShowId, keyName, customButtons, showDefaultColumns, columns, summaryItems, convertID, customFilter, getItems, cellRenderIcon, cellRenderNameAndDesc, onChoose, onClose, onShowIdChanged }: ITMChooserFormProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default TMChooserForm;
|
|
@@ -7,7 +7,7 @@ import { IconApply, IconHide, IconRefresh, IconShow, SDKUI_Globals, SDKUI_Locali
|
|
|
7
7
|
import TMButton from '../base/TMButton';
|
|
8
8
|
import TMToggleButton from '../base/TMToggleButton';
|
|
9
9
|
import TMModal from '../base/TMModal';
|
|
10
|
-
const TMChooserForm = ({ children, title, allowMultipleSelection, hasShowOnlySelectedItems = false, allowGrouping, allowSorting = true, width, height, dataSource, selectedIDs, manageUseLocalizedName = true, hasShowId = true, keyName = "id", customButtons, showDefaultColumns = true, columns, summaryItems, convertID, customFilter, getItems, cellRenderIcon, cellRenderNameAndDesc, onChoose, onClose, onShowIdChanged
|
|
10
|
+
const TMChooserForm = ({ children, title, allowMultipleSelection, hasShowOnlySelectedItems = false, allowGrouping, allowSorting = true, width, height, dataSource, selectedIDs, manageUseLocalizedName = true, hasShowId = true, keyName = "id", customButtons, showDefaultColumns = true, columns, summaryItems, convertID, customFilter, getItems, cellRenderIcon, cellRenderNameAndDesc, onChoose, onClose, onShowIdChanged }) => {
|
|
11
11
|
const [showId, setShowId] = useState(false);
|
|
12
12
|
const [showOnlySelectedItems, setShowOnlySelectedItems] = useState(selectedIDs != undefined && selectedIDs.length > 0);
|
|
13
13
|
const [selectedItems, setSelectedItems] = useState([]);
|
|
@@ -19,8 +19,6 @@ const TMChooserForm = ({ children, title, allowMultipleSelection, hasShowOnlySel
|
|
|
19
19
|
const renderTitle = () => { return title ? `${title} (${selectedItems.length} / ${customFilter ? customFilter(items).length : items.length})` : SDKUI_Localizator.Select; };
|
|
20
20
|
const doGetItems = (refreshCache) => {
|
|
21
21
|
if (dataSource) {
|
|
22
|
-
if (refreshCache)
|
|
23
|
-
onRefreshCache?.();
|
|
24
22
|
setItems(dataSource);
|
|
25
23
|
setSelectedItems(dataSource.filter((o) => selectedIDs?.includes(o[keyName])));
|
|
26
24
|
return;
|
package/lib/ts/types.d.ts
CHANGED
|
@@ -137,7 +137,6 @@ export interface ITMChooserFormProps<T> {
|
|
|
137
137
|
onChoose?: (selectedobjects?: any) => void;
|
|
138
138
|
onClose?: () => void;
|
|
139
139
|
onShowIdChanged?: () => void;
|
|
140
|
-
onRefreshCache?: () => void;
|
|
141
140
|
}
|
|
142
141
|
export interface ITMChooserProps extends ITMEditorBase {
|
|
143
142
|
allowMultipleSelection?: boolean;
|