@topconsultnpm/sdkui-react-beta 6.6.35 → 6.6.37

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.
@@ -0,0 +1,17 @@
1
+ import { DynDataListsToBeRefreshed } from '../choosers/TMDynDataListItemChooser';
2
+ interface ITMMetadataEditorProps {
3
+ tid: number | undefined;
4
+ mid?: number;
5
+ value: string | undefined;
6
+ queryParamsDynDataList?: string[];
7
+ allowMultipleSelection: boolean;
8
+ autoFocus: boolean;
9
+ showAsText?: boolean;
10
+ showAsNumber?: boolean;
11
+ containerElement: Element | undefined;
12
+ onValueChanged?: (value: any) => void;
13
+ onValueChange?: (value: any) => void;
14
+ onCascadeRefreshDynDataLists?: (dynDataListsToBeRefreshed: DynDataListsToBeRefreshed[]) => void;
15
+ }
16
+ declare const TMMetadataEditor: ({ tid, mid, value, queryParamsDynDataList, containerElement, allowMultipleSelection, autoFocus, showAsText, showAsNumber, onValueChanged, onValueChange, onCascadeRefreshDynDataLists }: ITMMetadataEditorProps) => import("react/jsx-runtime").JSX.Element;
17
+ export default TMMetadataEditor;
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { MetadataDataDomains, MetadataDataTypes, DcmtTypeListCacheService } from '@topconsultnpm/sdk-ts-beta';
4
+ import { IconLayerGroup } from '../../helper';
5
+ import { TMColors } from '../../utils/theme';
6
+ import ShowAlert from '../base/TMAlert';
7
+ import TMDataListItemChooser from '../choosers/TMDataListItemChooser';
8
+ import TMDynDataListItemChooser from '../choosers/TMDynDataListItemChooser';
9
+ import TMUserChooser from '../choosers/TMUserChooser';
10
+ import TMDateBox from './TMDateBox';
11
+ import TMTextBox from './TMTextBox';
12
+ const TMMetadataEditor = ({ tid, mid, value, queryParamsDynDataList, containerElement, allowMultipleSelection, autoFocus, showAsText, showAsNumber, onValueChanged, onValueChange, onCascadeRefreshDynDataLists }) => {
13
+ const [md, setMd] = useState();
14
+ useEffect(() => {
15
+ DcmtTypeListCacheService.GetAsync(tid).then((dtd) => {
16
+ setMd(dtd?.metadata?.find(o => o.id == mid));
17
+ });
18
+ }, [mid]);
19
+ let btnDistincValues = { text: 'Valori distinti', icon: _jsx(IconLayerGroup, { fontSize: 16 }), onClick: () => { ShowAlert({ message: "TODO Valori distinti", mode: 'info', title: `${"TODO"}`, duration: 3000 }); } };
20
+ if (value?.startsWith("{@QueryParam") || value == "{@UserName}" || value == "{@UserID}")
21
+ return _jsx(TMTextBox, { elementStyle: { width: '100%' }, type: 'text', maxLength: md?.length, autoFocus: autoFocus, value: value || '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
22
+ if (md?.dataDomain == MetadataDataDomains.DynamicDataList)
23
+ return _jsx(TMDynDataListItemChooser, { 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
+ if (!IDs || IDs.length <= 0)
25
+ onValueChanged?.(undefined);
26
+ else
27
+ onValueChanged?.(IDs[0]);
28
+ } });
29
+ if (md?.dataDomain == MetadataDataDomains.DataList)
30
+ return _jsx(TMDataListItemChooser, { 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
+ if (!IDs || IDs.length <= 0)
32
+ onValueChanged?.(undefined);
33
+ else
34
+ onValueChanged?.(IDs.join(","));
35
+ } });
36
+ if (md?.dataDomain == MetadataDataDomains.UserID)
37
+ return _jsx(TMUserChooser, { 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
+ if (!IDs || IDs.length <= 0)
39
+ onValueChanged?.(undefined);
40
+ else
41
+ onValueChanged?.(IDs.join(","));
42
+ } });
43
+ if (showAsText)
44
+ return _jsx(TMTextBox, { 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
+ if (showAsNumber)
46
+ return _jsx(TMTextBox, { 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
+ switch (md?.dataType) {
48
+ case MetadataDataTypes.DateTime: return _jsx(TMDateBox, { 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, { 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
+ default: return _jsx(TMTextBox, { 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
+ }
52
+ };
53
+ export default TMMetadataEditor;
@@ -22,6 +22,7 @@ export { default as TMTextArea } from './editors/TMTextArea';
22
22
  export { default as TMCheckBox } from './editors/TMCheckBox';
23
23
  export { default as TMRadioButton } from './editors/TMRadioButton';
24
24
  export { default as TMDateBox } from './editors/TMDateBox';
25
+ export { default as TMMetadataEditor } from './editors/TMMetadataEditor';
25
26
  export { editorColorManager } from './editors/TMEditorStyled';
26
27
  export * from './choosers/TMDataListItemChooser';
27
28
  export * from './choosers/TMDynDataListItemChooser';
@@ -25,6 +25,7 @@ export { default as TMTextArea } from './editors/TMTextArea';
25
25
  export { default as TMCheckBox } from './editors/TMCheckBox';
26
26
  export { default as TMRadioButton } from './editors/TMRadioButton';
27
27
  export { default as TMDateBox } from './editors/TMDateBox';
28
+ export { default as TMMetadataEditor } from './editors/TMMetadataEditor';
28
29
  export { editorColorManager } from './editors/TMEditorStyled';
29
30
  // choosers
30
31
  export * from './choosers/TMDataListItemChooser';
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import { MetadataDescriptor, QueryDescriptor, ValidationItem } from '@topconsultnpm/sdk-ts-beta';
2
+ import { QueryDescriptor, ValidationItem } from '@topconsultnpm/sdk-ts-beta';
3
3
  import { ITMApplyFormProps, FormModes } from '../../ts';
4
- import { DynDataListsToBeRefreshed } from '../choosers/TMDynDataListItemChooser';
5
4
  export declare const StyledRowItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
6
5
  export declare const StyledItemWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
7
6
  $borderRadius?: string;
@@ -48,16 +47,3 @@ interface ITMQueryEditor extends ITMApplyFormProps<QueryDescriptor> {
48
47
  }
49
48
  declare const TMQueryEditor: React.FunctionComponent<ITMQueryEditor>;
50
49
  export default TMQueryEditor;
51
- export declare const TMQdWhereItemValueEditor: ({ tid, value, queryParamsDynDataList, containerElement, allowMultipleSelection, autoFocus, numberOfOperands, md, onValueChanged, onValueChange, onCascadeRefreshDynDataLists }: {
52
- tid: number | undefined;
53
- value: string | undefined;
54
- queryParamsDynDataList?: string[];
55
- allowMultipleSelection: boolean;
56
- numberOfOperands: number;
57
- autoFocus: boolean;
58
- containerElement: Element | undefined;
59
- md: MetadataDescriptor | undefined;
60
- onValueChanged?: (value: any) => void;
61
- onValueChange?: (value: any) => void;
62
- onCascadeRefreshDynDataLists?: (dynDataListsToBeRefreshed: DynDataListsToBeRefreshed[]) => void;
63
- }) => import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
3
3
  import { SDK_Localizator, AccessLevels, OnJoinItem, JoinTypes, PlatformObjectValidator, MetadataDataDomains, DcmtTypeListCacheService, JoinItem, SystemMIDsAsNumber, MetadataDataTypes, OrderByItem, QueryDescriptor, QueryFunctions, QueryOperators, ResultTypes, SelectItem, SDK_Globals, UserListCacheService, WhereItem, SearchEngine, SelectItemVisibilities, DataListCacheService, QueryValidatorOptions, TMPropertyNames, AppModules, LayoutModes } from '@topconsultnpm/sdk-ts-beta';
4
4
  import styled from 'styled-components';
5
5
  import Accordion, { Item } from 'devextreme-react/accordion';
6
- import { SDKUI_Localizator, IconSearch, IconCount, getQueryCountAsync, calcIsModified, IconClear, IconAddCircleOutline, IconDotsVerticalCircleOutline, IconHide, IconShow, IconDraggabledots, genUniqueId, LocalizeQueryOperators, LocalizeQueryFunctions, LocalizeQueryJoinTypes, IconArchiveDoc, IconArrowRight, IconLayerGroup } from '../../helper';
6
+ import { SDKUI_Localizator, IconSearch, IconCount, getQueryCountAsync, calcIsModified, IconClear, IconAddCircleOutline, IconDotsVerticalCircleOutline, IconHide, IconShow, IconDraggabledots, genUniqueId, LocalizeQueryOperators, LocalizeQueryFunctions, LocalizeQueryJoinTypes, IconArchiveDoc, IconArrowRight } from '../../helper';
7
7
  import { displayMetadataValue, getDcmtTypesByQdAsync, getTIDsByQd } from '../../helper/queryHelper';
8
8
  import { useOutsideClick } from '../../hooks/useOutsideClick';
9
9
  import { FormModes } from '../../ts';
@@ -16,19 +16,19 @@ import TMSpinner from '../base/TMSpinner';
16
16
  import { TMTabItemBadge } from '../base/TMTab';
17
17
  import TMTooltip from '../base/TMTooltip';
18
18
  import TMVilViewer from '../base/TMVilViewer';
19
- import TMDataListItemChooser, { TMDataListItemChooserForm } from '../choosers/TMDataListItemChooser';
19
+ import { TMDataListItemChooserForm } from '../choosers/TMDataListItemChooser';
20
20
  import TMDcmtTypeChooser from '../choosers/TMDcmtTypeChooser';
21
21
  import TMMetadataChooser from '../choosers/TMMetadataChooser';
22
- import TMUserChooser, { TMUserChooserForm } from '../choosers/TMUserChooser';
22
+ import { TMUserChooserForm } from '../choosers/TMUserChooser';
23
23
  import TMCheckBox from '../editors/TMCheckBox';
24
- import TMDateBox from '../editors/TMDateBox';
25
24
  import TMTextBox from '../editors/TMTextBox';
26
25
  import TMApplyForm from '../forms/TMApplyForm';
27
26
  import { getDisplayAlias } from '../viewers/TMMidViewer';
28
27
  import { useApplyForm } from '../../hooks/useForm';
29
28
  import ShowAlert from '../base/TMAlert';
30
- import TMDynDataListItemChooser, { IsParametricQuery, TMDynDataListItemChooserForm } from '../choosers/TMDynDataListItemChooser';
29
+ import { IsParametricQuery, TMDynDataListItemChooserForm } from '../choosers/TMDynDataListItemChooser';
31
30
  import TMQueryResultForm, { SearchResultContext } from './TMQueryResultForm';
31
+ import TMMetadataEditor from '../editors/TMMetadataEditor';
32
32
  export const StyledRowItem = styled.div ` display: flex; flex-direction: row; align-items: center; justify-content: flex-start; margin-bottom: 5px; gap: 3px; `;
33
33
  export const StyledItemWrapper = styled.div ` border-radius: ${props => props.$borderRadius ? props.$borderRadius : '4px'}; padding: 4px; font-size: 1rem; user-select: none; width: max-content; `;
34
34
  export const StyledAccordionItemContainer = styled.div ` width: 100%; padding: 2px; display: flex; flex-direction: column; overflow-x: auto; align-items: flex-start; margin-left: 5px; gap: 3px; max-height: 300px; `;
@@ -970,7 +970,7 @@ const TMQdWhereItemValue = ({ whereItem, index, queryParamsDynDataList, onlyEdit
970
970
  };
971
971
  const mdValueEmptyDescr = `<${SDKUI_Localizator.Search_EnterValue}...>`;
972
972
  return (_jsxs("div", { ref: ref, id: containerId, style: { width: isEditing && whereItem.operator == QueryOperators.Custom && !onlyEditing ? "100%" : undefined }, children: [(isEditing || onlyEditing) &&
973
- _jsxs(StyledRowItem, { children: [showValue1 && _jsx(TMQdWhereItemValueEditor, { tid: whereItem.tid, value: whereItem.value1, allowMultipleSelection: whereItem.operator == QueryOperators.In || whereItem.operator == QueryOperators.NotIn, autoFocus: !onlyEditing, md: md, containerElement: containerElement, numberOfOperands: numberOfOperands, onValueChange: (value) => setCurrentValue1(value), onValueChanged: (value) => { normalizeValue(value, true); } }), showValue2 && _jsx(TMQdWhereItemValueEditor, { tid: whereItem.tid, value: whereItem.value2, allowMultipleSelection: whereItem.operator == QueryOperators.In || whereItem.operator == QueryOperators.NotIn, autoFocus: !onlyEditing, md: md, containerElement: containerElement, numberOfOperands: numberOfOperands, onValueChange: (value) => setCurrentValue2(value), onValueChanged: (value) => { normalizeValue(value, false); } })] }), !isEditing && !onlyEditing && (showValue1 || showValue2) &&
973
+ _jsxs(StyledRowItem, { children: [showValue1 && _jsx(TMMetadataEditor, { tid: whereItem.tid, mid: whereItem.mid, value: whereItem.value1, allowMultipleSelection: whereItem.operator == QueryOperators.In || whereItem.operator == QueryOperators.NotIn, autoFocus: !onlyEditing, containerElement: containerElement, showAsText: numberOfOperands == 11 || numberOfOperands == 99, showAsNumber: numberOfOperands == 12, onValueChange: (value) => setCurrentValue1(value), onValueChanged: (value) => { normalizeValue(value, true); } }), showValue2 && _jsx(TMMetadataEditor, { tid: whereItem.tid, mid: whereItem.mid, value: whereItem.value2, allowMultipleSelection: whereItem.operator == QueryOperators.In || whereItem.operator == QueryOperators.NotIn, autoFocus: !onlyEditing, containerElement: containerElement, showAsText: numberOfOperands == 11 || numberOfOperands == 99, showAsNumber: numberOfOperands == 12, onValueChange: (value) => setCurrentValue2(value), onValueChanged: (value) => { normalizeValue(value, false); } })] }), !isEditing && !onlyEditing && (showValue1 || showValue2) &&
974
974
  _jsxs(StyledDivHorizontal, { children: [editingMode == EditingModes.Chooser &&
975
975
  _jsxs(_Fragment, { children: [showDataListChooseForm &&
976
976
  _jsx(TMDataListItemChooserForm, { height: '500px', width: '450px', allowMultipleSelection: whereItem.operator == QueryOperators.In || whereItem.operator == QueryOperators.NotIn, dataListId: md?.dataListID, selectedIDs: whereItem.value1?.split(',').map((item) => !item.startsWith("'") ? item : item.slice(1, -1)) ?? [], onClose: () => setShowDataListChooseForm(false), onChoose: (IDs) => { IDs && normalizeValue(IDs.length == 1 ? IDs[0] : IDs.map((item) => `${item}`).join(","), true); } }), showDynDataListChooseForm &&
@@ -1017,40 +1017,3 @@ const TMQdWhereItemValue = ({ whereItem, index, queryParamsDynDataList, onlyEdit
1017
1017
  ? _jsx(_Fragment, { children: whereItem.value1 ?? mdValueEmptyDescr })
1018
1018
  : _jsxs(_Fragment, { children: [displayMetadataValue(md, whereItem.value1, mdValueEmptyDescr), numberOfOperands == 2 && (whereItem.value2 && whereItem.value2 != '' ? ` - ${displayMetadataValue(md, whereItem.value2, mdValueEmptyDescr)}` : ' - ?')] }) })] })] }));
1019
1019
  };
1020
- export const TMQdWhereItemValueEditor = ({ tid, value, queryParamsDynDataList, containerElement, allowMultipleSelection, autoFocus, numberOfOperands, md, onValueChanged, onValueChange, onCascadeRefreshDynDataLists }) => {
1021
- let btnDistincValues = { text: 'Valori distinti', icon: _jsx(IconLayerGroup, { fontSize: 16 }), onClick: () => { ShowAlert({ message: "TODO Valori distinti", mode: 'info', title: `${"TODO"}`, duration: 3000 }); } };
1022
- if (value?.startsWith("{@QueryParam") || value == "{@UserName}" || value == "{@UserID}")
1023
- return _jsx(TMTextBox, { elementStyle: { width: '100%' }, type: 'text', maxLength: md?.length, autoFocus: autoFocus, value: value || '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
1024
- if (md?.dataDomain == MetadataDataDomains.DynamicDataList)
1025
- return _jsx(TMDynDataListItemChooser, { 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) => {
1026
- if (!IDs || IDs.length <= 0)
1027
- onValueChanged?.(undefined);
1028
- else
1029
- onValueChanged?.(IDs[0]);
1030
- } });
1031
- if (md?.dataDomain == MetadataDataDomains.DataList)
1032
- return _jsx(TMDataListItemChooser, { 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) => {
1033
- if (!IDs || IDs.length <= 0)
1034
- onValueChanged?.(undefined);
1035
- else
1036
- onValueChanged?.(IDs.join(","));
1037
- } });
1038
- if (md?.dataDomain == MetadataDataDomains.UserID)
1039
- return _jsx(TMUserChooser, { 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) => {
1040
- if (!IDs || IDs.length <= 0)
1041
- onValueChanged?.(undefined);
1042
- else
1043
- onValueChanged?.(IDs.join(","));
1044
- } });
1045
- switch (numberOfOperands) {
1046
- case 11:
1047
- case 99: return _jsx(TMTextBox, { 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) });
1048
- case 12: return _jsx(TMTextBox, { 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) });
1049
- default:
1050
- switch (md?.dataType) {
1051
- case MetadataDataTypes.DateTime: return _jsx(TMDateBox, { width: '100%', value: value, buttons: [btnDistincValues], showClearButton: true, useDateSerializationFormat: true, containerElement: containerElement, onValueChange: (newValue) => { onValueChange?.(newValue ? newValue.toString() : undefined); onValueChanged?.(newValue ? newValue.toString() : undefined); } });
1052
- case MetadataDataTypes.Number: return _jsx(TMTextBox, { 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) });
1053
- default: return _jsx(TMTextBox, { 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); } });
1054
- }
1055
- }
1056
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.6.35",
3
+ "version": "6.6.37",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -28,7 +28,7 @@
28
28
  "lib"
29
29
  ],
30
30
  "dependencies": {
31
- "@topconsultnpm/sdk-ts-beta": "^6.6.7",
31
+ "@topconsultnpm/sdk-ts-beta": "^6.6.8",
32
32
  "buffer": "^6.0.3",
33
33
  "devextreme": "24.1.6",
34
34
  "devextreme-react": "24.1.6",