From 8ec266d47c11a0226dffac26daefff8f2f2f710d Mon Sep 17 00:00:00 2001 From: rizky Date: Tue, 13 Aug 2024 01:50:37 -0700 Subject: [PATCH] fixing filter where by md name in link params --- comps/form/field/type/TypeLink.tsx | 1 + comps/list/TableList.tsx | 6 ++++-- comps/md/utils/md-hash.ts | 1 + preset/menu/Layout.tsx | 1 + utils/globals.d.ts | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/comps/form/field/type/TypeLink.tsx b/comps/form/field/type/TypeLink.tsx index f4c1d22..c004013 100755 --- a/comps/form/field/type/TypeLink.tsx +++ b/comps/form/field/type/TypeLink.tsx @@ -157,6 +157,7 @@ export const FieldLink: FC<{ export type LinkParam = { url: string; + name?: string; where: any; create: any; update: any; diff --git a/comps/list/TableList.tsx b/comps/list/TableList.tsx index fc217f6..e8159a1 100755 --- a/comps/list/TableList.tsx +++ b/comps/list/TableList.tsx @@ -214,8 +214,10 @@ export const TableList: FC = ({ const last = md.params.links[md.params.links.length - 1]; if (last && last.where) { - for (const [k, v] of Object.entries(last.where)) { - where[k] = v; + if ((last.name && last.name === md.name) || !last.name) { + for (const [k, v] of Object.entries(last.where)) { + where[k] = v; + } } } } diff --git a/comps/md/utils/md-hash.ts b/comps/md/utils/md-hash.ts index 518b36c..db16b38 100755 --- a/comps/md/utils/md-hash.ts +++ b/comps/md/utils/md-hash.ts @@ -90,6 +90,7 @@ export const breadcrumbPrefix = (md: MDLocal) => { } } for (const link of md.params.links) { + if (link.name && link.name !== md.name) continue; for (const p of link.prefix) { prefix.push({ label: p.label, diff --git a/preset/menu/Layout.tsx b/preset/menu/Layout.tsx index 6b96963..fb6d962 100755 --- a/preset/menu/Layout.tsx +++ b/preset/menu/Layout.tsx @@ -92,6 +92,7 @@ export const Layout: FC = (props) => { }) || []; const values: LinkParam = { + name: params.name, url: getPathname({ hash: true }), prefix, hash: "", diff --git a/utils/globals.d.ts b/utils/globals.d.ts index 9dfc6e1..f253dc1 100755 --- a/utils/globals.d.ts +++ b/utils/globals.d.ts @@ -9,6 +9,7 @@ declare var preloaded: (url: string) => boolean; declare var navigate: ( url: string, params?: { + name?: string; where?: any; create?: any; update?: any;