fix title md
This commit is contained in:
parent
4c8ad76035
commit
b3eeaea11e
|
|
@ -25,15 +25,18 @@ export const MasterDetail: FC<MDProps> = (arg) => {
|
|||
gen_table,
|
||||
on_init,
|
||||
_item,
|
||||
title,
|
||||
} = arg;
|
||||
const _ref = useRef({ PassProp, item: _item, childs: {} });
|
||||
const mdr = _ref.current;
|
||||
const md = useLocal<MDLocalInternal>({
|
||||
name,
|
||||
title,
|
||||
status: isEditor ? "init" : "ready",
|
||||
actions: [],
|
||||
header: {
|
||||
breadcrumb: [],
|
||||
internalRender() {},
|
||||
render: () => {},
|
||||
},
|
||||
selected: null,
|
||||
|
|
@ -98,8 +101,18 @@ export const MasterDetail: FC<MDProps> = (arg) => {
|
|||
}
|
||||
}
|
||||
|
||||
if (isEditor) {
|
||||
useEffect(() => {
|
||||
md.title = title;
|
||||
md.header.render();
|
||||
}, [title]);
|
||||
}
|
||||
return (
|
||||
<div className={cx("master-detail c-flex-1 c-flex-col c-flex c-w-full c-h-full")}>
|
||||
<div
|
||||
className={cx(
|
||||
"master-detail c-flex-1 c-flex-col c-flex c-w-full c-h-full"
|
||||
)}
|
||||
>
|
||||
{md.props.show_head === "always" && <MDHeader md={md} mdr={mdr} />}
|
||||
{md.status === "ready" && (
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export const generateMDForm = async (
|
|||
() => {
|
||||
const breads: BreadItem[] = [
|
||||
{
|
||||
label: "List ${formatName(arg.table)}",
|
||||
label: md.title || "List ${formatName(arg.table)}",
|
||||
onClick: () => {
|
||||
md.selected = null;
|
||||
md.tab.active = "master";
|
||||
|
|
|
|||
|
|
@ -10,6 +10,16 @@ export const generateMasterDetail: GenFn<{
|
|||
}> = async (modify, data, arg) => {
|
||||
const { item } = arg;
|
||||
|
||||
try {
|
||||
const fn_title = new Function(
|
||||
`return ${item.edit.props?.title?.value || "''"}`
|
||||
);
|
||||
const title = fn_title();
|
||||
if (!title && item.edit.props?.gen_table) {
|
||||
item.edit.setProp('title', item.edit.props?.gen_table)
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
await generateList(arg, data, false);
|
||||
await generateMDForm(arg, data, false);
|
||||
await item.edit.commit();
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ idx: any;
|
|||
value: `\
|
||||
() => {
|
||||
return [
|
||||
{ label: "List ${formatName(arg.table)}" },
|
||||
{ label: md.title || "List ${formatName(arg.table)}" },
|
||||
] as BreadItem[];
|
||||
};
|
||||
type BreadItem = {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ export type MDProps = {
|
|||
on_init: (md: MDLocal) => void;
|
||||
_item: PrasiItem;
|
||||
deps?: any[];
|
||||
title: string;
|
||||
};
|
||||
|
||||
export type MDActions = {
|
||||
|
|
@ -34,6 +35,7 @@ export type MDActions = {
|
|||
|
||||
export type MDLocalInternal = {
|
||||
name: string;
|
||||
title: string;
|
||||
status: "init" | "unready" | "ready";
|
||||
header: {
|
||||
breadcrumb: BreadItem[];
|
||||
|
|
@ -94,6 +96,7 @@ export type MDLocal = MDLocalInternal & { render: (force?: boolean) => void };
|
|||
|
||||
export const MasterDetailType = `const md = {
|
||||
name: string;
|
||||
title: string;
|
||||
status: string;
|
||||
header: {
|
||||
render: () => void;
|
||||
|
|
|
|||
Loading…
Reference in New Issue