diff --git a/comps/list/ExportExcel.tsx b/comps/list/ExportExcel.tsx index 63b382e..dfa51d5 100755 --- a/comps/list/ExportExcel.tsx +++ b/comps/list/ExportExcel.tsx @@ -1,7 +1,6 @@ import { useLocal } from "@/utils/use-local"; import { FC, MouseEvent } from "react"; import ExcelJS from "exceljs"; -import * as FileSaver from "file-saver"; export const ExportExcel: FC<{ data: any[], @@ -43,7 +42,7 @@ export const ExportExcel: FC<{ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", }); - FileSaver.saveAs(blob, fileName); + // FileSaver.saveAs(blob, fileName); console.log("Data exported"); } catch (error) { diff --git a/comps/md/MasterDetail.tsx b/comps/md/MasterDetail.tsx index 3f28822..88b0366 100755 --- a/comps/md/MasterDetail.tsx +++ b/comps/md/MasterDetail.tsx @@ -1,5 +1,4 @@ import { useLocal } from "@/utils/use-local"; -import get from "lodash.get"; import { FC, useEffect, useRef } from "react"; import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels"; import { refreshBread } from "./MDBread"; @@ -10,47 +9,22 @@ import { masterDetailParseHash as masterDetailParseParams, } from "./utils/md-hash"; import { masterDetailInit, masterDetailSelected } from "./utils/md-init"; -import { MDLocal, MDLocalInternal, MDRef, w } from "./utils/typings"; - -export const MasterDetail: FC<{ - child: any; - PassProp: any; - name: string; - mode: "full" | "h-split" | "v-split"; - show_head: "always" | "only-master" | "only-child" | "hidden"; - tab_mode: "h-tab" | "v-tab" | "hidden"; - editor_tab: string; - gen_fields: any; - gen_table: string; - on_init: (md: MDLocal) => void; - _item: PrasiItem; -}> = ({ - _item, - PassProp, - child, - name, - mode, - show_head, - tab_mode, - editor_tab, - gen_fields, - gen_table, - on_init, -}) => { - let isGenerate = false as Boolean; - - try { - if (!get(w.md_internal, _item.id)) - w.md_internal = { - ...w.md_internal, - [_item.id]: _item, - }; - isGenerate = false; - if (w.generating_prasi_md["master_detail"]) { - isGenerate = true; - } - } catch (ex) {} +import { MDLocal, MDLocalInternal, MDProps, MDRef } from "./utils/typings"; +import { editorMDInit } from "./utils/editor-init"; +export const MasterDetail: FC = (arg) => { + const { + PassProp, + child, + name, + mode, + show_head, + tab_mode, + editor_tab, + gen_fields, + gen_table, + on_init, + } = arg; const _ref = useRef({ PassProp, child }); const md = useLocal({ name, @@ -91,14 +65,9 @@ export const MasterDetail: FC<{ const local = useLocal({ init: false }); if (isEditor) { - md.props.mode = mode; - md.props.show_head = show_head; - md.props.tab_mode = tab_mode; - md.props.editor_tab = editor_tab; - md.props.gen_fields = gen_fields; - md.props.gen_table = gen_table; - md.props.on_init = on_init; + editorMDInit(md, arg); } + _ref.current.PassProp = PassProp; _ref.current.child = child; @@ -107,13 +76,15 @@ export const MasterDetail: FC<{ local.render(); }, [editor_tab]); + // refreshBread ga ditaro di useEffect karena + // butuh ubah breadcrumb berdasarkan mode master-detailnya refreshBread(md); + if (!local.init || isEditor) { local.init = true; masterDetailInit(md, child, editor_tab); masterDetailSelected(md); } - if (isGenerate) return <>Generating ...; return (
{ + const { + PassProp, + child, + name, + mode, + show_head, + tab_mode, + editor_tab, + gen_fields, + gen_table, + on_init, + } = arg; + md.props.mode = mode; + md.props.show_head = show_head; + md.props.tab_mode = tab_mode; + md.props.editor_tab = editor_tab; + md.props.gen_fields = gen_fields; + md.props.gen_table = gen_table; + md.props.on_init = on_init; +}; diff --git a/comps/md/utils/typings.ts b/comps/md/utils/typings.ts index b5a92b4..a32745c 100755 --- a/comps/md/utils/typings.ts +++ b/comps/md/utils/typings.ts @@ -11,6 +11,20 @@ export const w = window as unknown as { md_internal: Record; }; +export type MDProps = { + child: any; + PassProp: any; + name: string; + mode: "full" | "h-split" | "v-split"; + show_head: "always" | "only-master" | "only-child" | "hidden"; + tab_mode: "h-tab" | "v-tab" | "hidden"; + editor_tab: string; + gen_fields: any; + gen_table: string; + on_init: (md: MDLocal) => void; + _item: PrasiItem; +}; + export type MDActions = { action?: string; label: ReactNode; diff --git a/gen/gen_table_list/gen_export.tsx b/gen/gen_table_list/gen_export.tsx index 738d27f..4547626 100755 --- a/gen/gen_table_list/gen_export.tsx +++ b/gen/gen_table_list/gen_export.tsx @@ -4,7 +4,6 @@ import { on_load } from "./on_load"; import { codeBuild, codeBuildTest } from "../master_detail/utils"; // import * as Excel from "exceljs"; import ExcelJS from "exceljs"; -import * as FileSaver from "file-saver"; export const gen_export = async ( modify: (data: any) => void, @@ -70,7 +69,7 @@ export const gen_export = async ( type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", }); - FileSaver.saveAs(blob, "exported_data.xlsx"); + // FileSaver.saveAs(blob, "exported_data.xlsx"); console.log("Data exported"); } catch (error) {