fix header
This commit is contained in:
parent
b1e40bf2ed
commit
01e65b4858
|
|
@ -7,6 +7,7 @@ import { formError } from "./error";
|
||||||
import { toast } from "lib/comps/ui/toast";
|
import { toast } from "lib/comps/ui/toast";
|
||||||
import { Button } from "lib/comps/ui/button";
|
import { Button } from "lib/comps/ui/button";
|
||||||
import { MDLocal } from "lib/comps/md/utils/typings";
|
import { MDLocal } from "lib/comps/md/utils/typings";
|
||||||
|
import { masterDetailApplyParams } from "lib/comps/md/utils/md-hash";
|
||||||
|
|
||||||
export const formInit = (fm: FMLocal, props: FMProps) => {
|
export const formInit = (fm: FMLocal, props: FMProps) => {
|
||||||
for (const [k, v] of Object.entries(props)) {
|
for (const [k, v] of Object.entries(props)) {
|
||||||
|
|
@ -57,6 +58,7 @@ export const formInit = (fm: FMLocal, props: FMProps) => {
|
||||||
size={"xs"}
|
size={"xs"}
|
||||||
className="c-cursor-pointer"
|
className="c-cursor-pointer"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
const md = fm.deps.md as MDLocal;
|
||||||
toast.dismiss();
|
toast.dismiss();
|
||||||
md.selected = null;
|
md.selected = null;
|
||||||
md.tab.active = "master";
|
md.tab.active = "master";
|
||||||
|
|
@ -74,14 +76,14 @@ export const formInit = (fm: FMLocal, props: FMProps) => {
|
||||||
size={"xs"}
|
size={"xs"}
|
||||||
className="c-cursor-pointer"
|
className="c-cursor-pointer"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
const md = fm.deps.md as MDLocal;
|
||||||
toast.dismiss();
|
toast.dismiss();
|
||||||
for (const k of Object.keys(md.selected)) {
|
|
||||||
delete md.selected[k];
|
|
||||||
}
|
|
||||||
md.tab.active = "detail";
|
|
||||||
md.params.hash[md.name] = "+";
|
md.params.hash[md.name] = "+";
|
||||||
|
md.selected = {};
|
||||||
|
md.internal.reset_detail = true;
|
||||||
|
md.tab.active = "detail";
|
||||||
md.params.apply();
|
md.params.apply();
|
||||||
md.render();
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="c-px-1">{opt.addNewText}</div> <Plus size={18} />
|
<div className="c-px-1">{opt.addNewText}</div> <Plus size={18} />
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ export const MasterDetail: FC<MDProps> = (arg) => {
|
||||||
active: "",
|
active: "",
|
||||||
list: [],
|
list: [],
|
||||||
},
|
},
|
||||||
internal: { action_should_refresh: false },
|
internal: { action_should_refresh: false, reset_detail: false },
|
||||||
childs: {},
|
childs: {},
|
||||||
props: {
|
props: {
|
||||||
mode,
|
mode,
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,15 @@ export const should_show_tab = (md: MDLocal) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MDDetail: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => {
|
export const MDDetail: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => {
|
||||||
const local = useLocal({ selected: "", synced: false });
|
|
||||||
const detail = md.childs[md.tab.active];
|
const detail = md.childs[md.tab.active];
|
||||||
const PassProp = mdr.PassProp;
|
const PassProp = mdr.PassProp;
|
||||||
|
|
||||||
|
if (md.internal.reset_detail) {
|
||||||
|
md.internal.reset_detail = false;
|
||||||
|
md.render();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!detail) {
|
if (!detail) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,6 @@ export const MDHeader: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => {
|
||||||
md.header.breadcrumb = [...prefix, ...md.header.master.breadcrumb()];
|
md.header.breadcrumb = [...prefix, ...md.header.master.breadcrumb()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (md.internal.reset_detail) return null;
|
||||||
return <PassProp md={md}>{head}</PassProp>;
|
return <PassProp md={md}>{head}</PassProp>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ export type MDLocalInternal = {
|
||||||
active: string;
|
active: string;
|
||||||
list: string[];
|
list: string[];
|
||||||
};
|
};
|
||||||
internal: { action_should_refresh: boolean };
|
internal: { action_should_refresh: boolean; reset_detail: boolean };
|
||||||
master: {
|
master: {
|
||||||
reload: (arg?: { toast: boolean }) => void;
|
reload: (arg?: { toast: boolean }) => void;
|
||||||
render: () => void;
|
render: () => void;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue