From 101c439ef0c0be628caa1f3d49f1139eca232a43 Mon Sep 17 00:00:00 2001 From: rizky Date: Wed, 14 Aug 2024 15:28:16 -0700 Subject: [PATCH] fix --- comps/form/field/type/TypeUploadSingle.tsx | 4 +++- comps/md/MasterDetail.tsx | 1 + comps/md/utils/md-hash.ts | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/comps/form/field/type/TypeUploadSingle.tsx b/comps/form/field/type/TypeUploadSingle.tsx index 8279db2..0c64958 100755 --- a/comps/form/field/type/TypeUploadSingle.tsx +++ b/comps/form/field/type/TypeUploadSingle.tsx @@ -19,6 +19,8 @@ export const FieldUploadSingle: FC<{ on_change: (e: any) => void | Promise; }> = ({ field, fm, prop, on_change, arg }) => { const styling = arg.upload_style ? arg.upload_style : "full"; + const disabled = + typeof field.disabled === "function" ? field.disabled() : field.disabled; let value: any = fm.data[field.name]; // let type_upload = const input = useLocal({ @@ -142,7 +144,7 @@ export const FieldUploadSingle: FC<{ ` )} > - {!isEditor && ( + {!isEditor && !disabled && ( (input.ref = ref)} type="file" diff --git a/comps/md/MasterDetail.tsx b/comps/md/MasterDetail.tsx index d5d0b9b..24f5038 100755 --- a/comps/md/MasterDetail.tsx +++ b/comps/md/MasterDetail.tsx @@ -89,6 +89,7 @@ export const MasterDetail: FC = (arg) => { const pk = fields.find((e) => e.is_pk); md.pk = pk; md.params.parse(); + if (pk) { const value = md.params.hash[md.name]; if (!value && md.selected && Object.keys(md.selected).length === 0) { diff --git a/comps/md/utils/md-hash.ts b/comps/md/utils/md-hash.ts index db16b38..db2fa16 100755 --- a/comps/md/utils/md-hash.ts +++ b/comps/md/utils/md-hash.ts @@ -80,6 +80,15 @@ export const masterDetailApplyParams = (md: MDLocal) => { } }; +const cleanHash = (hash: string) => { + return hash + .split("#") + .filter(function (value, index, self) { + return self.indexOf(value) === index; + }) + .join("#"); +}; + export const breadcrumbPrefix = (md: MDLocal) => { let prefix: (BreadItem & { url: string })[] = []; if (md.params.links && md.params.links.length > 0) { @@ -100,14 +109,14 @@ export const breadcrumbPrefix = (md: MDLocal) => { const hashIndex = hashes.indexOf(link.hash); const link_hashes = hashes.slice(0, hashIndex).join("+"); - const lnk = link_hashes ? `#lnk=${link_hashes}` : ``; + let lnk = link_hashes ? `#lnk=${link_hashes}` : ``; if (p.md) { - url = `${p.url || link.url}#${p.md.name}=${p.md.value}${lnk}`; - } else { - url = `${p.url || link.url}${lnk}`; + lnk = `#${p.md.name}=${p.md.value}${lnk}`; } + url = `${p.url || link.url}${cleanHash(lnk)}`; + if (url) { navigate(url); }