@topconsultnpm/sdkui-react 6.21.0-dev1.21 → 6.21.0-dev1.22
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.
- package/lib/hooks/useForm.js +20 -14
- package/package.json +1 -1
package/lib/hooks/useForm.js
CHANGED
|
@@ -94,21 +94,27 @@ export function useSaveForm(formMode, id, sfo, validator, onSaved, onStatusChang
|
|
|
94
94
|
const saveDataAsync = async (...args) => {
|
|
95
95
|
if (!formData)
|
|
96
96
|
return;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
newId =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
newData
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
97
|
+
try {
|
|
98
|
+
TMSpinner.show({ description: `${SDKUI_Localizator.SavingInProgress}...`, backgroundColor: 'transparent' });
|
|
99
|
+
let newId = -1;
|
|
100
|
+
if (saveCustomAsync)
|
|
101
|
+
newId = await saveCustomAsync();
|
|
102
|
+
else
|
|
103
|
+
newId = await setDataAsync?.(formMode, formData, ...args);
|
|
104
|
+
let newData;
|
|
105
|
+
if (sfo.loadDataAfterSave)
|
|
106
|
+
newData = await loadDataAsync(newId, FormModes.Update);
|
|
107
|
+
else {
|
|
108
|
+
newData = formData;
|
|
109
|
+
newData.id = newId;
|
|
110
|
+
setFormData(newData);
|
|
111
|
+
setFormDataOrig(newData);
|
|
112
|
+
}
|
|
113
|
+
onSaved?.(newData);
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
TMSpinner.hide();
|
|
110
117
|
}
|
|
111
|
-
onSaved?.(newData);
|
|
112
118
|
};
|
|
113
119
|
useEffect(() => { id && loadDataAsync(id, formMode); }, [id, formMode]);
|
|
114
120
|
useEffect(() => {
|