This commit is contained in:
rizky 2024-07-19 01:30:54 -07:00
parent 780be87439
commit 5cdb3ab853
3 changed files with 33 additions and 32 deletions

View File

@ -443,45 +443,46 @@ type IForm = { form: any; error: Record<string, string>; fm: FMLocal }
align: "top-left",
},
};
const child_body = createItem({
name: "item",
...body_prop,
childs: [
createItem({
adv: {
js: '<div {...props} className={cx(props.className, "form-fields")}>\n {children}\n</div>',
jsBuilt:
'render(/* @__PURE__ */ React.createElement("div", { ...props, className: cx(props.className, "form-fields") }, children));\n',
},
dim: {
w: "full",
h: "full",
wUnit: "px",
hUnit: "px",
},
name: "fields",
layout: {
dir: "row",
align: "top-left",
gap: 0,
wrap: "flex-nowrap",
},
childs: child_fields,
}),
submit,
].filter((e) => e),
});
if (commit) {
Object.keys(result).map((e) => {
item.edit.setProp(e, result[e]);
});
item.edit.setProp("body", {
mode: "jsx",
value: createItem({
name: "item",
...body_prop,
childs: [
createItem({
adv: {
js: '<div {...props} className={cx(props.className, "form-fields")}>\n {children}\n</div>',
jsBuilt:
'render(/* @__PURE__ */ React.createElement("div", { ...props, className: cx(props.className, "form-fields") }, children));\n',
},
dim: {
w: "full",
h: "full",
wUnit: "px",
hUnit: "px",
},
name: "fields",
layout: {
dir: "row",
align: "top-left",
gap: 0,
wrap: "flex-nowrap",
},
childs: child_fields,
}),
submit,
].filter((e) => e),
}),
value: child_body,
});
await item.edit.commit();
} else {
set(data, "body.value", { ...data.body?.value, ...body_prop });
set(data, "body.value.childs", child_fields);
set(data, "body.value.childs", child_body.childs);
Object.keys(result).map((e) => {
set(data, e, result[e]);
});

View File

@ -1,6 +1,6 @@
import { GenFn } from "lib/gen/utils";
import { generateMDForm } from "./md-form";
import { generateList } from "./md-list";
import { generateMDList } from "./md-list";
const w = window as any;
export const generateMasterDetail: GenFn<{
@ -20,7 +20,7 @@ export const generateMasterDetail: GenFn<{
}
} catch (e) {}
await generateList(arg, data, false);
await generateMDList(arg, data, false);
await generateMDForm(arg, data, false);
await item.edit.commit();
};

View File

@ -3,7 +3,7 @@ import { createItem } from "lib/gen/utils";
import get from "lodash.get";
import { generateTableList } from "./gen-table-list";
export const generateList = async (
export const generateMDList = async (
arg: { item: PrasiItem; table: string; fields: any },
data: any,
commit: boolean