From 2ae5e5e90be92ccf3d682e2c60410ea491370df4 Mon Sep 17 00:00:00 2001 From: rizrmd Date: Wed, 17 Jul 2024 05:19:12 +0000 Subject: [PATCH] fix error message when saving --- comps/form/gen/gen-form.ts | 32 +++++++++++++++----------------- comps/form/utils/init.tsx | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/comps/form/gen/gen-form.ts b/comps/form/gen/gen-form.ts index 76658be..174866e 100755 --- a/comps/form/gen/gen-form.ts +++ b/comps/form/gen/gen-form.ts @@ -192,28 +192,26 @@ ${ call_prasi_events("form", "after_save", [fm, data]); + ${ + is_md && + `\ + if (typeof md !== "undefined") { + fm.status = "ready"; + // kembali ke tabel + setTimeout(() => { + md.selected = null; + md.tab.active = "master"; + md.internal.action_should_refresh = true; + md.params.apply(); + md.render(); + }, 500); + }` + } } catch (e) { console.error(e); result = false; } -${ - is_md && - `\ - if (typeof md !== "undefined") { - fm.status = "ready"; - // kembali ke tabel - setTimeout(() => { - md.selected = null; - md.tab.active = "master"; - md.internal.action_should_refresh = true; - md.params.apply(); - md.render(); - }, 500); - }` -} - - return result; }; diff --git a/comps/form/utils/init.tsx b/comps/form/utils/init.tsx index bbb8fb6..88fd322 100755 --- a/comps/form/utils/init.tsx +++ b/comps/form/utils/init.tsx @@ -126,16 +126,26 @@ export const formInit = (fm: FMLocal, props: FMProps) => { toast.dismiss(); done_all(success); + + if (!success) { + fm.status = "ready"; + fm.render(); + } + if (fm.props.sonar === "on" && !isEditor) { setTimeout(() => { toast.dismiss(); if (!success) { + const count = Object.keys(fm.error.list).length; toast.error(
- Save Failed, please correct{" "} - {Object.keys(fm.error.list).length} errors. + Save Failed + {count > 0 && + `, please correct + ${count} errors`} + .
, { dismissible: true,