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", 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) { if (commit) {
Object.keys(result).map((e) => { Object.keys(result).map((e) => {
item.edit.setProp(e, result[e]); item.edit.setProp(e, result[e]);
}); });
item.edit.setProp("body", { item.edit.setProp("body", {
mode: "jsx", mode: "jsx",
value: createItem({ value: child_body,
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),
}),
}); });
await item.edit.commit(); await item.edit.commit();
} else { } else {
set(data, "body.value", { ...data.body?.value, ...body_prop }); 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) => { Object.keys(result).map((e) => {
set(data, e, result[e]); set(data, e, result[e]);
}); });

View File

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

View File

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