@topconsultnpm/sdkui-react-beta 6.6.63 → 6.6.64
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,3 +1,4 @@
|
|
|
1
|
+
import { ValidationItem } from '@topconsultnpm/sdk-ts-beta';
|
|
1
2
|
import { DynDataListsToBeRefreshed } from '../choosers/TMDynDataListItemChooser';
|
|
2
3
|
interface ITMMetadataEditorProps {
|
|
3
4
|
tid: number | undefined;
|
|
@@ -10,9 +11,10 @@ interface ITMMetadataEditorProps {
|
|
|
10
11
|
showAsNumber?: boolean;
|
|
11
12
|
containerElement: Element | undefined;
|
|
12
13
|
disabled?: boolean;
|
|
14
|
+
validationItems?: ValidationItem[];
|
|
13
15
|
onValueChanged?: (value: any) => void;
|
|
14
16
|
onValueChange?: (value: any) => void;
|
|
15
17
|
onCascadeRefreshDynDataLists?: (dynDataListsToBeRefreshed: DynDataListsToBeRefreshed[]) => void;
|
|
16
18
|
}
|
|
17
|
-
declare const TMMetadataEditor: ({ tid, mid, value, queryParamsDynDataList, containerElement, allowMultipleSelection, autoFocus, showAsText, showAsNumber, disabled, onValueChanged, onValueChange, onCascadeRefreshDynDataLists }: ITMMetadataEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
declare const TMMetadataEditor: ({ tid, mid, value, queryParamsDynDataList, containerElement, allowMultipleSelection, autoFocus, showAsText, showAsNumber, validationItems, disabled, onValueChanged, onValueChange, onCascadeRefreshDynDataLists }: ITMMetadataEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
20
|
export default TMMetadataEditor;
|
|
@@ -9,7 +9,7 @@ import TMDynDataListItemChooser from '../choosers/TMDynDataListItemChooser';
|
|
|
9
9
|
import TMUserChooser from '../choosers/TMUserChooser';
|
|
10
10
|
import TMDateBox from './TMDateBox';
|
|
11
11
|
import TMTextBox from './TMTextBox';
|
|
12
|
-
const TMMetadataEditor = ({ tid, mid, value, queryParamsDynDataList, containerElement, allowMultipleSelection, autoFocus, showAsText, showAsNumber, disabled = false, onValueChanged, onValueChange, onCascadeRefreshDynDataLists }) => {
|
|
12
|
+
const TMMetadataEditor = ({ tid, mid, value, queryParamsDynDataList, containerElement, allowMultipleSelection, autoFocus, showAsText, showAsNumber, validationItems = [], disabled = false, onValueChanged, onValueChange, onCascadeRefreshDynDataLists }) => {
|
|
13
13
|
const [md, setMd] = useState();
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
DcmtTypeListCacheService.GetAsync(tid).then((dtd) => {
|
|
@@ -18,35 +18,35 @@ const TMMetadataEditor = ({ tid, mid, value, queryParamsDynDataList, containerEl
|
|
|
18
18
|
}, [mid]);
|
|
19
19
|
let btnDistincValues = { text: 'Valori distinti', icon: _jsx(IconLayerGroup, { fontSize: 16 }), onClick: () => { ShowAlert({ message: "TODO Valori distinti", mode: 'info', title: `${"TODO"}`, duration: 3000 }); } };
|
|
20
20
|
if (value?.startsWith("{@QueryParam") || value == "{@UserName}" || value == "{@UserID}")
|
|
21
|
-
return _jsx(TMTextBox, { disabled: disabled, elementStyle: { width: '100%' }, type: 'text', maxLength: md?.length, autoFocus: autoFocus, value: value || '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
21
|
+
return _jsx(TMTextBox, { validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'text', maxLength: md?.length, autoFocus: autoFocus, value: value || '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
22
22
|
if (md?.dataDomain == MetadataDataDomains.DynamicDataList)
|
|
23
|
-
return _jsx(TMDynDataListItemChooser, { disabled: disabled, md: md, tid: tid, buttons: [btnDistincValues], queryParamsDynDataList: queryParamsDynDataList, onCascadeRefreshDynDataLists: onCascadeRefreshDynDataLists, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, allowMultipleSelection: allowMultipleSelection, values: value ? [value] : [], showClearButton: true, onValueChanged: (IDs) => {
|
|
23
|
+
return _jsx(TMDynDataListItemChooser, { validationItems: validationItems, disabled: disabled, md: md, tid: tid, buttons: [btnDistincValues], queryParamsDynDataList: queryParamsDynDataList, onCascadeRefreshDynDataLists: onCascadeRefreshDynDataLists, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, allowMultipleSelection: allowMultipleSelection, values: value ? [value] : [], showClearButton: true, onValueChanged: (IDs) => {
|
|
24
24
|
if (!IDs || IDs.length <= 0)
|
|
25
25
|
onValueChanged?.(undefined);
|
|
26
26
|
else
|
|
27
27
|
onValueChanged?.(IDs[0]);
|
|
28
28
|
} });
|
|
29
29
|
if (md?.dataDomain == MetadataDataDomains.DataList)
|
|
30
|
-
return _jsx(TMDataListItemChooser, { disabled: disabled, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, dataListId: md.dataListID, allowMultipleSelection: allowMultipleSelection, values: value?.split(',').map((item) => !item.startsWith("'") ? item : item.slice(1, -1)) ?? [], showClearButton: true, buttons: [btnDistincValues], onValueChanged: (IDs) => {
|
|
30
|
+
return _jsx(TMDataListItemChooser, { validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, dataListId: md.dataListID, allowMultipleSelection: allowMultipleSelection, values: value?.split(',').map((item) => !item.startsWith("'") ? item : item.slice(1, -1)) ?? [], showClearButton: true, buttons: [btnDistincValues], onValueChanged: (IDs) => {
|
|
31
31
|
if (!IDs || IDs.length <= 0)
|
|
32
32
|
onValueChanged?.(undefined);
|
|
33
33
|
else
|
|
34
34
|
onValueChanged?.(IDs.join(","));
|
|
35
35
|
} });
|
|
36
36
|
if (md?.dataDomain == MetadataDataDomains.UserID)
|
|
37
|
-
return _jsx(TMUserChooser, { disabled: disabled, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, placeHolder: " ", showClearButton: true, allowMultipleSelection: allowMultipleSelection, values: value?.split(',').map((item) => !item.startsWith("'") ? Number(item) : Number(item.slice(1, -1))) ?? [], buttons: [btnDistincValues], onValueChanged: (IDs) => {
|
|
37
|
+
return _jsx(TMUserChooser, { validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, placeHolder: " ", showClearButton: true, allowMultipleSelection: allowMultipleSelection, values: value?.split(',').map((item) => !item.startsWith("'") ? Number(item) : Number(item.slice(1, -1))) ?? [], buttons: [btnDistincValues], onValueChanged: (IDs) => {
|
|
38
38
|
if (!IDs || IDs.length <= 0)
|
|
39
39
|
onValueChanged?.(undefined);
|
|
40
40
|
else
|
|
41
41
|
onValueChanged?.(IDs.join(","));
|
|
42
42
|
} });
|
|
43
43
|
if (showAsText)
|
|
44
|
-
return _jsx(TMTextBox, { disabled: disabled, elementStyle: { width: '100%' }, type: 'text', buttons: [btnDistincValues], showClearButton: true, maxLength: md?.length, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
44
|
+
return _jsx(TMTextBox, { validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'text', buttons: [btnDistincValues], showClearButton: true, maxLength: md?.length, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
45
45
|
if (showAsNumber)
|
|
46
|
-
return _jsx(TMTextBox, { disabled: disabled, elementStyle: { width: '100%' }, type: 'number', showClearButton: true, precision: md?.length, scale: md?.scale, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
46
|
+
return _jsx(TMTextBox, { validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'number', showClearButton: true, precision: md?.length, scale: md?.scale, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
47
47
|
switch (md?.dataType) {
|
|
48
|
-
case MetadataDataTypes.DateTime: return _jsx(TMDateBox, { disabled: disabled, width: '100%', value: value, buttons: [btnDistincValues], showClearButton: true, useDateSerializationFormat: true, containerElement: containerElement, onValueChange: (newValue) => { onValueChange?.(newValue ? newValue.toString() : undefined); onValueChanged?.(newValue ? newValue.toString() : undefined); } });
|
|
49
|
-
case MetadataDataTypes.Number: return _jsx(TMTextBox, { disabled: disabled, elementStyle: { width: '100%' }, type: 'number', buttons: [btnDistincValues], showClearButton: true, precision: md?.length, scale: md?.scale, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
48
|
+
case MetadataDataTypes.DateTime: return _jsx(TMDateBox, { validationItems: validationItems, disabled: disabled, width: '100%', value: value, buttons: [btnDistincValues], showClearButton: true, useDateSerializationFormat: true, containerElement: containerElement, onValueChange: (newValue) => { onValueChange?.(newValue ? newValue.toString() : undefined); onValueChanged?.(newValue ? newValue.toString() : undefined); } });
|
|
49
|
+
case MetadataDataTypes.Number: return _jsx(TMTextBox, { validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'number', buttons: [btnDistincValues], showClearButton: true, precision: md?.length, scale: md?.scale, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
50
50
|
default: return _jsx(TMTextBox, { disabled: disabled, type: 'text', elementStyle: { width: '100%' }, showClearButton: true, buttons: [btnDistincValues], autoFocus: autoFocus, maxLength: md?.length, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => { onValueChanged?.(newValue); } });
|
|
51
51
|
}
|
|
52
52
|
};
|