@topconsultnpm/sdkui-react-beta 6.11.109 → 6.11.110

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;
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.110",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",