This commit is contained in:
rizky 2024-03-30 00:41:09 -07:00
parent 6d05d76522
commit 6c17b8711d
2 changed files with 20 additions and 2 deletions

View File

@ -10,6 +10,7 @@ type TableListProp = {
PassProp: any; PassProp: any;
name: string; name: string;
on_load: () => Promise<any[]>; on_load: () => Promise<any[]>;
mode: "table" | "list" | "grid";
}; };
export const TableList: FC<TableListProp> = ({ export const TableList: FC<TableListProp> = ({
@ -17,6 +18,7 @@ export const TableList: FC<TableListProp> = ({
on_load, on_load,
child, child,
PassProp, PassProp,
mode,
}) => { }) => {
const local = useLocal({ const local = useLocal({
el: null as null | HTMLDivElement, el: null as null | HTMLDivElement,
@ -50,11 +52,20 @@ export const TableList: FC<TableListProp> = ({
} }
}, [on_load]); }, [on_load]);
const childs = get( const raw_childs = get(
child, child,
"props.meta.item.component.props.child.content.childs" "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<any>[] = []; const columns: ColumnOrColumnGroup<any>[] = [];
for (const child of childs) { for (const child of childs) {
const key = getProp(child, "name"); const key = getProp(child, "name");

View File

@ -53,6 +53,13 @@ export const gen_table_list = (
if (data["child"]) { if (data["child"]) {
result["child"] = 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 = [ result["child"].content.childs = [
createItem({ createItem({
name: arg.mode, name: arg.mode,
@ -67,9 +74,9 @@ export const gen_table_list = (
}, },
], ],
}), }),
...result["child"].content.childs,
]; ];
} }
console.log(result["child"]);
if (data["selected"]) { if (data["selected"]) {
result["selected"] = data["selected"]; result["selected"] = data["selected"];