From 6c17b8711d512f8fe9752aff70c9f787d154bb29 Mon Sep 17 00:00:00 2001 From: rizky Date: Sat, 30 Mar 2024 00:41:09 -0700 Subject: [PATCH] wip fix --- comps/list/TableList.tsx | 13 ++++++++++++- gen/gen_table_list/gen_table_list.tsx | 9 ++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/comps/list/TableList.tsx b/comps/list/TableList.tsx index 51435fe..a63a185 100755 --- a/comps/list/TableList.tsx +++ b/comps/list/TableList.tsx @@ -10,6 +10,7 @@ type TableListProp = { PassProp: any; name: string; on_load: () => Promise; + mode: "table" | "list" | "grid"; }; export const TableList: FC = ({ @@ -17,6 +18,7 @@ export const TableList: FC = ({ on_load, child, PassProp, + mode, }) => { const local = useLocal({ el: null as null | HTMLDivElement, @@ -50,11 +52,20 @@ export const TableList: FC = ({ } }, [on_load]); - const childs = get( + const raw_childs = get( child, "props.meta.item.component.props.child.content.childs" ); + let childs: any[] = []; + + const mode_child = raw_childs.find((e: any) => e.name === mode); + + if (mode_child && mode_child.childs) { + childs = mode_child.childs; + } + console.log(raw_childs); + const columns: ColumnOrColumnGroup[] = []; for (const child of childs) { const key = getProp(child, "name"); diff --git a/gen/gen_table_list/gen_table_list.tsx b/gen/gen_table_list/gen_table_list.tsx index bb36db5..531be22 100755 --- a/gen/gen_table_list/gen_table_list.tsx +++ b/gen/gen_table_list/gen_table_list.tsx @@ -53,6 +53,13 @@ export const gen_table_list = ( if (data["child"]) { result["child"] = data["child"]; + + result["child"].content.childs = result["child"].content.childs.filter( + (e: any) => { + return e.name !== arg.mode; + } + ); + result["child"].content.childs = [ createItem({ name: arg.mode, @@ -67,9 +74,9 @@ export const gen_table_list = ( }, ], }), + ...result["child"].content.childs, ]; } - console.log(result["child"]); if (data["selected"]) { result["selected"] = data["selected"];