@topconsultnpm/sdkui-react-beta 6.6.22 → 6.6.24
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.
|
@@ -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 = [], inputDcmtTypesList, 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, onValueChanged, showClearButton, qd, placeHolder }) => {
|
|
15
|
+
const TMMetadataChooser = ({ tmSession, dataSource, buttons = [], inputDcmtTypesList, 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, onValueChanged, showClearButton, qd, placeHolder, onRefreshCache }) => {
|
|
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, inputDcmtTypesList: inputDcmtTypesList, tids: tids, qd: qd, qdShowOnlySelectItems: qdShowOnlySelectItems, selectedIDs: values, onClose: () => setShowChooser(false), onChoose: (tid_mids) => { onValueChanged?.(tid_mids); } })] }));
|
|
21
|
+
_jsx(TMMetadataChooserForm, { tmSession: tmSession, allowMultipleSelection: allowMultipleSelection, height: '500px', width: '600px', allowSysMetadata: allowSysMetadata, getColorIndex: getColorIndex, dataSource: dataSource, inputDcmtTypesList: inputDcmtTypesList, tids: tids, qd: qd, qdShowOnlySelectItems: qdShowOnlySelectItems, selectedIDs: values, onRefreshCache: onRefreshCache, onClose: () => setShowChooser(false), onChoose: (tid_mids) => { onValueChanged?.(tid_mids); } })] }));
|
|
22
22
|
};
|
|
23
23
|
export default TMMetadataChooser;
|
|
24
|
-
export const TMMetadataChooserForm = ({ tmSession, tids, inputDcmtTypesList, qd, qdShowOnlySelectItems, selectedIDs, dataSource, allowMultipleSelection, allowSysMetadata = true, width, height, getColorIndex, onClose, onChoose }) => {
|
|
24
|
+
export const TMMetadataChooserForm = ({ tmSession, tids, inputDcmtTypesList, qd, qdShowOnlySelectItems, selectedIDs, dataSource, allowMultipleSelection, allowSysMetadata = true, width, height, getColorIndex, onClose, onChoose, onRefreshCache }) => {
|
|
25
25
|
const [showSysMetadata, setShowSysMetadata] = useState(false);
|
|
26
26
|
const [hasSysMetadata, setHasSysMetadata] = useState(false);
|
|
27
27
|
const [dcmtTypes, setDcmtTypes] = useState([]);
|
|
@@ -119,5 +119,5 @@ export const TMMetadataChooserForm = ({ tmSession, tids, inputDcmtTypesList, qd,
|
|
|
119
119
|
};
|
|
120
120
|
const convertID = (md) => { return { tid: md.customData1, mid: md.id, aliasTID: md.customData2 }; };
|
|
121
121
|
const customFilter = (items) => { return showSysMetadata ? items : items.filter(o => o.isSystem != 1); };
|
|
122
|
-
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) }));
|
|
122
|
+
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, onRefreshCache: onRefreshCache, onClose: onClose, onChoose: (IDs) => onChoose?.(IDs) }));
|
|
123
123
|
};
|
|
@@ -141,7 +141,7 @@ const TMTextBox = ({ autoFocus, maxLength, precision, scale, showClearButton, va
|
|
|
141
141
|
e.preventDefault();
|
|
142
142
|
}
|
|
143
143
|
}, "$isMobile": screenWidth < 640, "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, "$fontSize": fontSize, "$maxValue": maxValue, "$width": width, "$type": currentType }), initialType === 'password' && currentValue && _jsx(StyledShowPasswordIcon, { onClick: toggleShowPassword, "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, children: showPasswordIcon() }), initialType !== 'password' &&
|
|
144
|
-
_jsxs("div", { style: { display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', position: 'absolute', right: '6px', top: '7px', pointerEvents: disabled ? 'none' : 'auto', opacity: disabled ? 0.4 : 1 }, children: [showClearButton && currentValue &&
|
|
144
|
+
_jsxs("div", { style: { display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', position: 'absolute', right: '6px', top: label.length > 0 ? '20px' : '7px', pointerEvents: disabled ? 'none' : 'auto', opacity: disabled ? 0.4 : 1 }, children: [showClearButton && currentValue &&
|
|
145
145
|
_jsx(StyledTextBoxEditorButton, { onClick: () => {
|
|
146
146
|
onValueChanged?.({ target: { value: undefined } });
|
|
147
147
|
onBlur?.(undefined);
|
|
@@ -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 }: ITMChooserFormProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
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, onRefreshCache }: 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, onRefreshCache }) => {
|
|
11
11
|
const [showId, setShowId] = useState(false);
|
|
12
12
|
const [showOnlySelectedItems, setShowOnlySelectedItems] = useState(selectedIDs != undefined && selectedIDs.length > 0);
|
|
13
13
|
const [selectedItems, setSelectedItems] = useState([]);
|
|
@@ -18,12 +18,14 @@ const TMChooserForm = ({ children, title, allowMultipleSelection, hasShowOnlySel
|
|
|
18
18
|
const getSelectedIDs = () => { return gridInstance?.instance().getSelectedRowsData().map((item) => { return convertID ? convertID(item) : item[keyName]; }); };
|
|
19
19
|
const renderTitle = () => { return title ? `${title} (${selectedItems.length} / ${customFilter ? customFilter(items).length : items.length})` : SDKUI_Localizator.Select; };
|
|
20
20
|
const doGetItems = (refreshCache) => {
|
|
21
|
+
if (refreshCache)
|
|
22
|
+
onRefreshCache?.();
|
|
21
23
|
if (dataSource) {
|
|
22
24
|
setItems(dataSource);
|
|
23
25
|
setSelectedItems(dataSource.filter((o) => selectedIDs?.includes(o[keyName])));
|
|
24
26
|
return;
|
|
25
27
|
}
|
|
26
|
-
getItems
|
|
28
|
+
getItems?.(refreshCache).then((result) => {
|
|
27
29
|
setItems(result);
|
|
28
30
|
if (!refreshCache) {
|
|
29
31
|
setSelectedItems(result.filter((o) => selectedIDs?.includes(o[keyName])));
|
package/lib/ts/types.d.ts
CHANGED
|
@@ -137,6 +137,7 @@ export interface ITMChooserFormProps<T> {
|
|
|
137
137
|
onChoose?: (selectedobjects?: any) => void;
|
|
138
138
|
onClose?: () => void;
|
|
139
139
|
onShowIdChanged?: () => void;
|
|
140
|
+
onRefreshCache?: () => void;
|
|
140
141
|
}
|
|
141
142
|
export interface ITMChooserProps extends ITMEditorBase {
|
|
142
143
|
allowMultipleSelection?: boolean;
|
|
@@ -149,4 +150,5 @@ export interface ITMChooserProps extends ITMEditorBase {
|
|
|
149
150
|
tmSession?: ITopMediaSession;
|
|
150
151
|
valueName?: any;
|
|
151
152
|
onValueChanged?: (value: any) => void;
|
|
153
|
+
onRefreshCache?: () => void;
|
|
152
154
|
}
|