From 66ce2ab14502bc96809e06005c339f7e2c02fbaa Mon Sep 17 00:00:00 2001 From: rizky Date: Sun, 18 Aug 2024 21:47:22 -0700 Subject: [PATCH] fix prasi generate master detail --- comps/form/gen/gen-form.ts | 19 +++++++++++++++---- comps/form/gen/gen-form/on-submit.ts | 5 ++++- comps/md/gen/md-list.ts | 3 ++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/comps/form/gen/gen-form.ts b/comps/form/gen/gen-form.ts index bc49659..6d2428e 100755 --- a/comps/form/gen/gen-form.ts +++ b/comps/form/gen/gen-form.ts @@ -25,10 +25,17 @@ export const generateForm = async ( ) => { let table = "" as string; try { - table = eval(data.gen__table.value); - } catch (e) { - table = data.gen__table.value; - } + if ( + data.gen__table.value.startsWith('"') || + data.gen__table.value.startsWith("'") || + data.gen__table.value.startsWith("`") + ) { + table = eval(data.gen__table.value); + } else { + table = data.gen__table.value; + } + } catch (e) {} + const raw_fields = JSON.parse(data.gen__fields.value) as ( | string | { value: string; checked: string[] } @@ -66,6 +73,10 @@ export const generateForm = async ( } if (pk) { + if (typeof table !== "string") { + console.log(data.gen__table.value, table); + } + const gen_form_args = { result, pk, pks, table, select, is_md, rel_many }; if (data["on_load"]) { genFormOnLoad(gen_form_args); diff --git a/comps/form/gen/gen-form/on-submit.ts b/comps/form/gen/gen-form/on-submit.ts index 3efcf7b..ac287e2 100755 --- a/comps/form/gen/gen-form/on-submit.ts +++ b/comps/form/gen/gen-form/on-submit.ts @@ -7,8 +7,11 @@ export const genFormOnSubmit = ({ table, select, is_md, - rel_many + rel_many, }: GenFormArgs) => { + if (typeof table !== "string") { + throw new Error('woi') + } result.on_submit = { mode: "raw", value: `\ diff --git a/comps/md/gen/md-list.ts b/comps/md/gen/md-list.ts index 8e73bf2..f0a44d3 100755 --- a/comps/md/gen/md-list.ts +++ b/comps/md/gen/md-list.ts @@ -106,9 +106,10 @@ idx: any; value: `\ () => { return [ - { label: md.title || "List ${formatName(arg.table)}" }, + { label: md.title || "List ${formatName(arg.table)}" } ] as BreadItem[]; }; + type BreadItem = { label: React.ReactNode; url?: string;