diff --git a/gen/gen_form/gen_form.ts b/gen/gen_form/gen_form.ts index 97355ef..c527057 100755 --- a/gen/gen_form/gen_form.ts +++ b/gen/gen_form/gen_form.ts @@ -60,6 +60,11 @@ export const gen_form = (modify: (data: any) => void, data: any) => { } const result: any = {}; + + if (!pk) { + alert("Failed to generate! Primary Key not found. "); + return; + } if (pk) { if (mode.includes("on_load")) { result["on_load"] = data["on_load"]; diff --git a/gen/gen_form/on_load.ts b/gen/gen_form/on_load.ts index 133c473..f919bec 100755 --- a/gen/gen_form/on_load.ts +++ b/gen/gen_form/on_load.ts @@ -13,6 +13,7 @@ export const on_load = ({ pks: Record; opt?: { before_load: string; + after_load: string; }; }) => { return `\ @@ -22,8 +23,9 @@ async (opt) => { let id = ${pk.type === "int" ? "parseInt(params.id)" : "params.id"}; ${opt?.before_load} + let item = {}; if (id){ - const item = await db.${table}.findFirst({ + item = await db.${table}.findFirst({ where: { ${pk.name}: id, }, @@ -40,9 +42,12 @@ async (opt) => { }`; }) .join("\n")} - } + + ${opt?.after_load} return item; + } else { + ${opt?.after_load} } }`; }; diff --git a/gen/gen_md/form_before_load.ts b/gen/gen_md/form_before_load.ts index 5ffa00b..8371859 100755 --- a/gen/gen_md/form_before_load.ts +++ b/gen/gen_md/form_before_load.ts @@ -1,4 +1,9 @@ -export const form_before_load = (pk: string, title: string, name: string) => { +export const form_before_load = ( + table: string, + pk: string, + title: string, + label: string +) => { return ` const after_load = (item: any) => { const set_actions = () => @@ -11,7 +16,7 @@ export const form_before_load = (pk: string, title: string, name: string) => { md.ui.actions = [{ label: "Deleting...", type: "ghost" }]; md.render(); - await db.m_aset.delete({ where: { ${pk}: item.${pk} } }); + await db.${table}.delete({ where: { ${pk}: item.${pk} } }); setTimeout(() => { md.ui.actions = [...md.ui.default_actions]; @@ -39,8 +44,11 @@ export const form_before_load = (pk: string, title: string, name: string) => { }, ]); set_actions(); - md.ui.breadcrumb = [[${title}, ""], item?.nama_aset_komersial]; + md.ui.breadcrumb = [["${title}", ""]${label ? `, item?.["${label}"]` : ""}]; md.render(); }; + md.ui.breadcrumb = [["${title}", ""], "..."]; + md.render(); + `; }; diff --git a/gen/gen_md/gen_detail.ts b/gen/gen_md/gen_detail.ts index 828debd..2b68a0a 100755 --- a/gen/gen_md/gen_detail.ts +++ b/gen/gen_md/gen_detail.ts @@ -383,2383 +383,7 @@ export const gen_detail = () => { }, name: "body", type: "item", - childs: [ - { - id: createId(), - adv: { - js: '\n \n', - css: "", - jsBuilt: - 'render(/* @__PURE__ */ React.createElement(\n "div",\n {\n ...props,\n className: cx(\n "field",\n css`\n width:100%;\n border-bottom:1px solid white;\n padding: 10px;`\n )\n },\n /* @__PURE__ */ React.createElement(\n Field,\n {\n label,\n name,\n type,\n selection,\n label_alt,\n options,\n on_change,\n form,\n custom,\n PassProp,\n required,\n child,\n slider,\n placeholder,\n suffix\n }\n )\n));\n', - }, - dim: { - h: "full", - w: "full", - }, - name: "field", - type: "item", - childs: [], - mobile: { - dim: { - h: "full", - w: "full", - hUnit: "px", - }, - border: { - color: "#ba2f2f", - style: "solid", - stroke: { - b: 1, - }, - }, - padding: { - b: 5, - l: 15, - r: 15, - t: 5, - }, - }, - script: {}, - component: { - id: "32550d01-42a3-4b15-a04a-2c2d5c3c8e67", - props: { - name: { - idx: 0, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`nama_aset`", - is_name: true, - valueBuilt: "`nama_aset`", - }, - type: { - idx: 4, - meta: { - type: "option", - options: - '[\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link",\n]', - option_mode: "dropdown", - optionsBuilt: - ' [\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link"\n];\n', - }, - name: "prop_3", - type: "string", - value: '"text"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "type", - type: "item", - childs: [], - }, - is_name: false, - valueBuilt: '"text"', - }, - child: { - idx: 11, - meta: { - type: "content-element", - }, - name: "prop_11", - type: "string", - value: '"hello"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "child", - type: "item", - childs: [], - }, - is_name: false, - typings: - 'const typings = {\n data: "any",\n is_active: "boolean",\n item_click: "() => void",\n current_name: "string",\n option_item: "{value: string, label: string}",\n modify: `(field_name: string, opt: {\n value?: any,\n }) => void`,\n}', - visible: 'type === "radio"', - valueBuilt: '"hello"', - }, - label: { - idx: 1, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`Nama Aset`", - is_name: false, - valueBuilt: "`Nama Aset`", - }, - custom: { - idx: 8, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]\n', - option_mode: "button", - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_11", - type: "string", - value: '"n"', - is_name: false, - valueBuilt: ' "n";\n', - }, - slider: { - idx: 9, - meta: { - type: "text", - }, - name: "prop_9", - type: "string", - value: - 'async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" },\n };\n}', - is_name: false, - visible: "type === 'slider'", - valueBuilt: - ' async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" }\n };\n};\n', - }, - suffix: { - idx: 12, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["number", "text", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - options: { - idx: 6, - meta: { - type: "text", - }, - name: "prop_5", - type: "string", - value: - 'async () => {\r\n return [\r\n {\r\n value: "sample1",\r\n label: "sample1",\r\n },\r\n {\r\n value: "sample2",\r\n label: "sample2",\r\n },\r\n ];\r\n}', - is_name: false, - visible: - "['button-options', 'dropdown', 'radio'].includes(type)", - valueBuilt: - ' async () => {\n return [\n {\n value: "sample1",\n label: "sample1"\n },\n {\n value: "sample2",\n label: "sample2"\n }\n ];\n};\n', - }, - required: { - idx: 7, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]', - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_7", - type: "string", - value: "`n`", - is_name: false, - valueBuilt: "`n`", - }, - label_alt: { - idx: 2, - meta: { - type: "text", - }, - name: "prop_10", - type: "string", - value: '""', - is_name: false, - valueBuilt: ' "";\n', - }, - on_change: { - idx: 10, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: "({ value }) => {}", - is_name: false, - valueBuilt: " ({ value }) => {\n};\n", - }, - selection: { - idx: 5, - meta: { - type: "option", - options: '["single", "multi"]', - optionsBuilt: ' ["single", "multi"];\n', - }, - name: "prop_11", - type: "string", - value: '"single"', - visible: 'type === "radio"', - valueBuilt: ' "single";\n', - }, - placeholder: { - idx: 3, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["text", "number", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - rel_query: { - idx: 11, - name: "prop_11", - type: "string", - value: - 'async () => {\n return {\n orderBy: {\n regional: "asc",\n },\n };\n}', - valueBuilt: - ' async () => {\n return {\n orderBy: {\n regional: "asc"\n }\n };\n};\n', - meta: { - type: "text", - }, - }, - rel_table: { - idx: 11, - name: "prop_11", - type: "string", - value: '""', - valueBuilt: '""', - meta: { - type: "text", - }, - content: { - id: createId(), - name: "rel_table", - type: "item", - dim: { - w: "full", - h: "full", - }, - childs: [], - adv: { - css: "", - }, - }, - }, - rel_fields: { - idx: 11, - name: "prop_11", - type: "string", - value: "[]", - valueBuilt: "[]", - meta: { - type: "option", - }, - }, - default_value: { - idx: 11, - name: "prop_11", - type: "string", - value: '"hello"', - valueBuilt: '"hello"', - meta: { - type: "text", - }, - }, - }, - ref_ids: {}, - instances: {}, - }, - }, - { - id: createId(), - adv: { - js: '\n \n', - css: "", - jsBuilt: - 'render(/* @__PURE__ */ React.createElement(\n "div",\n {\n ...props,\n className: cx(\n "field",\n css`\n width:100%;\n border-bottom:1px solid white;\n padding: 10px;`\n )\n },\n /* @__PURE__ */ React.createElement(\n Field,\n {\n label,\n name,\n type,\n selection,\n label_alt,\n options,\n on_change,\n form,\n custom,\n PassProp,\n required,\n child,\n slider,\n placeholder,\n suffix\n }\n )\n));\n', - }, - dim: { - h: "full", - w: "full", - }, - name: "field", - type: "item", - childs: [], - mobile: { - dim: { - h: "full", - w: "full", - hUnit: "px", - }, - border: { - color: "#ba2f2f", - style: "solid", - stroke: { - b: 1, - }, - }, - padding: { - b: 5, - l: 15, - r: 15, - t: 5, - }, - }, - script: {}, - component: { - id: "32550d01-42a3-4b15-a04a-2c2d5c3c8e67", - props: { - name: { - idx: 0, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`nama_aset_keuangan`", - is_name: true, - valueBuilt: "`nama_aset_keuangan`", - }, - type: { - idx: 4, - meta: { - type: "option", - options: - '[\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link",\n]', - option_mode: "dropdown", - optionsBuilt: - ' [\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link"\n];\n', - }, - name: "prop_3", - type: "string", - value: '"text"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "type", - type: "item", - childs: [], - }, - is_name: false, - valueBuilt: '"text"', - }, - child: { - idx: 11, - meta: { - type: "content-element", - }, - name: "prop_11", - type: "string", - value: '"hello"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "child", - type: "item", - childs: [], - }, - is_name: false, - typings: - 'const typings = {\n data: "any",\n is_active: "boolean",\n item_click: "() => void",\n current_name: "string",\n option_item: "{value: string, label: string}",\n modify: `(field_name: string, opt: {\n value?: any,\n }) => void`,\n}', - visible: 'type === "radio"', - valueBuilt: '"hello"', - }, - label: { - idx: 1, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`Nama Aset Keuangan`", - is_name: false, - valueBuilt: "`Nama Aset Keuangan`", - }, - custom: { - idx: 8, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]\n', - option_mode: "button", - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_11", - type: "string", - value: '"n"', - is_name: false, - valueBuilt: ' "n";\n', - }, - slider: { - idx: 9, - meta: { - type: "text", - }, - name: "prop_9", - type: "string", - value: - 'async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" },\n };\n}', - is_name: false, - visible: "type === 'slider'", - valueBuilt: - ' async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" }\n };\n};\n', - }, - suffix: { - idx: 12, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["number", "text", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - options: { - idx: 6, - meta: { - type: "text", - }, - name: "prop_5", - type: "string", - value: - 'async () => {\r\n return [\r\n {\r\n value: "sample1",\r\n label: "sample1",\r\n },\r\n {\r\n value: "sample2",\r\n label: "sample2",\r\n },\r\n ];\r\n}', - is_name: false, - visible: - "['button-options', 'dropdown', 'radio'].includes(type)", - valueBuilt: - ' async () => {\n return [\n {\n value: "sample1",\n label: "sample1"\n },\n {\n value: "sample2",\n label: "sample2"\n }\n ];\n};\n', - }, - required: { - idx: 7, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]', - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_7", - type: "string", - value: "`n`", - is_name: false, - valueBuilt: "`n`", - }, - label_alt: { - idx: 2, - meta: { - type: "text", - }, - name: "prop_10", - type: "string", - value: '""', - is_name: false, - valueBuilt: ' "";\n', - }, - on_change: { - idx: 10, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: "({ value }) => {}", - is_name: false, - valueBuilt: " ({ value }) => {\n};\n", - }, - selection: { - idx: 5, - meta: { - type: "option", - options: '["single", "multi"]', - optionsBuilt: ' ["single", "multi"];\n', - }, - name: "prop_11", - type: "string", - value: '"single"', - visible: 'type === "radio"', - valueBuilt: ' "single";\n', - }, - placeholder: { - idx: 3, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["text", "number", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - rel_query: { - idx: 11, - name: "prop_11", - type: "string", - value: - 'async () => {\n return {\n orderBy: {\n regional: "asc",\n },\n };\n}', - valueBuilt: - ' async () => {\n return {\n orderBy: {\n regional: "asc"\n }\n };\n};\n', - meta: { - type: "text", - }, - }, - - rel_table: { - idx: 11, - name: "prop_11", - type: "string", - value: '""', - valueBuilt: '""', - meta: { - type: "text", - }, - content: { - id: createId(), - name: "rel_table", - type: "item", - dim: { - w: "full", - h: "full", - }, - childs: [], - adv: { - css: "", - }, - }, - }, - rel_fields: { - idx: 11, - name: "prop_11", - type: "string", - value: "[]", - valueBuilt: "[]", - meta: { - type: "option", - }, - }, - default_value: { - idx: 11, - name: "prop_11", - type: "string", - value: '"hello"', - valueBuilt: '"hello"', - meta: { - type: "text", - }, - }, - }, - ref_ids: {}, - instances: {}, - }, - }, - { - id: createId(), - adv: { - js: '\n \n', - css: "", - jsBuilt: - 'render(/* @__PURE__ */ React.createElement(\n "div",\n {\n ...props,\n className: cx(\n "field",\n css`\n width:100%;\n border-bottom:1px solid white;\n padding: 10px;`\n )\n },\n /* @__PURE__ */ React.createElement(\n Field,\n {\n label,\n name,\n type,\n selection,\n label_alt,\n options,\n on_change,\n form,\n custom,\n PassProp,\n required,\n child,\n slider,\n placeholder,\n suffix\n }\n )\n));\n', - }, - dim: { - h: "full", - w: "full", - }, - name: "field", - type: "item", - childs: [], - mobile: { - dim: { - h: "full", - w: "full", - hUnit: "px", - }, - border: { - color: "#ba2f2f", - style: "solid", - stroke: { - b: 1, - }, - }, - padding: { - b: 5, - l: 15, - r: 15, - t: 5, - }, - }, - script: {}, - component: { - id: "32550d01-42a3-4b15-a04a-2c2d5c3c8e67", - props: { - name: { - idx: 0, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`nama_aset_komersial`", - is_name: true, - valueBuilt: "`nama_aset_komersial`", - }, - type: { - idx: 4, - meta: { - type: "option", - options: - '[\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link",\n]', - option_mode: "dropdown", - optionsBuilt: - ' [\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link"\n];\n', - }, - name: "prop_3", - type: "string", - value: '"text"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "type", - type: "item", - childs: [], - }, - is_name: false, - valueBuilt: '"text"', - }, - child: { - idx: 11, - meta: { - type: "content-element", - }, - name: "prop_11", - type: "string", - value: '"hello"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "child", - type: "item", - childs: [], - }, - is_name: false, - typings: - 'const typings = {\n data: "any",\n is_active: "boolean",\n item_click: "() => void",\n current_name: "string",\n option_item: "{value: string, label: string}",\n modify: `(field_name: string, opt: {\n value?: any,\n }) => void`,\n}', - visible: 'type === "radio"', - valueBuilt: '"hello"', - }, - label: { - idx: 1, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`Nama Aset Komersial`", - is_name: false, - valueBuilt: "`Nama Aset Komersial`", - }, - custom: { - idx: 8, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]\n', - option_mode: "button", - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_11", - type: "string", - value: '"n"', - is_name: false, - valueBuilt: ' "n";\n', - }, - slider: { - idx: 9, - meta: { - type: "text", - }, - name: "prop_9", - type: "string", - value: - 'async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" },\n };\n}', - is_name: false, - visible: "type === 'slider'", - valueBuilt: - ' async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" }\n };\n};\n', - }, - suffix: { - idx: 12, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["number", "text", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - options: { - idx: 6, - meta: { - type: "text", - }, - name: "prop_5", - type: "string", - value: - 'async () => {\r\n return [\r\n {\r\n value: "sample1",\r\n label: "sample1",\r\n },\r\n {\r\n value: "sample2",\r\n label: "sample2",\r\n },\r\n ];\r\n}', - is_name: false, - visible: - "['button-options', 'dropdown', 'radio'].includes(type)", - valueBuilt: - ' async () => {\n return [\n {\n value: "sample1",\n label: "sample1"\n },\n {\n value: "sample2",\n label: "sample2"\n }\n ];\n};\n', - }, - required: { - idx: 7, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]', - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_7", - type: "string", - value: "`n`", - is_name: false, - valueBuilt: "`n`", - }, - label_alt: { - idx: 2, - meta: { - type: "text", - }, - name: "prop_10", - type: "string", - value: '""', - is_name: false, - valueBuilt: ' "";\n', - }, - on_change: { - idx: 10, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: "({ value }) => {}", - is_name: false, - valueBuilt: " ({ value }) => {\n};\n", - }, - selection: { - idx: 5, - meta: { - type: "option", - options: '["single", "multi"]', - optionsBuilt: ' ["single", "multi"];\n', - }, - name: "prop_11", - type: "string", - value: '"single"', - visible: 'type === "radio"', - valueBuilt: ' "single";\n', - }, - placeholder: { - idx: 3, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["text", "number", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - rel_query: { - idx: 11, - name: "prop_11", - type: "string", - value: - 'async () => {\n return {\n orderBy: {\n regional: "asc",\n },\n };\n}', - valueBuilt: - ' async () => {\n return {\n orderBy: {\n regional: "asc"\n }\n };\n};\n', - meta: { - type: "text", - }, - }, - - rel_table: { - idx: 11, - name: "prop_11", - type: "string", - value: '""', - valueBuilt: '""', - meta: { - type: "text", - }, - content: { - id: createId(), - name: "rel_table", - type: "item", - dim: { - w: "full", - h: "full", - }, - childs: [], - adv: { - css: "", - }, - }, - }, - rel_fields: { - idx: 11, - name: "prop_11", - type: "string", - value: "[]", - valueBuilt: "[]", - meta: { - type: "option", - }, - }, - default_value: { - idx: 11, - name: "prop_11", - type: "string", - value: '"hello"', - valueBuilt: '"hello"', - meta: { - type: "text", - }, - }, - }, - ref_ids: {}, - instances: {}, - }, - }, - { - id: createId(), - adv: { - js: '\n \n', - css: "", - jsBuilt: - 'render(/* @__PURE__ */ React.createElement(\n "div",\n {\n ...props,\n className: cx(\n "field",\n css`\n width:100%;\n border-bottom:1px solid white;\n padding: 10px;`\n )\n },\n /* @__PURE__ */ React.createElement(\n Field,\n {\n label,\n name,\n type,\n selection,\n label_alt,\n options,\n on_change,\n form,\n custom,\n PassProp,\n required,\n child,\n slider,\n placeholder,\n suffix\n }\n )\n));\n', - }, - dim: { - h: "full", - w: "full", - }, - name: "field", - type: "item", - childs: [], - mobile: { - dim: { - h: "full", - w: "full", - hUnit: "px", - }, - border: { - color: "#ba2f2f", - style: "solid", - stroke: { - b: 1, - }, - }, - padding: { - b: 5, - l: 15, - r: 15, - t: 5, - }, - }, - script: {}, - component: { - id: "32550d01-42a3-4b15-a04a-2c2d5c3c8e67", - props: { - name: { - idx: 0, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`asset_number`", - is_name: true, - valueBuilt: "`asset_number`", - }, - type: { - idx: 4, - meta: { - type: "option", - options: - '[\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link",\n]', - option_mode: "dropdown", - optionsBuilt: - ' [\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link"\n];\n', - }, - name: "prop_3", - type: "string", - value: '"text"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "type", - type: "item", - childs: [], - }, - is_name: false, - valueBuilt: '"text"', - }, - child: { - idx: 11, - meta: { - type: "content-element", - }, - name: "prop_11", - type: "string", - value: '"hello"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "child", - type: "item", - childs: [], - }, - is_name: false, - typings: - 'const typings = {\n data: "any",\n is_active: "boolean",\n item_click: "() => void",\n current_name: "string",\n option_item: "{value: string, label: string}",\n modify: `(field_name: string, opt: {\n value?: any,\n }) => void`,\n}', - visible: 'type === "radio"', - valueBuilt: '"hello"', - }, - label: { - idx: 1, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`Asset Number`", - is_name: false, - valueBuilt: "`Asset Number`", - }, - custom: { - idx: 8, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]\n', - option_mode: "button", - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_11", - type: "string", - value: '"n"', - is_name: false, - valueBuilt: ' "n";\n', - }, - slider: { - idx: 9, - meta: { - type: "text", - }, - name: "prop_9", - type: "string", - value: - 'async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" },\n };\n}', - is_name: false, - visible: "type === 'slider'", - valueBuilt: - ' async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" }\n };\n};\n', - }, - suffix: { - idx: 12, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["number", "text", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - options: { - idx: 6, - meta: { - type: "text", - }, - name: "prop_5", - type: "string", - value: - 'async () => {\r\n return [\r\n {\r\n value: "sample1",\r\n label: "sample1",\r\n },\r\n {\r\n value: "sample2",\r\n label: "sample2",\r\n },\r\n ];\r\n}', - is_name: false, - visible: - "['button-options', 'dropdown', 'radio'].includes(type)", - valueBuilt: - ' async () => {\n return [\n {\n value: "sample1",\n label: "sample1"\n },\n {\n value: "sample2",\n label: "sample2"\n }\n ];\n};\n', - }, - required: { - idx: 7, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]', - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_7", - type: "string", - value: "`n`", - is_name: false, - valueBuilt: "`n`", - }, - label_alt: { - idx: 2, - meta: { - type: "text", - }, - name: "prop_10", - type: "string", - value: '""', - is_name: false, - valueBuilt: ' "";\n', - }, - on_change: { - idx: 10, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: "({ value }) => {}", - is_name: false, - valueBuilt: " ({ value }) => {\n};\n", - }, - selection: { - idx: 5, - meta: { - type: "option", - options: '["single", "multi"]', - optionsBuilt: ' ["single", "multi"];\n', - }, - name: "prop_11", - type: "string", - value: '"single"', - visible: 'type === "radio"', - valueBuilt: ' "single";\n', - }, - placeholder: { - idx: 3, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["text", "number", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - rel_query: { - idx: 11, - name: "prop_11", - type: "string", - value: - 'async () => {\n return {\n orderBy: {\n regional: "asc",\n },\n };\n}', - valueBuilt: - ' async () => {\n return {\n orderBy: {\n regional: "asc"\n }\n };\n};\n', - meta: { - type: "text", - }, - }, - - rel_table: { - idx: 11, - name: "prop_11", - type: "string", - value: '""', - valueBuilt: '""', - meta: { - type: "text", - }, - content: { - id: createId(), - name: "rel_table", - type: "item", - dim: { - w: "full", - h: "full", - }, - childs: [], - adv: { - css: "", - }, - }, - }, - rel_fields: { - idx: 11, - name: "prop_11", - type: "string", - value: "[]", - valueBuilt: "[]", - meta: { - type: "option", - }, - }, - default_value: { - idx: 11, - name: "prop_11", - type: "string", - value: '"hello"', - valueBuilt: '"hello"', - meta: { - type: "text", - }, - }, - }, - ref_ids: {}, - instances: {}, - }, - }, - { - id: createId(), - adv: { - js: '\n \n', - css: "", - jsBuilt: - 'render(/* @__PURE__ */ React.createElement(\n "div",\n {\n ...props,\n className: cx(\n "field",\n css`\n width:100%;\n border-bottom:1px solid white;\n padding: 10px;`\n )\n },\n /* @__PURE__ */ React.createElement(\n Field,\n {\n label,\n name,\n type,\n selection,\n label_alt,\n options,\n on_change,\n form,\n custom,\n PassProp,\n required,\n child,\n slider,\n placeholder,\n suffix\n }\n )\n));\n', - }, - dim: { - h: "full", - w: "full", - }, - name: "field", - type: "item", - childs: [], - mobile: { - dim: { - h: "full", - w: "full", - hUnit: "px", - }, - border: { - color: "#ba2f2f", - style: "solid", - stroke: { - b: 1, - }, - }, - padding: { - b: 5, - l: 15, - r: 15, - t: 5, - }, - }, - script: {}, - component: { - id: "32550d01-42a3-4b15-a04a-2c2d5c3c8e67", - props: { - name: { - idx: 0, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`luas_setifikat`", - is_name: true, - valueBuilt: "`luas_setifikat`", - }, - type: { - idx: 4, - meta: { - type: "option", - options: - '[\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link",\n]', - option_mode: "dropdown", - optionsBuilt: - ' [\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link"\n];\n', - }, - name: "prop_3", - type: "string", - value: '"text"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "type", - type: "item", - childs: [], - }, - is_name: false, - valueBuilt: '"text"', - }, - child: { - idx: 11, - meta: { - type: "content-element", - }, - name: "prop_11", - type: "string", - value: '"hello"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "child", - type: "item", - childs: [], - }, - is_name: false, - typings: - 'const typings = {\n data: "any",\n is_active: "boolean",\n item_click: "() => void",\n current_name: "string",\n option_item: "{value: string, label: string}",\n modify: `(field_name: string, opt: {\n value?: any,\n }) => void`,\n}', - visible: 'type === "radio"', - valueBuilt: '"hello"', - }, - label: { - idx: 1, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`Luas Setifikat`", - is_name: false, - valueBuilt: "`Luas Setifikat`", - }, - custom: { - idx: 8, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]\n', - option_mode: "button", - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_11", - type: "string", - value: '"n"', - is_name: false, - valueBuilt: ' "n";\n', - }, - slider: { - idx: 9, - meta: { - type: "text", - }, - name: "prop_9", - type: "string", - value: - 'async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" },\n };\n}', - is_name: false, - visible: "type === 'slider'", - valueBuilt: - ' async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" }\n };\n};\n', - }, - suffix: { - idx: 12, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["number", "text", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - options: { - idx: 6, - meta: { - type: "text", - }, - name: "prop_5", - type: "string", - value: - 'async () => {\r\n return [\r\n {\r\n value: "sample1",\r\n label: "sample1",\r\n },\r\n {\r\n value: "sample2",\r\n label: "sample2",\r\n },\r\n ];\r\n}', - is_name: false, - visible: - "['button-options', 'dropdown', 'radio'].includes(type)", - valueBuilt: - ' async () => {\n return [\n {\n value: "sample1",\n label: "sample1"\n },\n {\n value: "sample2",\n label: "sample2"\n }\n ];\n};\n', - }, - required: { - idx: 7, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]', - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_7", - type: "string", - value: "`n`", - is_name: false, - valueBuilt: "`n`", - }, - label_alt: { - idx: 2, - meta: { - type: "text", - }, - name: "prop_10", - type: "string", - value: '""', - is_name: false, - valueBuilt: ' "";\n', - }, - on_change: { - idx: 10, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: "({ value }) => {}", - is_name: false, - valueBuilt: " ({ value }) => {\n};\n", - }, - selection: { - idx: 5, - meta: { - type: "option", - options: '["single", "multi"]', - optionsBuilt: ' ["single", "multi"];\n', - }, - name: "prop_11", - type: "string", - value: '"single"', - visible: 'type === "radio"', - valueBuilt: ' "single";\n', - }, - placeholder: { - idx: 3, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["text", "number", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - rel_query: { - idx: 11, - name: "prop_11", - type: "string", - value: - 'async () => {\n return {\n orderBy: {\n regional: "asc",\n },\n };\n}', - valueBuilt: - ' async () => {\n return {\n orderBy: {\n regional: "asc"\n }\n };\n};\n', - meta: { - type: "text", - }, - }, - - rel_table: { - idx: 11, - name: "prop_11", - type: "string", - value: '""', - valueBuilt: '""', - meta: { - type: "text", - }, - content: { - id: createId(), - name: "rel_table", - type: "item", - dim: { - w: "full", - h: "full", - }, - childs: [], - adv: { - css: "", - }, - }, - }, - rel_fields: { - idx: 11, - name: "prop_11", - type: "string", - value: "[]", - valueBuilt: "[]", - meta: { - type: "option", - }, - }, - default_value: { - idx: 11, - name: "prop_11", - type: "string", - value: '"hello"', - valueBuilt: '"hello"', - meta: { - type: "text", - }, - }, - }, - ref_ids: {}, - instances: {}, - }, - }, - { - id: createId(), - adv: { - js: '\n \n', - css: "", - jsBuilt: - 'render(/* @__PURE__ */ React.createElement(\n "div",\n {\n ...props,\n className: cx(\n "field",\n css`\n width:100%;\n border-bottom:1px solid white;\n padding: 10px;`\n )\n },\n /* @__PURE__ */ React.createElement(\n Field,\n {\n label,\n name,\n type,\n selection,\n label_alt,\n options,\n on_change,\n form,\n custom,\n PassProp,\n required,\n child,\n slider,\n placeholder,\n suffix\n }\n )\n));\n', - }, - dim: { - h: "full", - w: "full", - }, - name: "field", - type: "item", - childs: [], - mobile: { - dim: { - h: "full", - w: "full", - hUnit: "px", - }, - border: { - color: "#ba2f2f", - style: "solid", - stroke: { - b: 1, - }, - }, - padding: { - b: 5, - l: 15, - r: 15, - t: 5, - }, - }, - script: {}, - component: { - id: "32550d01-42a3-4b15-a04a-2c2d5c3c8e67", - props: { - name: { - idx: 0, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`tanggal_sertifikat`", - is_name: true, - valueBuilt: "`tanggal_sertifikat`", - }, - type: { - idx: 4, - meta: { - type: "option", - options: - '[\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link",\n]', - option_mode: "dropdown", - optionsBuilt: - ' [\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link"\n];\n', - }, - name: "prop_3", - type: "string", - value: '"text"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "type", - type: "item", - childs: [], - }, - is_name: false, - valueBuilt: '"text"', - }, - child: { - idx: 11, - meta: { - type: "content-element", - }, - name: "prop_11", - type: "string", - value: '"hello"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "child", - type: "item", - childs: [], - }, - is_name: false, - typings: - 'const typings = {\n data: "any",\n is_active: "boolean",\n item_click: "() => void",\n current_name: "string",\n option_item: "{value: string, label: string}",\n modify: `(field_name: string, opt: {\n value?: any,\n }) => void`,\n}', - visible: 'type === "radio"', - valueBuilt: '"hello"', - }, - label: { - idx: 1, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`Tanggal Sertifikat`", - is_name: false, - valueBuilt: "`Tanggal Sertifikat`", - }, - custom: { - idx: 8, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]\n', - option_mode: "button", - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_11", - type: "string", - value: '"n"', - is_name: false, - valueBuilt: ' "n";\n', - }, - slider: { - idx: 9, - meta: { - type: "text", - }, - name: "prop_9", - type: "string", - value: - 'async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" },\n };\n}', - is_name: false, - visible: "type === 'slider'", - valueBuilt: - ' async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" }\n };\n};\n', - }, - suffix: { - idx: 12, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["number", "text", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - options: { - idx: 6, - meta: { - type: "text", - }, - name: "prop_5", - type: "string", - value: - 'async () => {\r\n return [\r\n {\r\n value: "sample1",\r\n label: "sample1",\r\n },\r\n {\r\n value: "sample2",\r\n label: "sample2",\r\n },\r\n ];\r\n}', - is_name: false, - visible: - "['button-options', 'dropdown', 'radio'].includes(type)", - valueBuilt: - ' async () => {\n return [\n {\n value: "sample1",\n label: "sample1"\n },\n {\n value: "sample2",\n label: "sample2"\n }\n ];\n};\n', - }, - required: { - idx: 7, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]', - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_7", - type: "string", - value: "`n`", - is_name: false, - valueBuilt: "`n`", - }, - label_alt: { - idx: 2, - meta: { - type: "text", - }, - name: "prop_10", - type: "string", - value: '""', - is_name: false, - valueBuilt: ' "";\n', - }, - on_change: { - idx: 10, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: "({ value }) => {}", - is_name: false, - valueBuilt: " ({ value }) => {\n};\n", - }, - selection: { - idx: 5, - meta: { - type: "option", - options: '["single", "multi"]', - optionsBuilt: ' ["single", "multi"];\n', - }, - name: "prop_11", - type: "string", - value: '"single"', - visible: 'type === "radio"', - valueBuilt: ' "single";\n', - }, - placeholder: { - idx: 3, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["text", "number", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - rel_query: { - idx: 11, - name: "prop_11", - type: "string", - value: - 'async () => {\n return {\n orderBy: {\n regional: "asc",\n },\n };\n}', - valueBuilt: - ' async () => {\n return {\n orderBy: {\n regional: "asc"\n }\n };\n};\n', - meta: { - type: "text", - }, - }, - - rel_table: { - idx: 11, - name: "prop_11", - type: "string", - value: '""', - valueBuilt: '""', - meta: { - type: "text", - }, - content: { - id: createId(), - name: "rel_table", - type: "item", - dim: { - w: "full", - h: "full", - }, - childs: [], - adv: { - css: "", - }, - }, - }, - rel_fields: { - idx: 11, - name: "prop_11", - type: "string", - value: "[]", - valueBuilt: "[]", - meta: { - type: "option", - }, - }, - default_value: { - idx: 11, - name: "prop_11", - type: "string", - value: '"hello"', - valueBuilt: '"hello"', - meta: { - type: "text", - }, - }, - }, - ref_ids: {}, - instances: {}, - }, - }, - { - id: createId(), - adv: { - js: '\n \n', - css: "", - jsBuilt: - 'render(/* @__PURE__ */ React.createElement(\n "div",\n {\n ...props,\n className: cx(\n "field",\n css`\n width:100%;\n border-bottom:1px solid white;\n padding: 10px;`\n )\n },\n /* @__PURE__ */ React.createElement(\n Field,\n {\n label,\n name,\n type,\n selection,\n label_alt,\n options,\n on_change,\n form,\n custom,\n PassProp,\n required,\n child,\n slider,\n placeholder,\n suffix\n }\n )\n));\n', - }, - dim: { - h: "full", - w: "full", - }, - name: "field", - type: "item", - childs: [], - mobile: { - dim: { - h: "full", - w: "full", - hUnit: "px", - }, - border: { - color: "#ba2f2f", - style: "solid", - stroke: { - b: 1, - }, - }, - padding: { - b: 5, - l: 15, - r: 15, - t: 5, - }, - }, - script: {}, - component: { - id: "32550d01-42a3-4b15-a04a-2c2d5c3c8e67", - props: { - name: { - idx: 0, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`m_cabang`", - is_name: true, - valueBuilt: "`m_cabang`", - }, - type: { - idx: 4, - meta: { - type: "option", - options: - '[\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link",\n]', - option_mode: "dropdown", - optionsBuilt: - ' [\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link"\n];\n', - }, - name: "prop_3", - type: "string", - value: '"relation"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "type", - type: "item", - childs: [], - }, - is_name: false, - valueBuilt: '"relation"', - }, - child: { - idx: 11, - meta: { - type: "content-element", - }, - name: "prop_11", - type: "string", - value: '"hello"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "child", - type: "item", - childs: [], - }, - is_name: false, - typings: - 'const typings = {\n data: "any",\n is_active: "boolean",\n item_click: "() => void",\n current_name: "string",\n option_item: "{value: string, label: string}",\n modify: `(field_name: string, opt: {\n value?: any,\n }) => void`,\n}', - visible: 'type === "radio"', - valueBuilt: '"hello"', - }, - label: { - idx: 1, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`Cabang`", - is_name: false, - valueBuilt: "`Cabang`", - }, - custom: { - idx: 8, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]\n', - option_mode: "button", - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_11", - type: "string", - value: '"n"', - is_name: false, - valueBuilt: ' "n";\n', - }, - slider: { - idx: 9, - meta: { - type: "text", - }, - name: "prop_9", - type: "string", - value: - 'async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" },\n };\n}', - is_name: false, - visible: "type === 'slider'", - valueBuilt: - ' async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" }\n };\n};\n', - }, - suffix: { - idx: 12, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["number", "text", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - options: { - idx: 6, - meta: { - type: "text", - }, - name: "prop_5", - type: "string", - value: - 'async () => {\r\n return [\r\n {\r\n value: "sample1",\r\n label: "sample1",\r\n },\r\n {\r\n value: "sample2",\r\n label: "sample2",\r\n },\r\n ];\r\n}', - is_name: false, - visible: - "['button-options', 'dropdown', 'radio'].includes(type)", - valueBuilt: - ' async () => {\n return [\n {\n value: "sample1",\n label: "sample1"\n },\n {\n value: "sample2",\n label: "sample2"\n }\n ];\n};\n', - }, - required: { - idx: 7, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]', - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_7", - type: "string", - value: "`n`", - is_name: false, - valueBuilt: "`n`", - }, - label_alt: { - idx: 2, - meta: { - type: "text", - }, - name: "prop_10", - type: "string", - value: '""', - is_name: false, - valueBuilt: ' "";\n', - }, - on_change: { - idx: 10, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: "({ value }) => {}", - is_name: false, - valueBuilt: " ({ value }) => {\n};\n", - }, - selection: { - idx: 5, - meta: { - type: "option", - options: '["single", "multi"]', - optionsBuilt: ' ["single", "multi"];\n', - }, - name: "prop_11", - type: "string", - value: '"single"', - visible: 'type === "radio"', - valueBuilt: ' "single";\n', - }, - placeholder: { - idx: 3, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["text", "number", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - rel_query: { - idx: 11, - name: "prop_11", - type: "string", - value: - "async () => {\n return {\n // orderBy: {\n // name: 'asc'\n // }\n };\n}", - valueBuilt: - " async () => {\n return {\n // orderBy: {\n // name: 'asc'\n // }\n };\n};\n", - meta: { - type: "text", - }, - }, - - rel_table: { - idx: 11, - name: "prop_11", - type: "string", - value: '"m_cabang"', - valueBuilt: '"m_cabang"', - meta: { - type: "text", - }, - content: { - id: createId(), - name: "rel_table", - type: "item", - dim: { - w: "full", - h: "full", - }, - childs: [], - adv: { - css: "", - }, - }, - }, - rel_fields: { - idx: 11, - name: "prop_11", - type: "string", - value: '["::id","nama_cabang"]', - valueBuilt: '["::id","nama_cabang"]', - meta: { - type: "option", - }, - }, - default_value: { - idx: 11, - name: "prop_11", - type: "string", - value: '"hello"', - valueBuilt: '"hello"', - meta: { - type: "text", - }, - }, - }, - ref_ids: {}, - instances: {}, - }, - }, - { - id: createId(), - adv: { - js: '\n \n', - css: "", - jsBuilt: - 'render(/* @__PURE__ */ React.createElement(\n "div",\n {\n ...props,\n className: cx(\n "field",\n css`\n width:100%;\n border-bottom:1px solid white;\n padding: 10px;`\n )\n },\n /* @__PURE__ */ React.createElement(\n Field,\n {\n label,\n name,\n type,\n selection,\n label_alt,\n options,\n on_change,\n form,\n custom,\n PassProp,\n required,\n child,\n slider,\n placeholder,\n suffix\n }\n )\n));\n', - }, - dim: { - h: "full", - w: "full", - }, - name: "field", - type: "item", - childs: [], - mobile: { - dim: { - h: "full", - w: "full", - hUnit: "px", - }, - border: { - color: "#ba2f2f", - style: "solid", - stroke: { - b: 1, - }, - }, - padding: { - b: 5, - l: 15, - r: 15, - t: 5, - }, - }, - script: {}, - component: { - id: "32550d01-42a3-4b15-a04a-2c2d5c3c8e67", - props: { - name: { - idx: 0, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`m_regional`", - is_name: true, - valueBuilt: "`m_regional`", - }, - type: { - idx: 4, - meta: { - type: "option", - options: - '[\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link",\n]', - option_mode: "dropdown", - optionsBuilt: - ' [\n "text",\n "number",\n "textarea",\n "slider",\n "dropdown",\n "password",\n "radio",\n "date",\n "datetime",\n "money",\n "sub-link"\n];\n', - }, - name: "prop_3", - type: "string", - value: '"relation"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "type", - type: "item", - childs: [], - }, - is_name: false, - valueBuilt: '"relation"', - }, - child: { - idx: 11, - meta: { - type: "content-element", - }, - name: "prop_11", - type: "string", - value: '"hello"', - content: { - id: createId(), - adv: { - css: "", - }, - dim: { - h: "full", - w: "full", - }, - name: "child", - type: "item", - childs: [], - }, - is_name: false, - typings: - 'const typings = {\n data: "any",\n is_active: "boolean",\n item_click: "() => void",\n current_name: "string",\n option_item: "{value: string, label: string}",\n modify: `(field_name: string, opt: {\n value?: any,\n }) => void`,\n}', - visible: 'type === "radio"', - valueBuilt: '"hello"', - }, - label: { - idx: 1, - meta: { - type: "text", - }, - name: "prop_1", - type: "string", - value: "`Regional`", - is_name: false, - valueBuilt: "`Regional`", - }, - custom: { - idx: 8, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]\n', - option_mode: "button", - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_11", - type: "string", - value: '"n"', - is_name: false, - valueBuilt: ' "n";\n', - }, - slider: { - idx: 9, - meta: { - type: "text", - }, - name: "prop_9", - type: "string", - value: - 'async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" },\n };\n}', - is_name: false, - visible: "type === 'slider'", - valueBuilt: - ' async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" }\n };\n};\n', - }, - suffix: { - idx: 12, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["number", "text", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - options: { - idx: 6, - meta: { - type: "text", - }, - name: "prop_5", - type: "string", - value: - 'async () => {\r\n return [\r\n {\r\n value: "sample1",\r\n label: "sample1",\r\n },\r\n {\r\n value: "sample2",\r\n label: "sample2",\r\n },\r\n ];\r\n}', - is_name: false, - visible: - "['button-options', 'dropdown', 'radio'].includes(type)", - valueBuilt: - ' async () => {\n return [\n {\n value: "sample1",\n label: "sample1"\n },\n {\n value: "sample2",\n label: "sample2"\n }\n ];\n};\n', - }, - required: { - idx: 7, - meta: { - type: "option", - options: - '[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]', - optionsBuilt: - ' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n', - }, - name: "prop_7", - type: "string", - value: "`n`", - is_name: false, - valueBuilt: "`n`", - }, - label_alt: { - idx: 2, - meta: { - type: "text", - }, - name: "prop_10", - type: "string", - value: '""', - is_name: false, - valueBuilt: ' "";\n', - }, - on_change: { - idx: 10, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: "({ value }) => {}", - is_name: false, - valueBuilt: " ({ value }) => {\n};\n", - }, - selection: { - idx: 5, - meta: { - type: "option", - options: '["single", "multi"]', - optionsBuilt: ' ["single", "multi"];\n', - }, - name: "prop_11", - type: "string", - value: '"single"', - visible: 'type === "radio"', - valueBuilt: ' "single";\n', - }, - placeholder: { - idx: 3, - meta: { - type: "text", - }, - name: "prop_11", - type: "string", - value: '""', - visible: - '["text", "number", "password"].includes(type)', - valueBuilt: ' "";\n', - }, - rel_query: { - idx: 11, - name: "prop_11", - type: "string", - value: - 'async () => {\n return {\n orderBy: {\n regional: "asc",\n },\n };\n}', - valueBuilt: - ' async () => {\n return {\n orderBy: {\n regional: "asc"\n }\n };\n};\n', - meta: { - type: "text", - }, - }, - - rel_table: { - idx: 11, - name: "prop_11", - type: "string", - value: '"m_regional"', - valueBuilt: '"m_regional"', - meta: { - type: "text", - }, - content: { - id: createId(), - name: "rel_table", - type: "item", - dim: { - w: "full", - h: "full", - }, - childs: [], - adv: { - css: "", - }, - }, - }, - rel_fields: { - idx: 11, - name: "prop_11", - type: "string", - value: '["::id","regional"]', - valueBuilt: '["::id","regional"]', - meta: { - type: "option", - }, - }, - default_value: { - idx: 11, - name: "prop_11", - type: "string", - value: '"hello"', - valueBuilt: '"hello"', - meta: { - type: "text", - }, - }, - }, - ref_ids: {}, - instances: {}, - }, - }, - ], + childs: [], padding: { l: 10, b: 10, @@ -2807,8 +431,6 @@ export const gen_detail = () => { type: "string", value: 'async (opt) => {\n if (isEditor) return {};\n\n let id = parseInt(md.selected.id);\n\n const after_load = (item: any) => {\n const set_actions = () =>\n (md.ui.actions = [\n {\n label: "Delete",\n type: "destructive",\n onClick: async () => {\n if (confirm("Are you sure ?")) {\n md.ui.actions = [{ label: "Deleting...", type: "ghost" }];\n md.render();\n\n await db.m_aset.delete({ where: { id: item.id } });\n\n setTimeout(() => {\n md.ui.actions = [...md.ui.default_actions];\n md.ui.breadcrumb = [];\n md.ui.back = false;\n md.selected = null;\n md.render();\n });\n }\n },\n icon: ``,\n },\n {\n label: "Save",\n onClick: async () => {\n md.ui.actions = [{ label: "Saving...", type: "ghost" }];\n md.render();\n await md.cache("form")._submit();\n setTimeout(() => {\n set_actions();\n md.render();\n }, 500);\n },\n icon: ``,\n },\n ]);\n set_actions();\n md.ui.breadcrumb = [["Master Aset", ""], item?.nama_aset_komersial];\n md.render();\n };\n\n if (id) {\n md.ui.breadcrumb = [["Master Aset", ""], "..."];\n md.render();\n\n const item = await db.m_aset.findFirst({\n where: {\n id: id,\n },\n select: {\n id: true,\n nama_aset: true,\n nama_aset_keuangan: true,\n nama_aset_komersial: true,\n asset_number: true,\n luas_setifikat: true,\n tanggal_sertifikat: true,\n m_cabang: {\n select: {\n id: true,\n },\n },\n m_regional: {\n select: {\n id: true,\n },\n },\n },\n });\n\n for (const [k, v] of Object.entries(item)) {\n if (k === "m_cabang") {\n if (v?.["id"]) item[k] = { connect: { id: v?.["id"] } } as any;\n else delete item[k];\n }\n if (k === "m_regional") {\n if (v?.["id"]) item[k] = { connect: { id: v?.["id"] } } as any;\n else delete item[k];\n }\n }\n\n after_load(item);\n\n return item;\n } else {\n after_load({});\n }\n}', - valueBuilt: - ' async (opt) => {\n if (isEditor)\n return {};\n let id = parseInt(md.selected.id);\n const after_load = (item) => {\n const set_actions = () => md.ui.actions = [\n {\n label: "Delete",\n type: "destructive",\n onClick: async () => {\n if (confirm("Are you sure ?")) {\n md.ui.actions = [{ label: "Deleting...", type: "ghost" }];\n md.render();\n await db.m_aset.delete({ where: { id: item.id } });\n setTimeout(() => {\n md.ui.actions = [...md.ui.default_actions];\n md.ui.breadcrumb = [];\n md.ui.back = false;\n md.selected = null;\n md.render();\n });\n }\n },\n icon: ``\n },\n {\n label: "Save",\n onClick: async () => {\n md.ui.actions = [{ label: "Saving...", type: "ghost" }];\n md.render();\n await md.cache("form")._submit();\n setTimeout(() => {\n set_actions();\n md.render();\n }, 500);\n },\n icon: ``\n }\n ];\n set_actions();\n md.ui.breadcrumb = [["Master Aset", ""], item?.nama_aset_komersial];\n md.render();\n };\n if (id) {\n md.ui.breadcrumb = [["Master Aset", ""], "..."];\n md.render();\n const item = await db.m_aset.findFirst({\n where: {\n id\n },\n select: {\n id: true,\n nama_aset: true,\n nama_aset_keuangan: true,\n nama_aset_komersial: true,\n asset_number: true,\n luas_setifikat: true,\n tanggal_sertifikat: true,\n m_cabang: {\n select: {\n id: true\n }\n },\n m_regional: {\n select: {\n id: true\n }\n }\n }\n });\n for (const [k, v] of Object.entries(item)) {\n if (k === "m_cabang") {\n if (v?.["id"])\n item[k] = { connect: { id: v?.["id"] } };\n else\n delete item[k];\n }\n if (k === "m_regional") {\n if (v?.["id"])\n item[k] = { connect: { id: v?.["id"] } };\n else\n delete item[k];\n }\n }\n after_load(item);\n return item;\n } else {\n after_load({});\n }\n};\n', }, on_submit: { idx: 2, @@ -2819,8 +441,6 @@ export const gen_detail = () => { type: "string", value: 'async ({ form, error }: IForm) => {\n if (typeof error === "object" && Object.keys(error).length > 0) return {};\n\n const data = { ...form };\n delete data.id;\n\n if (form.id) {\n await db.m_aset.update({\n where: {\n id: form.id,\n },\n data,\n });\n } else {\n const res = await db.m_aset.create({\n data,\n select: { id: true },\n });\n if (res) form.id = res.id;\n }\n\n return true;\n};\n\ntype IForm = { form: any; error: Record }', - valueBuilt: - ' async ({ form, error }) => {\n if (typeof error === "object" && Object.keys(error).length > 0)\n return {};\n const data = { ...form };\n delete data.id;\n if (form.id) {\n await db.m_aset.update({\n where: {\n id: form.id\n },\n data\n });\n } else {\n const res = await db.m_aset.create({\n data,\n select: { id: true }\n });\n if (res)\n form.id = res.id;\n }\n return true;\n};\n', }, gen_mode: { idx: 8, @@ -2841,16 +461,6 @@ export const gen_detail = () => { label: "mode", visible: "generate === 'y'", }, - prop_11: { - idx: 11, - name: "prop_11", - type: "string", - value: '"hello"', - valueBuilt: '"hello"', - meta: { - type: "text", - }, - }, cache: { idx: 11, name: "prop_11", @@ -2883,5 +493,8 @@ export const gen_detail = () => { }, }; - return { content: res, props: res.childs[0].childs[0].component.props }; + return { + content: res.childs[0], + props: res.childs[0].childs[0].component.props, + }; }; diff --git a/gen/gen_md/gen_master.ts b/gen/gen_md/gen_master.ts index c760467..248b33a 100755 --- a/gen/gen_md/gen_master.ts +++ b/gen/gen_md/gen_master.ts @@ -208,7 +208,6 @@ export const gen_master = () => { }, typings: "const typings = {\n cell: `{ key: string, value: any }`,\n row: `any`,\n idx: `number`,\n rows: `any[]`,\n}", - valueBuilt: ' "hello";\n', }, columns: { idx: 0, @@ -219,8 +218,6 @@ export const gen_master = () => { type: "string", value: 'async (): Promise<\n { key: string; name: string; width?: number; frozen?: boolean }[]\n > => {\n return [\n { key: "id", name: "#", width: 60, frozen: true },\n {"key":"nama_aset_komersial","name":"Nama Aset Komersial"},\n {"key":"m_cabang","name":"Cabang"},\n {"key":"m_regional","name":"Regional"},\n {"key":"luas_setifikat","name":"Luas Setifikat"},\n {"key":"tanggal_sertifikat","name":"Tanggal Sertifikat"}\n ];\n }', - valueBuilt: - ' async () => {\n return [\n { key: "id", name: "#", width: 60, frozen: true },\n { "key": "nama_aset_komersial", "name": "Nama Aset Komersial" },\n { "key": "m_cabang", "name": "Cabang" },\n { "key": "m_regional", "name": "Regional" },\n { "key": "luas_setifikat", "name": "Luas Setifikat" },\n { "key": "tanggal_sertifikat", "name": "Tanggal Sertifikat" }\n ];\n};\n', }, on_load: { idx: 1, @@ -230,9 +227,7 @@ export const gen_master = () => { name: "prop_1", type: "string", value: - "async () => {\n if (isEditor)\n return [\n {\n id: createId(),\n },\n });\n\n return items;\n}", - valueBuilt: - ' async () => {\n if (isEditor)\n return [\n {\n id: createId(),\n tanggal_sertifikat: "sample"\n }\n ];\n const items = await db.m_aset.findMany({\n select: {\n id: true,\n nama_aset_komersial: true,\n m_cabang: {\n select: {\n id: true,\n nama_cabang: true\n }\n },\n m_regional: {\n select: {\n regional: true,\n id: true\n }\n },\n luas_setifikat: true,\n tanggal_sertifikat: true\n },\n orderBy: {\n id: "desc"\n }\n });\n return items;\n};\n', + "async () => {\n if (isEditor)\n return [\n {\n },\n });\n\n return items;\n}", }, generate: { idx: 5, diff --git a/gen/gen_md/gen_md.ts b/gen/gen_md/gen_md.ts index 8f94f03..f2629f9 100755 --- a/gen/gen_md/gen_md.ts +++ b/gen/gen_md/gen_md.ts @@ -6,6 +6,7 @@ import { gen_master } from "./gen_master"; import { on_load as table_on_load } from "../gen_table/on_load"; import { on_load as form_on_load } from "../gen_form/on_load"; import { on_submit as form_on_submit } from "../gen_form/on_submit"; +import { newField as form_new_field } from "../gen_form/new_field"; import { gen_columns } from "../gen_table/columns"; import { newField as table_new_field } from "../gen_table/new_field"; import { gen_detail } from "./gen_detail"; @@ -66,6 +67,10 @@ export const gen_md = (modify: (data: any) => void, data: any) => { } const result: any = {}; + if (!pk) { + alert("Failed to generate! Primary Key not found. "); + return; + } if (pk) { result["header"] = data["header"]; result["header"].content = gen_header(); @@ -79,19 +84,48 @@ export const gen_md = (modify: (data: any) => void, data: any) => { result["detail"] = data["detail"]; const detail = gen_detail(); - const title = JSON.parse(get(data, "title.value")); - const before_load = form_before_load(pk.name, title, ""); + const title = parse(get(data, "title.value")); + const label = parse(get(data, "gen_label.value")); + const before_load = form_before_load(table, pk.name, title, label); - detail.props["on_load"].value = form_on_load({ pk, pks, select, table }); + detail.props["on_load"].value = form_on_load({ + pk, + pks, + select, + table, + opt: { before_load, after_load: `after_load(item);` }, + }); detail.props["on_submit"].value = form_on_submit({ pk, table, select, pks, }); + + const childs = get(detail.props, "body.content.childs"); + if (Array.isArray(childs)) { + detail.props.body.content.childs = new_fields.map(form_new_field) as any; + console.log(detail.props.body.content.childs); + } result["detail"].content = detail.content; } - // modify(result); + modify(result); - alert("Prop Generated!"); + alert("Prop Generated! "); +}; + +const parse = (text: any) => { + if (typeof text === "string") { + let result = ""; + try { + eval(`result = ${text}`); + + if (typeof result === "function") { + result = (result as any)(); + } + } catch (e) {} + + return result; + } + return ""; }; diff --git a/gen/gen_table/gen_table.ts b/gen/gen_table/gen_table.ts index 8c4cf49..0dcb06d 100755 --- a/gen/gen_table/gen_table.ts +++ b/gen/gen_table/gen_table.ts @@ -38,17 +38,24 @@ export const gen_table = (modify: (data: any) => void, data: any) => { } const result = {} as any; - if (data["columns"]) { - result["columns"] = data["columns"]; - result["columns"].value = gen_columns(columns); + + if (!pk) { + alert("Failed to generate! Primary Key not found. "); + return; } - if (data["on_load"]) { - result["on_load"] = data["on_load"]; - result["on_load"].value = on_load({ pk, table, select, pks }); - } - if (data["child"]) { - result["child"] = data["child"]; - result["child"].content.childs = newField(select, pks); + if (pk) { + if (data["columns"]) { + result["columns"] = data["columns"]; + result["columns"].value = gen_columns(columns); + } + if (data["on_load"]) { + result["on_load"] = data["on_load"]; + result["on_load"].value = on_load({ pk, table, select, pks }); + } + if (data["child"]) { + result["child"] = data["child"]; + result["child"].content.childs = newField(select, pks); + } } modify(result);