disabling file saver
This commit is contained in:
parent
e096b9dd34
commit
84667c3001
|
|
@ -1,7 +1,6 @@
|
||||||
import { useLocal } from "@/utils/use-local";
|
import { useLocal } from "@/utils/use-local";
|
||||||
import { FC, MouseEvent } from "react";
|
import { FC, MouseEvent } from "react";
|
||||||
import ExcelJS from "exceljs";
|
import ExcelJS from "exceljs";
|
||||||
import * as FileSaver from "file-saver";
|
|
||||||
|
|
||||||
export const ExportExcel: FC<{
|
export const ExportExcel: FC<{
|
||||||
data: any[],
|
data: any[],
|
||||||
|
|
@ -43,7 +42,7 @@ export const ExportExcel: FC<{
|
||||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
});
|
});
|
||||||
|
|
||||||
FileSaver.saveAs(blob, fileName);
|
// FileSaver.saveAs(blob, fileName);
|
||||||
|
|
||||||
console.log("Data exported");
|
console.log("Data exported");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { useLocal } from "@/utils/use-local";
|
import { useLocal } from "@/utils/use-local";
|
||||||
import get from "lodash.get";
|
|
||||||
import { FC, useEffect, useRef } from "react";
|
import { FC, useEffect, useRef } from "react";
|
||||||
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
|
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
|
||||||
import { refreshBread } from "./MDBread";
|
import { refreshBread } from "./MDBread";
|
||||||
|
|
@ -10,22 +9,11 @@ import {
|
||||||
masterDetailParseHash as masterDetailParseParams,
|
masterDetailParseHash as masterDetailParseParams,
|
||||||
} from "./utils/md-hash";
|
} from "./utils/md-hash";
|
||||||
import { masterDetailInit, masterDetailSelected } from "./utils/md-init";
|
import { masterDetailInit, masterDetailSelected } from "./utils/md-init";
|
||||||
import { MDLocal, MDLocalInternal, MDRef, w } from "./utils/typings";
|
import { MDLocal, MDLocalInternal, MDProps, MDRef } from "./utils/typings";
|
||||||
|
import { editorMDInit } from "./utils/editor-init";
|
||||||
|
|
||||||
export const MasterDetail: FC<{
|
export const MasterDetail: FC<MDProps> = (arg) => {
|
||||||
child: any;
|
const {
|
||||||
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,
|
PassProp,
|
||||||
child,
|
child,
|
||||||
name,
|
name,
|
||||||
|
|
@ -36,21 +24,7 @@ export const MasterDetail: FC<{
|
||||||
gen_fields,
|
gen_fields,
|
||||||
gen_table,
|
gen_table,
|
||||||
on_init,
|
on_init,
|
||||||
}) => {
|
} = arg;
|
||||||
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) {}
|
|
||||||
|
|
||||||
const _ref = useRef({ PassProp, child });
|
const _ref = useRef({ PassProp, child });
|
||||||
const md = useLocal<MDLocalInternal>({
|
const md = useLocal<MDLocalInternal>({
|
||||||
name,
|
name,
|
||||||
|
|
@ -91,14 +65,9 @@ export const MasterDetail: FC<{
|
||||||
|
|
||||||
const local = useLocal({ init: false });
|
const local = useLocal({ init: false });
|
||||||
if (isEditor) {
|
if (isEditor) {
|
||||||
md.props.mode = mode;
|
editorMDInit(md, arg);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ref.current.PassProp = PassProp;
|
_ref.current.PassProp = PassProp;
|
||||||
_ref.current.child = child;
|
_ref.current.child = child;
|
||||||
|
|
||||||
|
|
@ -107,13 +76,15 @@ export const MasterDetail: FC<{
|
||||||
local.render();
|
local.render();
|
||||||
}, [editor_tab]);
|
}, [editor_tab]);
|
||||||
|
|
||||||
|
// refreshBread ga ditaro di useEffect karena
|
||||||
|
// butuh ubah breadcrumb berdasarkan mode master-detailnya
|
||||||
refreshBread(md);
|
refreshBread(md);
|
||||||
|
|
||||||
if (!local.init || isEditor) {
|
if (!local.init || isEditor) {
|
||||||
local.init = true;
|
local.init = true;
|
||||||
masterDetailInit(md, child, editor_tab);
|
masterDetailInit(md, child, editor_tab);
|
||||||
masterDetailSelected(md);
|
masterDetailSelected(md);
|
||||||
}
|
}
|
||||||
if (isGenerate) return <>Generating ...</>;
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cx(
|
className={cx(
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { MDLocal, MDProps } from "./typings";
|
||||||
|
|
||||||
|
export const editorMDInit = (md: MDLocal, arg: MDProps) => {
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
@ -11,6 +11,20 @@ export const w = window as unknown as {
|
||||||
md_internal: Record<string, any>;
|
md_internal: Record<string, any>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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 = {
|
export type MDActions = {
|
||||||
action?: string;
|
action?: string;
|
||||||
label: ReactNode;
|
label: ReactNode;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import { on_load } from "./on_load";
|
||||||
import { codeBuild, codeBuildTest } from "../master_detail/utils";
|
import { codeBuild, codeBuildTest } from "../master_detail/utils";
|
||||||
// import * as Excel from "exceljs";
|
// import * as Excel from "exceljs";
|
||||||
import ExcelJS from "exceljs";
|
import ExcelJS from "exceljs";
|
||||||
import * as FileSaver from "file-saver";
|
|
||||||
|
|
||||||
export const gen_export = async (
|
export const gen_export = async (
|
||||||
modify: (data: any) => void,
|
modify: (data: any) => void,
|
||||||
|
|
@ -70,7 +69,7 @@ export const gen_export = async (
|
||||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
});
|
});
|
||||||
|
|
||||||
FileSaver.saveAs(blob, "exported_data.xlsx");
|
// FileSaver.saveAs(blob, "exported_data.xlsx");
|
||||||
|
|
||||||
console.log("Data exported");
|
console.log("Data exported");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue