@topconsultnpm/sdkui-react-beta 6.10.42 → 6.10.43

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.
@@ -4,12 +4,18 @@ import { ITMChooserFormProps, ITMChooserProps } from '../../ts';
4
4
  interface ITMUserChooserProps extends ITMChooserProps {
5
5
  /** Contiene i values selezionati */
6
6
  values?: number[];
7
+ /** predicate function per filtrare i metadati. Significativo per un solo tid (tids) */
8
+ filter?: (value: UserDescriptor, index: number, array: UserDescriptor[]) => unknown;
7
9
  /** Visualizza il bordo */
8
10
  showBorder?: boolean;
9
11
  }
10
12
  declare const TMUserChooser: React.FunctionComponent<ITMUserChooserProps>;
11
13
  export default TMUserChooser;
12
- export declare const TMUserChooserForm: React.FunctionComponent<ITMChooserFormProps<UserDescriptor>>;
14
+ interface ITMUserChooserFormProps extends ITMChooserFormProps<UserDescriptor> {
15
+ /** predicate function per filtrare i metadati. Significativo per un solo tid (tids) */
16
+ filter?: (value: UserDescriptor, index: number, array: UserDescriptor[]) => unknown;
17
+ }
18
+ export declare const TMUserChooserForm: React.FunctionComponent<ITMUserChooserFormProps>;
13
19
  export declare const TMUserIdViewer: ({ userId, showIcon, noneSelectionText }: {
14
20
  userId?: number;
15
21
  showIcon?: boolean;
@@ -10,7 +10,7 @@ import TMSummary from '../editors/TMSummary';
10
10
  import TMChooserForm from '../forms/TMChooserForm';
11
11
  import { TMColors } from '../../utils/theme';
12
12
  import { TMExceptionBoxManager } from '../base/TMPopUp';
13
- const TMUserChooser = ({ labelColor, titleForm, readOnly = false, icon, dataSource, backgroundColor, openChooserBySingleClick, buttons = [], disabled = false, showBorder = true, elementStyle, allowMultipleSelection, values, isModifiedWhen, label, placeHolder, validationItems = [], onValueChanged, showClearButton }) => {
13
+ const TMUserChooser = ({ labelColor, titleForm, filter, readOnly = false, icon, dataSource, backgroundColor, openChooserBySingleClick, buttons = [], disabled = false, showBorder = true, elementStyle, allowMultipleSelection, values, isModifiedWhen, label, placeHolder, validationItems = [], onValueChanged, showClearButton }) => {
14
14
  const [showChooser, setShowChooser] = useState(false);
15
15
  useEffect(() => {
16
16
  if (!values || values.length <= 0)
@@ -22,10 +22,10 @@ const TMUserChooser = ({ labelColor, titleForm, readOnly = false, icon, dataSour
22
22
  return (_jsxs(StyledDivHorizontal, { style: { minWidth: '125px' }, children: [values && values.length > 0 && _jsx(TMUserIdViewer, { userId: values?.[0], showIcon: true, noneSelectionText: '' }), values && values.length > 1 && _jsx("p", { style: { marginLeft: '10px' }, children: `(+${values.length - 1} ${values.length == 2 ? 'altro' : 'altri'})` })] }));
23
23
  };
24
24
  return (_jsxs(_Fragment, { children: [_jsx(TMSummary, { disabled: disabled, placeHolder: placeHolder, readOnly: readOnly, labelColor: labelColor, icon: icon, backgroundColor: backgroundColor, buttons: buttons, showBorder: showBorder, hasValue: values && values.length > 0, showClearButton: showClearButton, iconEditButton: _jsx(IconSearch, { fontSize: 16 }), onEditorClick: () => !readOnly && setShowChooser(true), elementStyle: elementStyle, isModifiedWhen: isModifiedWhen, openEditorOnSummaryClick: openChooserBySingleClick, label: label, template: renderTemplate(), onClearClick: showClearButton ? () => { onValueChanged?.([]); } : undefined, validationItems: validationItems }), showChooser &&
25
- _jsx(TMUserChooserForm, { allowMultipleSelection: allowMultipleSelection, title: titleForm, hasShowOnlySelectedItems: true, dataSource: dataSource, selectedIDs: values, onClose: () => setShowChooser(false), onChoose: (IDs) => { onValueChanged?.(IDs); } })] }));
25
+ _jsx(TMUserChooserForm, { allowMultipleSelection: allowMultipleSelection, title: titleForm, hasShowOnlySelectedItems: true, dataSource: dataSource, filter: filter, selectedIDs: values, onClose: () => setShowChooser(false), onChoose: (IDs) => { onValueChanged?.(IDs); } })] }));
26
26
  };
27
27
  export default TMUserChooser;
28
- export const TMUserChooserForm = (props) => {
28
+ export const TMUserChooserForm = ({ allowMultipleSelection, startWithShowOnlySelectedItems = true, filter, title, hasShowOnlySelectedItems, width, height, selectedIDs, dataSource, onClose, onChoose }) => {
29
29
  const renderDataGridColumns = [
30
30
  _jsx(Column, { dataField: "domain", visibleIndex: 2, caption: SDKUI_Localizator.Domain, dataType: 'string' }, 3)
31
31
  ];
@@ -33,18 +33,19 @@ export const TMUserChooserForm = (props) => {
33
33
  TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.Users} ...` });
34
34
  if (refreshCache)
35
35
  UserListCacheService.RemoveAll();
36
- let users = await UserListCacheService.GetAllAsync();
36
+ let allUsers = await UserListCacheService.GetAllAsync();
37
+ let users = filter ? allUsers?.filter(filter) : allUsers;
37
38
  TMSpinner.hide();
38
39
  return users;
39
40
  };
40
41
  const getTitle = () => {
41
42
  let title = SDK_Localizator.Users;
42
- if (props.title)
43
- title += `: ${props.title}`;
43
+ if (title)
44
+ title += `: ${title}`;
44
45
  return title;
45
46
  };
46
47
  const cellRenderIcon = (data) => _jsx(TMUserIcon, { ud: data.data });
47
- return (_jsx(TMChooserForm, { title: getTitle(), allowMultipleSelection: props.allowMultipleSelection, hasShowOnlySelectedItems: props.hasShowOnlySelectedItems, width: props.width, height: props.height, manageUseLocalizedName: false, columns: renderDataGridColumns, selectedIDs: props.selectedIDs, cellRenderIcon: cellRenderIcon, dataSource: props.dataSource, getItems: getItems, onClose: props.onClose, onChoose: (IDs) => props.onChoose?.(IDs) }));
48
+ return (_jsx(TMChooserForm, { title: getTitle(), allowMultipleSelection: allowMultipleSelection, startWithShowOnlySelectedItems: startWithShowOnlySelectedItems, hasShowOnlySelectedItems: hasShowOnlySelectedItems, width: width, height: height, manageUseLocalizedName: false, columns: renderDataGridColumns, selectedIDs: selectedIDs, cellRenderIcon: cellRenderIcon, dataSource: dataSource, getItems: getItems, onClose: onClose, onChoose: (IDs) => onChoose?.(IDs) }));
48
49
  };
49
50
  export const TMUserIdViewer = ({ userId, showIcon = false, noneSelectionText = `<${SDKUI_Localizator.NoneSelection}>` }) => {
50
51
  const [ud, setUd] = useState();
@@ -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, startWithShowOnlySelectedItems, 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;
@@ -8,9 +8,9 @@ import TMToggleButton from '../base/TMToggleButton';
8
8
  import TMModal from '../base/TMModal';
9
9
  import TMLayoutContainer, { TMLayoutItem } from '../base/TMLayout';
10
10
  import { TMColors } from '../../utils/theme';
11
- 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
+ const TMChooserForm = ({ children, title, allowMultipleSelection, startWithShowOnlySelectedItems = true, 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 }) => {
12
12
  const [showId, setShowId] = useState(false);
13
- const [showOnlySelectedItems, setShowOnlySelectedItems] = useState(selectedIDs != undefined && selectedIDs.length > 0);
13
+ const [showOnlySelectedItems, setShowOnlySelectedItems] = useState(startWithShowOnlySelectedItems && selectedIDs != undefined && selectedIDs.length > 0);
14
14
  const [selectedItems, setSelectedItems] = useState([]);
15
15
  const [items, setItems] = useState([]);
16
16
  const [isInitialized, setIsInitialized] = useState(false);
package/lib/ts/types.d.ts CHANGED
@@ -122,6 +122,7 @@ export interface ITMChooserFormProps<T> {
122
122
  allowGrouping?: boolean;
123
123
  allowMultipleSelection?: boolean;
124
124
  hasShowOnlySelectedItems?: boolean;
125
+ startWithShowOnlySelectedItems?: boolean;
125
126
  keyName?: string;
126
127
  customButtons?: React.ReactNode;
127
128
  columns?: JSX.Element[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.10.42",
3
+ "version": "6.10.43",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",