From 34f9c3a631df679cf79df3e2ba229dc83b5ca423 Mon Sep 17 00:00:00 2001 From: rizrmd Date: Fri, 24 May 2024 05:33:41 -0700 Subject: [PATCH] checkpoint masterdetail --- comps/form/field/type/TypeCustom.tsx | 4 - comps/md/parts/MDMaster.tsx | 2 +- comps/md/parts/MDTab.tsx | 2 +- comps/menu/Menu.tsx | 285 +++++++++++++-------------- comps/popup/PopUp.tsx | 8 +- gen/prop/gen_prop_fields.ts | 4 +- preset/login/utils/generate.ts | 17 +- 7 files changed, 159 insertions(+), 163 deletions(-) diff --git a/comps/form/field/type/TypeCustom.tsx b/comps/form/field/type/TypeCustom.tsx index e51564b..57a02a1 100755 --- a/comps/form/field/type/TypeCustom.tsx +++ b/comps/form/field/type/TypeCustom.tsx @@ -44,10 +44,6 @@ export const TypeCustom: FC<{ field: FieldLocal; fm: FMLocal }> = ({ if (local.result) { if (isValidElement(local.result)) { el = local.result; - } else { - if (local.result.field === "text") { - el = ; - } } } diff --git a/comps/md/parts/MDMaster.tsx b/comps/md/parts/MDMaster.tsx index 45b1f78..66d6b5b 100755 --- a/comps/md/parts/MDMaster.tsx +++ b/comps/md/parts/MDMaster.tsx @@ -34,7 +34,7 @@ export const MDMain: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { return ( <> {md.props.show_head === "only-master" && } - {md.master.internal} + {/* {md.master.internal} */} ); }; diff --git a/comps/md/parts/MDTab.tsx b/comps/md/parts/MDTab.tsx index dd89cda..a1b2cab 100755 --- a/comps/md/parts/MDTab.tsx +++ b/comps/md/parts/MDTab.tsx @@ -27,7 +27,7 @@ export const MDTab: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { {md.props.tab_mode !== "hidden" && md.tab.list.length > 1 && ( )} - {detail.internal} + {/* {detail.internal} */} ); diff --git a/comps/menu/Menu.tsx b/comps/menu/Menu.tsx index bdac14c..23ba5c8 100755 --- a/comps/menu/Menu.tsx +++ b/comps/menu/Menu.tsx @@ -1,12 +1,11 @@ - +import { getPathname } from "lib/utils/pathname"; +import { useLocal } from "lib/utils/use-local"; import get from "lodash.get"; -import { ChevronDown, ChevronRight } from "lucide-react"; -import { FC, ReactNode, useEffect } from "react"; -import { MenuProp } from "../../preset/menu/utils/type-menu"; +import { FC } from "react"; +import { IMenu, MenuProp } from "../../preset/menu/utils/type-menu"; export const Menu: FC = (props) => { - const imenu = props.menu; - console.log(imenu) + const imenu = props.menu[0]; let role = props.role; role = props.on_init() as string; @@ -55,147 +54,147 @@ export const SideBar: FC<{ value: item[2], }; return
asdas {typeof menu.icon}
; - const find_child = findChild(item, (e: any) => local.open.includes(e)); - let expand = find_child; - if (find_child && !local.open.includes(item)) local.open.push(item); - return ( -
-
{ - const childs = getChilds(item) || []; - if (local.open.includes(item)) { - local.open = local.open.filter( - (e: any) => e !== item && !childs.includes(e) - ); - } else { - local.open.push(item); - } - local.active = item; - local.render(); - }} - > - - {pm.child} - -
-
- {Array.isArray(menu.value) && expand ? ( - <> - - - ) : ( - <> - )} -
-
- ); + // const find_child = findChild(item, (e: any) => local.open.includes(e)); + // let expand = find_child; + // if (find_child && !local.open.includes(item)) local.open.push(item); + // return ( + //
+ //
{ + // const childs = getChilds(item) || []; + // if (local.open.includes(item)) { + // local.open = local.open.filter( + // (e: any) => e !== item && !childs.includes(e) + // ); + // } else { + // local.open.push(item); + // } + // local.active = item; + // local.render(); + // }} + // > + // + // {pm.child} + // + //
+ //
+ // {Array.isArray(menu.value) && expand ? ( + // <> + // + // + // ) : ( + // <> + // )} + //
+ //
+ // ); })} ); - return ( -
- {data.map((e) => { - const label: string = e[0]; - const child: any = e[2]; - const hasChildren = Array.isArray(child); - const predicate = (item: MenuActive) => { - if (hasChildren) { - return item.label === e[0] && item.path === ""; - } else { - return item.label === e[0] && item.path === child; - } - }; - const found_local = local.open.find(predicate); - let expand = get(found_local, "expand") ? true : false; - const selected = found(e, (menu: any) => - local.open.some( - (item: MenuActive) => - item.label === menu[0] || item.path === menu[2] - ) - ); - if (selected && !found_local) { - local.open.push({ - label: e[0], - path: hasChildren ? "" : e[2], - expand: hasChildren, - }); - expand = true; - } + // return ( + //
+ // {data.map((e) => { + // const label: string = e[0]; + // const child: any = e[2]; + // const hasChildren = Array.isArray(child); + // const predicate = (item: MenuActive) => { + // if (hasChildren) { + // return item.label === e[0] && item.path === ""; + // } else { + // return item.label === e[0] && item.path === child; + // } + // }; + // const found_local = local.open.find(predicate); + // let expand = get(found_local, "expand") ? true : false; + // const selected = found(e, (menu: any) => + // local.open.some( + // (item: MenuActive) => + // item.label === menu[0] || item.path === menu[2] + // ) + // ); + // if (selected && !found_local) { + // local.open.push({ + // label: e[0], + // path: hasChildren ? "" : e[2], + // expand: hasChildren, + // }); + // expand = true; + // } - return ( -
-
{ - const found_local = local.open.find(predicate); - console.log(found_local); - if (found_local) { - found_local.expand = !found_local.expand; - // local.open = local.open.filter((item: MenuActive) => { - // if (hasChildren) { - // return item.label !== e[0] && item.path === ""; - // } else { - // return item.label !== e[0] && item.path !== child; - // } - // }); - local.render(); - } else { - local.open = [ - { - label: e[0], - path: hasChildren ? "" : e[2], - expand: hasChildren, - }, - ]; - } - local.render(); - console.log(local.open); - }} - > - - {pm.child} - -
- {hasChildren && selected && expand ? ( -
- -
- ) : ( - <> - )} -
- ); - })} -
- ); + // return ( + //
+ //
{ + // const found_local = local.open.find(predicate); + // console.log(found_local); + // if (found_local) { + // found_local.expand = !found_local.expand; + // // local.open = local.open.filter((item: MenuActive) => { + // // if (hasChildren) { + // // return item.label !== e[0] && item.path === ""; + // // } else { + // // return item.label !== e[0] && item.path !== child; + // // } + // // }); + // local.render(); + // } else { + // local.open = [ + // { + // label: e[0], + // path: hasChildren ? "" : e[2], + // expand: hasChildren, + // }, + // ]; + // } + // local.render(); + // console.log(local.open); + // }} + // > + // + // {pm.child} + // + //
+ // {hasChildren && selected && expand ? ( + //
+ // + //
+ // ) : ( + // <> + // )} + //
+ // ); + // })} + //
+ // ); }; const getChilds = (data: Array) => { diff --git a/comps/popup/PopUp.tsx b/comps/popup/PopUp.tsx index b9af5b5..5cd6e30 100755 --- a/comps/popup/PopUp.tsx +++ b/comps/popup/PopUp.tsx @@ -4,7 +4,7 @@ import { createPortal } from "react-dom"; type PopupProp = { on_close: (value: boolean) => void; - open: boolean | () => boolean; + open: boolean | (() => boolean); child: ReactNode; }; export const Popup: FC = ({ on_close, open, child }) => { @@ -13,11 +13,11 @@ export const Popup: FC = ({ on_close, open, child }) => { open: false, }); useEffect(() => { - console.log(open) - const open_props = typeof open === "function" ? open() : open + console.log(open); + const open_props = typeof open === "function" ? open() : open; local.open = open_props; local.render(); - console.log(local.open) + console.log(local.open); }, [open]); if (document.getElementsByClassName("prasi-popup").length === 0) { diff --git a/gen/prop/gen_prop_fields.ts b/gen/prop/gen_prop_fields.ts index 23f90a2..c257033 100755 --- a/gen/prop/gen_prop_fields.ts +++ b/gen/prop/gen_prop_fields.ts @@ -33,8 +33,8 @@ const single = {} as Record< const load_single = async (table: string) => { if (!single[table]) { single[table] = { - cols: await db._schema.columns(table), - rels: await db._schema.rels(table), + cols: await db._schema.columns(table as any), + rels: await db._schema.rels(table as any), }; } return single[table]; diff --git a/preset/login/utils/generate.ts b/preset/login/utils/generate.ts index 8f50ed6..41cc138 100755 --- a/preset/login/utils/generate.ts +++ b/preset/login/utils/generate.ts @@ -1,5 +1,4 @@ import get from "lodash.get"; -import { select } from "./select"; type typeFieldLogin = { username: string; @@ -16,10 +15,12 @@ export const generateLogin = async ( "edit.childs[0].edit.childs[0].edit.props.body.value" ); const form: PrasiItem = item_form; - const filterField = form.edit.childs.filter((e: any) => get(e, "component.id") !== "32550d01-42a3-4b15-a04a-2c2d5c3c8e67") - console.log({filterField}) - form.edit.setChilds(filterField) - + const filterField = form.edit.childs.filter( + (e: any) => + get(e, "component.id") !== "32550d01-42a3-4b15-a04a-2c2d5c3c8e67" + ); + form.edit.setChilds(filterField); + // form.edit.childs[0].edit.setProp("name", field.username) // // form.edit.childs[1].edit.setProp("name", field.password) // let rels = { ...rel }; @@ -60,13 +61,13 @@ export const generateLogin = async ( // }else{ // alert("password salah"); // } - + // }else{ // alert("user belum terdaftar") // } - + // }; - + // type IForm = { form: any; error: Record } // `, // });