@topconsultnpm/sdkui-react-beta 6.11.109 → 6.11.111

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.
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useMemo, useState } from 'react';
3
3
  import { LayoutModes, MetadataDataDomains, AccessLevels, MetadataDataTypes, SDK_Globals, DcmtTypeListCacheService, DataColumnTypes } from '@topconsultnpm/sdk-ts-beta';
4
4
  import styled from 'styled-components';
5
- import { IconDataList, SDKUI_Localizator } from '../../helper';
5
+ import { IconDataList, SDKUI_Localizator, stringIsNullOrEmpty } from '../../helper';
6
6
  import TMButton from '../base/TMButton';
7
7
  import TMDataGrid from '../base/TMDataGrid';
8
8
  import { TMExceptionBoxManager } from '../base/TMPopUp';
@@ -19,6 +19,14 @@ const TMDistinctValues = ({ tid, mid, layoutMode = LayoutModes.None, allowAppend
19
19
  const [hasLoadedBefore, setHasLoadedBefore] = useState(false);
20
20
  const [showPrompt, setShowPrompt] = useState(false);
21
21
  const [currentValue, setCurrentValue] = useState('');
22
+ useEffect(() => {
23
+ if (!hasLoadedBefore) {
24
+ getDistictValuesAsync().then(() => setHasLoadedBefore(true));
25
+ }
26
+ else {
27
+ getDcmtTypeAsync().then(() => setShowPrompt(true));
28
+ }
29
+ }, [mid]);
22
30
  useEffect(() => {
23
31
  setIsAppendMode(false);
24
32
  setFocusedItem(undefined);
@@ -44,20 +52,12 @@ const TMDistinctValues = ({ tid, mid, layoutMode = LayoutModes.None, allowAppend
44
52
  return;
45
53
  }
46
54
  let value = md.dataType === MetadataDataTypes.Number ? parseFloat(focusedItem.value.replace(',', '.')).toString() : focusedItem.value;
47
- let newValue = isAppendMode ? currentValue + separator + value : value;
55
+ let newValue = stringIsNullOrEmpty(currentValue)
56
+ ? value
57
+ : isAppendMode ? currentValue + separator + value : value;
48
58
  setCurrentValue(newValue);
49
59
  onSelectionChanged?.({ tid: tid, mid: mid, newValue: newValue, isAppendMode: isAppendMode });
50
60
  }, [focusedItem]);
51
- useEffect(() => {
52
- if (!hasLoadedBefore) {
53
- getDistictValuesAsync();
54
- setHasLoadedBefore(true);
55
- }
56
- else {
57
- getDcmtTypeAsync();
58
- setShowPrompt(true);
59
- }
60
- }, [mid, hasLoadedBefore]);
61
61
  const getDistictValuesAsync = async () => {
62
62
  if (!tid)
63
63
  return;
@@ -141,9 +141,8 @@ const TMDistinctValues = ({ tid, mid, layoutMode = LayoutModes.None, allowAppend
141
141
  return false;
142
142
  return md.dataDomain === undefined || md.dataDomain === MetadataDataDomains.None;
143
143
  };
144
- if (showPrompt) {
145
- return (_jsxs(StyledPanelContainer, { children: [_jsx(IconDataList, { fontSize: 96 }), _jsxs("p", { children: ["Caricare i valori distinti di ", _jsx("strong", { children: `"${md?.nameLoc}" ` }), "? "] }), _jsx(TMButton, { caption: SDKUI_Localizator.Yes, onClick: handleLoadData, showTooltip: false })] }));
146
- }
147
- return (_jsx(TMToolbarCard, { title: SDKUI_Localizator.DistinctValues + (md?.nameLoc ? ` (${md?.nameLoc})` : ''), showHeader: showHeader, onClose: onClosePanelCallback, children: _jsxs(StyledDistinctValues, { children: [isVisibleAppend() && _jsx(TMCheckBox, { elementStyle: { position: 'absolute', right: '15px', top: '15px', zIndex: 10000 }, label: 'Accoda', value: isAppendMode, onValueChanged: () => { setIsAppendMode(!isAppendMode); } }), _jsx(TMDataGrid, { focusedRowKey: focusedItem ? focusedItem.rowIndex : undefined, selection: { showCheckBoxesMode: 'none' }, searchPanel: { highlightCaseSensitive: true, visible: true }, dataColumns: customColumns, dataSource: dataSource, keyExpr: 'rowIndex', height: 'calc(100%)', onFocusedRowChanged: onFocusedRowChanged, paging: { pageSize: 30 }, summary: customSummary })] }) }));
144
+ return (_jsx(TMToolbarCard, { title: SDKUI_Localizator.DistinctValues + (md?.nameLoc ? ` (${md?.nameLoc})` : ''), showHeader: showHeader, onClose: onClosePanelCallback, children: showPrompt
145
+ ? _jsxs(StyledPanelContainer, { children: [_jsx(IconDataList, { fontSize: 96 }), _jsxs("p", { children: ["Caricare i valori distinti di ", _jsx("strong", { children: `"${md?.nameLoc}" ` }), "? "] }), _jsx(TMButton, { caption: SDKUI_Localizator.Yes, onClick: handleLoadData, showTooltip: false })] })
146
+ : _jsxs(StyledDistinctValues, { children: [isVisibleAppend() && _jsx(TMCheckBox, { elementStyle: { position: 'absolute', right: '15px', top: '15px', zIndex: 10000 }, label: 'Accoda', value: isAppendMode, onValueChanged: () => { setIsAppendMode(!isAppendMode); } }), _jsx(TMDataGrid, { focusedRowKey: focusedItem ? focusedItem.rowIndex : undefined, selection: { showCheckBoxesMode: 'none' }, searchPanel: { highlightCaseSensitive: true, visible: true }, dataColumns: customColumns, dataSource: dataSource, keyExpr: 'rowIndex', height: 'calc(100%)', onFocusedRowChanged: onFocusedRowChanged, paging: { pageSize: 30 }, summary: customSummary })] }) }));
148
147
  };
149
148
  export default TMDistinctValues;
@@ -4,12 +4,10 @@ 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) */
7
+ /** predicate function per filtrare gli utenti */
8
8
  filter?: (value: UserDescriptor, index: number, array: UserDescriptor[]) => unknown;
9
9
  /** Visualizza il bordo */
10
10
  showBorder?: boolean;
11
- /** Visualizza colonne con informazioni utente */
12
- showColumnsUserInfo?: boolean;
13
11
  /** Nascondi pulsante aggiorna dati */
14
12
  hideRefresh?: boolean;
15
13
  /** Nascondi pulsante mostra ID */
@@ -20,8 +18,6 @@ export default TMUserChooser;
20
18
  interface ITMUserChooserFormProps extends ITMChooserFormProps<UserDescriptor> {
21
19
  /** predicate function per filtrare i metadati. Significativo per un solo tid (tids) */
22
20
  filter?: (value: UserDescriptor, index: number, array: UserDescriptor[]) => unknown;
23
- /** Visualizza colonne con informazioni utente */
24
- showColumnsUserInfo?: boolean;
25
21
  /** Nascondi pulsante aggiorna dati */
26
22
  hideRefresh?: boolean;
27
23
  /** Nascondi pulsante mostra ID */
@@ -10,30 +10,20 @@ 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, filter, readOnly = false, icon, dataSource, backgroundColor, openChooserBySingleClick, buttons = [], disabled = false, showBorder = true, showColumnsUserInfo = false, hideRefresh = false, hideShowId = false, 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, hideRefresh = false, hideShowId = false, elementStyle, allowMultipleSelection, values, isModifiedWhen, label, placeHolder, validationItems = [], onValueChanged, showClearButton }) => {
14
14
  const [showChooser, setShowChooser] = useState(false);
15
- useEffect(() => {
16
- if (!values || values.length <= 0)
17
- return;
18
- TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.Users} ...` });
19
- UserListCacheService.GetAsync(values[0]).then(() => { TMSpinner.hide(); });
20
- }, [values]);
21
15
  const renderTemplate = () => {
22
16
  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
17
  };
24
18
  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, filter: filter, showColumnsUserInfo: showColumnsUserInfo, selectedIDs: values, hideRefresh: hideRefresh, hideShowId: hideShowId, onClose: () => setShowChooser(false), onChoose: (IDs) => { onValueChanged?.(IDs); } })] }));
19
+ _jsx(TMUserChooserForm, { allowMultipleSelection: allowMultipleSelection, title: titleForm, hasShowOnlySelectedItems: true, dataSource: dataSource, filter: filter, selectedIDs: values, hideRefresh: hideRefresh, hideShowId: hideShowId, onClose: () => setShowChooser(false), onChoose: (IDs) => { onValueChanged?.(IDs); } })] }));
26
20
  };
27
21
  export default TMUserChooser;
28
- export const TMUserChooserForm = ({ allowMultipleSelection, showColumnsUserInfo = false, hideRefresh = false, hideShowId = false, startWithShowOnlySelectedItems = true, filter, title, hasShowOnlySelectedItems, width, height, selectedIDs, dataSource, onClose, onChoose }) => {
29
- const renderDataGridColumns = showColumnsUserInfo ? [
22
+ export const TMUserChooserForm = ({ allowMultipleSelection, hideRefresh = false, hideShowId = false, startWithShowOnlySelectedItems = true, filter, title, hasShowOnlySelectedItems, width, height, selectedIDs, dataSource, onClose, onChoose }) => {
23
+ const renderDataGridColumns = [
30
24
  _jsx(Column, { dataField: "domain", caption: SDKUI_Localizator.Domain, dataType: 'string' }, 2),
31
- _jsx(Column, { dataField: "name", caption: SDKUI_Localizator.UserName, dataType: 'string' }, 3),
32
- _jsx(Column, { dataField: "fn", caption: SDKUI_Localizator.User_FirstName, dataType: 'string' }, 4),
33
- _jsx(Column, { dataField: "ln", caption: SDKUI_Localizator.User_LastName, dataType: 'string' }, 5),
34
- _jsx(Column, { dataField: "description", caption: SDKUI_Localizator.Domain, dataType: 'string' }, 6),
35
- _jsx(Column, { dataField: "mailAddress", caption: SDKUI_Localizator.MetadataFormats_EMail, dataType: 'string' }, 7)
36
- ] : [];
25
+ _jsx(Column, { dataField: "name", caption: SDKUI_Localizator.UserName, dataType: 'string' }, 3)
26
+ ];
37
27
  const getItems = async (refreshCache) => {
38
28
  TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.Users} ...` });
39
29
  if (refreshCache)
@@ -50,7 +40,7 @@ export const TMUserChooserForm = ({ allowMultipleSelection, showColumnsUserInfo
50
40
  return title;
51
41
  };
52
42
  const cellRenderIcon = (data) => _jsx(TMUserIcon, { ud: data.data });
53
- return (_jsx(TMChooserForm, { title: getTitle(), allowMultipleSelection: allowMultipleSelection, startWithShowOnlySelectedItems: startWithShowOnlySelectedItems, hasShowOnlySelectedItems: hasShowOnlySelectedItems, width: width, height: height, manageUseLocalizedName: false, showDefaultColumns: showColumnsUserInfo == undefined ? true : !showColumnsUserInfo, columns: renderDataGridColumns, selectedIDs: selectedIDs, cellRenderIcon: cellRenderIcon, dataSource: dataSource, getItems: getItems, hasShowId: !hideShowId, hideRefresh: hideRefresh, onClose: onClose, onChoose: (IDs) => onChoose?.(IDs) }));
43
+ return (_jsx(TMChooserForm, { title: getTitle(), allowMultipleSelection: allowMultipleSelection, startWithShowOnlySelectedItems: startWithShowOnlySelectedItems, hasShowOnlySelectedItems: hasShowOnlySelectedItems, width: width, height: height, manageUseLocalizedName: false, showDefaultColumns: false, columns: renderDataGridColumns, selectedIDs: selectedIDs, cellRenderIcon: cellRenderIcon, dataSource: dataSource, getItems: getItems, hasShowId: !hideShowId, hideRefresh: hideRefresh, onClose: onClose, onChoose: (IDs) => onChoose?.(IDs) }));
54
44
  };
55
45
  export const TMUserIdViewer = ({ userId, showIcon = false, noneSelectionText = `<${SDKUI_Localizator.NoneSelection}>` }) => {
56
46
  const [ud, setUd] = useState();
@@ -53,7 +53,7 @@ const TMChooserForm = ({ children, title, allowMultipleSelection, startWithShowO
53
53
  onChoose?.(getSelectedIDs());
54
54
  onClose?.();
55
55
  }, onSelectionChanged: (e) => { setSelectedItems(e.selectedRowsData); }, onToolbarPreparing: (e) => { e.toolbarOptions.items.forEach((item) => { if (item.name === "searchPanel")
56
- item.location = "before"; }); }, children: [cellRenderIcon && _jsx(Column, { width: 30, allowResizing: false, allowFiltering: false, allowSorting: false, cellRender: cellRenderIcon }, 0), showDefaultColumns && _jsx(Column, { dataField: "id", visible: showId, dataType: 'number' }, 1), showDefaultColumns && _jsx(Column, { dataField: SDK_Globals.useLocalizedName && manageUseLocalizedName ? "nameLoc" : "name", caption: SDKUI_Localizator.Name, dataType: 'string', defaultSortOrder: allowSorting ? "asc" : undefined, cellRender: cellRenderNameAndDesc }, 2), showDefaultColumns && _jsx(Column, { dataField: "description", dataType: 'string', caption: SDKUI_Localizator.Description, cellRender: cellRenderNameAndDesc }, 3), columns, allowGrouping && _jsx(Grouping, { autoExpandAll: false, expandMode: 'rowClick' }), _jsx(HeaderFilter, { visible: true }), _jsx(Selection, { mode: allowMultipleSelection ? "multiple" : "single", showCheckBoxesMode: "onClick", selectAllMode: 'allPages' }), _jsx(Scrolling, { mode: "standard", useNative: SDKUI_Globals.dataGridUseNativeScrollbar }), _jsx(LoadPanel, { enabled: true }), _jsx(SearchPanel, { visible: true }), _jsx(Paging, { pageSize: 100 }), _jsx(Pager, { visible: true, showInfo: true, showNavigationButtons: true }), _jsxs(Summary, { children: [_jsx(TotalItem, { column: SDK_Globals.useLocalizedName && manageUseLocalizedName ? "nameLoc" : "name", summaryType: "count" }), summaryItems] })] })
56
+ item.location = "before"; }); }, children: [cellRenderIcon && _jsx(Column, { width: 30, allowResizing: false, allowFiltering: false, allowSorting: false, cellRender: cellRenderIcon }, 0), hasShowId && _jsx(Column, { dataField: "id", visible: showId, dataType: 'number' }, 1), showDefaultColumns && _jsx(Column, { dataField: SDK_Globals.useLocalizedName && manageUseLocalizedName ? "nameLoc" : "name", caption: SDKUI_Localizator.Name, dataType: 'string', defaultSortOrder: allowSorting ? "asc" : undefined, cellRender: cellRenderNameAndDesc }, 2), showDefaultColumns && _jsx(Column, { dataField: "description", dataType: 'string', caption: SDKUI_Localizator.Description, cellRender: cellRenderNameAndDesc }, 3), columns, allowGrouping && _jsx(Grouping, { autoExpandAll: false, expandMode: 'rowClick' }), _jsx(HeaderFilter, { visible: true }), _jsx(Selection, { mode: allowMultipleSelection ? "multiple" : "single", showCheckBoxesMode: "onClick", selectAllMode: 'allPages' }), _jsx(Scrolling, { mode: "standard", useNative: SDKUI_Globals.dataGridUseNativeScrollbar }), _jsx(LoadPanel, { enabled: true }), _jsx(SearchPanel, { visible: true }), _jsx(Paging, { pageSize: 100 }), _jsx(Pager, { visible: true, showInfo: true, showNavigationButtons: true }), _jsxs(Summary, { children: [_jsx(TotalItem, { column: SDK_Globals.useLocalizedName && manageUseLocalizedName ? "nameLoc" : "name", summaryType: "count" }), summaryItems] })] })
57
57
  :
58
58
  _jsx(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: _jsx(TMLayoutItem, { children: _jsx("p", { style: { height: "100%", color: TMColors.primaryColor, fontSize: "1.5rem", display: 'flex', alignItems: 'center', justifyContent: 'center' }, children: SDKUI_Localizator.NoDataToDisplay }) }) }) }));
59
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.11.109",
3
+ "version": "6.11.111",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",