fix prasi generate master detail

This commit is contained in:
rizky 2024-08-18 21:47:22 -07:00
parent 0b2aabbfb3
commit 66ce2ab145
3 changed files with 21 additions and 6 deletions

View File

@ -25,10 +25,17 @@ export const generateForm = async (
) => {
let table = "" as string;
try {
if (
data.gen__table.value.startsWith('"') ||
data.gen__table.value.startsWith("'") ||
data.gen__table.value.startsWith("`")
) {
table = eval(data.gen__table.value);
} catch (e) {
} 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);

View File

@ -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: `\

View File

@ -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;