@topconsultnpm/sdkui-react-beta 6.6.38 → 6.6.40
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.
|
@@ -90,7 +90,7 @@ const TMSaveForm = ({ id, formMode = FormModes.Update, title, children, isModal,
|
|
|
90
90
|
const warningsCount = validationItems.filter(o => o.ResultType == ResultTypes.WARNING).length;
|
|
91
91
|
const errorsCount = validationItems.filter(o => o.ResultType == ResultTypes.ERROR).length;
|
|
92
92
|
const renderSaveForm = () => {
|
|
93
|
-
return (_jsxs(TMLayoutContainer, { direction: 'vertical', children: [_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
|
|
93
|
+
return (_jsxs(TMLayoutContainer, { direction: 'vertical', children: [_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 }), _jsx(TMButton, { caption: SDKUI_Localizator.Undo, icon: _jsx(IconUndo, {}), keyGesture: "alt+z", color: "tertiary", btnStyle: "toolbar", disabled: isModified ? false : true, onClick: onUndo }), customToolbarElements, warningsCount > 0 &&
|
|
94
94
|
_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 })] }) }), errorsCount > 0 &&
|
|
95
95
|
_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 &&
|
|
96
96
|
_jsx("div", { style: { right: '10px', position: 'absolute' }, children: !isMobile && _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/hooks/useForm.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { FormModes } from "../ts";
|
|
2
2
|
import { JobTypes, ObjectClasses, ValidationItem } from "@topconsultnpm/sdk-ts-beta";
|
|
3
|
-
export declare
|
|
3
|
+
export declare class SaveFormOptions {
|
|
4
|
+
loadDataAfterSave: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function useSaveForm<T>(formMode: FormModes, id: number | undefined, objClass: ObjectClasses, objType: JobTypes | undefined, sfo: SaveFormOptions, validator?: (d: T) => Promise<ValidationItem[] | undefined>, onSaved?: (newDescriptor: T) => void, onStatusChanged?: (isModified: boolean, isValid: boolean) => void, customizeData?: (d: T) => T): {
|
|
4
7
|
formData: T | undefined;
|
|
5
8
|
setFormData: import("react").Dispatch<import("react").SetStateAction<T | undefined>>;
|
|
6
9
|
formDataOrig: T | undefined;
|
package/lib/hooks/useForm.js
CHANGED
|
@@ -4,7 +4,12 @@ import { TMExceptionBoxManager, TMSpinner } from "../components";
|
|
|
4
4
|
import { DataListDescriptor, DiskDescriptor, JobEngine, JobTypes, ObjectClasses, ProcessEngine, ResultTypes, SavedQueryEngine, SDK_Globals, TaskDescriptor } from "@topconsultnpm/sdk-ts-beta";
|
|
5
5
|
import { PlatformObjectService } from "../services";
|
|
6
6
|
import { SDKUI_Localizator, calcIsModified } from "../helper";
|
|
7
|
-
export
|
|
7
|
+
export class SaveFormOptions {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.loadDataAfterSave = true;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function useSaveForm(formMode, id, objClass, objType = JobTypes.None, sfo, validator, onSaved, onStatusChanged, customizeData) {
|
|
8
13
|
const [formData, setFormData] = useState();
|
|
9
14
|
const [formDataOrig, setFormDataOrig] = useState();
|
|
10
15
|
const [exception, setException] = useState();
|
|
@@ -61,7 +66,7 @@ export function useSaveForm(objClass, formMode, id, objType = JobTypes.None, val
|
|
|
61
66
|
if (!formData)
|
|
62
67
|
return;
|
|
63
68
|
let newId = await setDataAsync?.(formMode, formData);
|
|
64
|
-
let newData = await loadDataAsync(newId, FormModes.Update);
|
|
69
|
+
let newData = sfo.loadDataAfterSave ? await loadDataAsync(newId, FormModes.Update) : formData;
|
|
65
70
|
onSaved?.(newData);
|
|
66
71
|
};
|
|
67
72
|
useEffect(() => { id && loadDataAsync(id, formMode); }, [id, formMode]);
|