@topconsultnpm/sdkui-react-beta 6.12.27 → 6.12.29
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.
@@ -41,6 +41,15 @@ const TMChooserForm = ({ children, title, allowMultipleSelection = false, startW
|
|
41
41
|
const ToolbarButtons = () => {
|
42
42
|
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', gap: '2px' }, children: [_jsx(TMButton, { btnStyle: 'toolbar', caption: SDKUI_Localizator.Apply, disabled: selectedRowCounter.length <= 0, icon: _jsx(IconApply, {}), color: 'success', fontSize: '1.3rem', onClick: () => { onChoose?.(getSelectedIDs()); onClose?.(); } }), hasShowId ? _jsx(TMButton, { btnStyle: 'toolbar', caption: showId ? SDKUI_Localizator.ID_Hide : SDKUI_Localizator.ID_Show, icon: showId ? _jsx(IconHide, {}) : _jsx(IconShow, {}), fontSize: '1.3rem', onClick: () => { setShowId(!showId); onShowIdChanged?.(); } }) : _jsx(_Fragment, {}), !hideRefresh && _jsx(TMButton, { btnStyle: 'toolbar', caption: SDKUI_Localizator.Refresh, icon: _jsx(IconRefresh, {}), fontSize: '1.3rem', onClick: () => { doGetItems(true); } }), customButtons, hasShowOnlySelectedItems && allowMultipleSelection && _jsx(TMToggleButton, { value: showOnlySelectedItems, elementStyle: { marginLeft: '10px' }, label: 'Mostra solo selezionati', onValueChanged: () => setShowOnlySelectedItems(!showOnlySelectedItems) })] }));
|
43
43
|
};
|
44
|
+
/** check if it's possible to manage double-click to choose */
|
45
|
+
const allowChooseDoubleClick = () => {
|
46
|
+
if (!allowMultipleSelection)
|
47
|
+
return true;
|
48
|
+
if (selectedRowCounter.length <= 0)
|
49
|
+
return true;
|
50
|
+
return false;
|
51
|
+
};
|
52
|
+
/** Handle the selection changed when allowMultipleSelection */
|
44
53
|
const handleSelectionChanged = useCallback((e) => {
|
45
54
|
const selectedKeys = e.component.getSelectedRowKeys() ?? [];
|
46
55
|
setSelectedRowCounter(selectedKeys);
|
@@ -48,12 +57,14 @@ const TMChooserForm = ({ children, title, allowMultipleSelection = false, startW
|
|
48
57
|
return;
|
49
58
|
setSelectedRowKeys(selectedKeys);
|
50
59
|
}, [selectedRowKeys]);
|
60
|
+
/** Handle the row double-click event */
|
51
61
|
const handleRowDoubleClick = useCallback(() => {
|
52
|
-
if (
|
62
|
+
if (!allowChooseDoubleClick())
|
53
63
|
return;
|
54
64
|
onChoose?.(getFocusedIDs());
|
55
65
|
onClose?.();
|
56
|
-
}, [
|
66
|
+
}, [allowChooseDoubleClick, onChoose, onClose, getFocusedIDs]);
|
67
|
+
/** Handle the focused row changed */
|
57
68
|
const handleFocusedRowChange = useCallback((e) => {
|
58
69
|
setFocusedRowKey(e.row?.key);
|
59
70
|
}, []);
|
@@ -12,7 +12,7 @@ import TMValidationItemsList from '../grids/TMValidationItemsList';
|
|
12
12
|
import TMModal from '../base/TMModal';
|
13
13
|
import { DeviceType, useDeviceType } from '../base/TMDeviceProvider';
|
14
14
|
import toppy from '../../assets/Toppy-generico.png';
|
15
|
-
const TMSaveForm = ({ id, formMode = FormModes.Update, showToolbar = true, skipIsModifiedCheck = false, title, children, isModal, exception, customToolbarElements, hasNavigation, showBackButton, showWarningsCount = true, showErrorCount = true, showUndoButton = true, onClose, onSaveAsync, onNext, onPrev, canNext, canPrev, isModified, onShowList, validationItems = [], onUndo, onCancel, width, height }) => {
|
15
|
+
const TMSaveForm = ({ id, formMode = FormModes.Update, showToolbar = true, skipIsModifiedCheck = false, title, children, isModal, exception, customToolbarElements, hasNavigation, showSaveButton = true, showBackButton, showWarningsCount = true, showErrorCount = true, showUndoButton = true, onClose, onSaveAsync, onNext, onPrev, canNext, canPrev, isModified, onShowList, validationItems = [], onUndo, onCancel, width, height }) => {
|
16
16
|
const [showList, setShowList] = useState(true);
|
17
17
|
const [showErrorGrid, setShowErrorGrid] = useState(false);
|
18
18
|
const [showConfirmForClose, setShowConfirmForClose] = useState(false);
|
@@ -111,7 +111,7 @@ const TMSaveForm = ({ id, formMode = FormModes.Update, showToolbar = true, skipI
|
|
111
111
|
const warningsCount = validationItems.filter(o => o.ResultType == ResultTypes.WARNING).length;
|
112
112
|
const errorsCount = validationItems.filter(o => o.ResultType == ResultTypes.ERROR).length;
|
113
113
|
const renderSaveForm = () => {
|
114
|
-
return (_jsxs(TMLayoutContainer, { direction: 'vertical', children: [showToolbar && _jsx(TMLayoutItem, { height: 'max-content', children: _jsxs(StyledToolbarForm, { children: [showBackButton && _jsx(TMButton, { btnStyle: 'toolbar', color: 'tertiary', caption: SDKUI_Localizator.Back, icon: _jsx(IconArrowLeft, {}), elementStyle: { marginRight: '10px' }, onClick: () => { doClose(); } }), _jsx(TMButton, { caption: SDKUI_Localizator.Save, icon: _jsx(IconSave, {}), keyGesture: "alt+s", backgroundColor: errorsCount > 0 ? TMColors.error : isModified ? TMColors.success : TMColors.disabled, onClick: doSaveAsync, color: "success", btnStyle: "toolbar", disabled: !(isModified && errorsCount <= 0) }), hasNavigation && _jsx(TMButton, { caption: SDKUI_Localizator.Previous, icon: _jsx(IconArrowUp, {}), btnStyle: "toolbar", disabled: !canPrev || isModified || formMode == FormModes.Create || formMode == FormModes.Duplicate, onClick: doPrev }), hasNavigation && _jsx(TMButton, { caption: SDKUI_Localizator.Next, icon: _jsx(IconArrowDown, {}), btnStyle: "toolbar", disabled: !canNext || isModified || formMode == FormModes.Create || formMode == FormModes.Duplicate, onClick: doNext }), showUndoButton && _jsx(TMButton, { caption: SDKUI_Localizator.Undo, icon: _jsx(IconUndo, {}), keyGesture: "alt+z", color: "tertiary", btnStyle: "toolbar", disabled: isModified ? false : true, onClick: onUndo }), customToolbarElements, Boolean(showWarningsCount && warningsCount > 0) &&
|
114
|
+
return (_jsxs(TMLayoutContainer, { direction: 'vertical', children: [showToolbar && _jsx(TMLayoutItem, { height: 'max-content', children: _jsxs(StyledToolbarForm, { children: [showBackButton && _jsx(TMButton, { btnStyle: 'toolbar', color: 'tertiary', caption: SDKUI_Localizator.Back, icon: _jsx(IconArrowLeft, {}), elementStyle: { marginRight: '10px' }, onClick: () => { doClose(); } }), showSaveButton && _jsx(TMButton, { caption: SDKUI_Localizator.Save, icon: _jsx(IconSave, {}), keyGesture: "alt+s", backgroundColor: errorsCount > 0 ? TMColors.error : isModified ? TMColors.success : TMColors.disabled, onClick: doSaveAsync, color: "success", btnStyle: "toolbar", disabled: !(isModified && errorsCount <= 0) }), hasNavigation && _jsx(TMButton, { caption: SDKUI_Localizator.Previous, icon: _jsx(IconArrowUp, {}), btnStyle: "toolbar", disabled: !canPrev || isModified || formMode == FormModes.Create || formMode == FormModes.Duplicate, onClick: doPrev }), hasNavigation && _jsx(TMButton, { caption: SDKUI_Localizator.Next, icon: _jsx(IconArrowDown, {}), btnStyle: "toolbar", disabled: !canNext || isModified || formMode == FormModes.Create || formMode == FormModes.Duplicate, onClick: doNext }), showUndoButton && _jsx(TMButton, { caption: SDKUI_Localizator.Undo, icon: _jsx(IconUndo, {}), keyGesture: "alt+z", color: "tertiary", btnStyle: "toolbar", disabled: isModified ? false : true, onClick: onUndo }), customToolbarElements, Boolean(showWarningsCount && warningsCount > 0) &&
|
115
115
|
_jsx(TMLayoutItem, { width: 'fit-content', height: '90%', children: _jsxs(StyledResultTypeContainer, { style: { marginLeft: '10px' }, onClick: () => setShowErrorGrid(!showErrorGrid), "$resultType": ResultTypes.WARNING, children: [" ", _jsx(IconWarning, { fontSize: 16 }), " ", _jsx("span", { children: warningsCount })] }) }), Boolean(showErrorCount && errorsCount > 0) &&
|
116
116
|
_jsx(TMLayoutItem, { width: 'fit-content', height: '90%', children: _jsxs(StyledResultTypeContainer, { style: { marginLeft: warningsCount <= 0 ? '10px' : '0' }, onClick: () => setShowErrorGrid(!showErrorGrid), "$resultType": ResultTypes.ERROR, children: [" ", _jsx(IconCloseCircle, { fontSize: 16 }), " ", _jsx("span", { children: errorsCount })] }) }), onShowList &&
|
117
117
|
_jsx("div", { style: { right: '10px', position: 'absolute' }, children: deviceType !== DeviceType.MOBILE && _jsx(TMButton, { caption: showList ? SDKUI_Localizator.List_Hide : SDKUI_Localizator.List_Show, icon: showList ? _jsx(IconHide, {}) : _jsx(IconShow, {}), keyGesture: "alt+h", onClick: () => { setShowList(!showList); onShowList?.(!showList); }, btnStyle: 'toolbar' }) }), (formMode == FormModes.Create || formMode == FormModes.Duplicate) &&
|
package/lib/ts/types.d.ts
CHANGED