prasi-lib/comps/md/utils/editor-init.tsx

46 lines
1.1 KiB
TypeScript
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import get from "lodash.get";
import { MDLocal, MDProps, MDRef } from "./typings";
export const editorMDInit = (md: MDLocal, mdr: MDRef, arg: MDProps) => {
const {
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.deps = arg.deps;
md.props.on_init = on_init;
if (!mdr.master || (mdr.master && !get(mdr, "master.edit.childs.0.childs.length"))) {
md.header.breadcrumb = [
{
label: (
<>
Master Detail is not ready
<br />
<div
className={css`
font-size: 12px;
font-weight: normal;
`}
>
Please generate master detail props first
</div>
</>
),
},
];
md.status = "unready";
} else {
md.status = "ready";
}
};