checkpoint

This commit is contained in:
rizky 2024-11-03 21:49:12 -07:00
parent 61845dc62b
commit d580b6ccad
4 changed files with 29 additions and 12 deletions

View File

@ -8,6 +8,7 @@ export const masterDetailParseHash = (md: MDLocal) => {
md.params.hash = {}; md.params.hash = {};
md.params.tabs = {}; md.params.tabs = {};
let has_detail = false;
for (const h of raw_hash.split("#")) { for (const h of raw_hash.split("#")) {
if (h) { if (h) {
if (h.includes("=")) { if (h.includes("=")) {
@ -15,6 +16,9 @@ export const masterDetailParseHash = (md: MDLocal) => {
if (tab_name && tab_val) { if (tab_name && tab_val) {
md.params.hash[tab_name] = tab_val; md.params.hash[tab_name] = tab_val;
} }
if (tab_name === md.name) {
has_detail = true;
}
} else if (h.includes("~")) { } else if (h.includes("~")) {
const [tab_name, tab_val] = h.split("~"); const [tab_name, tab_val] = h.split("~");
if (tab_name && tab_val) { if (tab_name && tab_val) {
@ -24,6 +28,10 @@ export const masterDetailParseHash = (md: MDLocal) => {
} }
} }
if (!has_detail) {
md.selected = null;
}
md.params.links = md.params.links.filter((e) => e); md.params.links = md.params.links.filter((e) => e);
const parsed_link = parseLink(); const parsed_link = parseLink();
@ -69,9 +77,15 @@ export const masterDetailApplyParams = (md: MDLocal) => {
delete md.params.hash[md.name]; delete md.params.hash[md.name];
} }
let has_detail = false;
for (const [k, v] of Object.entries(md.params.hash)) { for (const [k, v] of Object.entries(md.params.hash)) {
if (k === md.name) {
has_detail = true;
}
hash += `#${k}=${v}`; hash += `#${k}=${v}`;
} }
for (const [k, v] of Object.entries(md.params.tabs)) { for (const [k, v] of Object.entries(md.params.tabs)) {
hash += `#${k}~${v}`; hash += `#${k}~${v}`;
} }
@ -79,16 +93,20 @@ export const masterDetailApplyParams = (md: MDLocal) => {
if (!isEditor) { if (!isEditor) {
location.hash = hash; location.hash = hash;
} }
if (!isEditor) { if (!isEditor) {
if (md.props.tab_mode === "v-tab" || md.props.tab_mode === "h-tab") { if (md.props.tab_mode === "v-tab" || md.props.tab_mode === "h-tab") {
try { try {
if(row && md?.childs?.form?.fm && md?.childs?.form?.fm?.status === "ready" && md.selected?.id){ if (
row &&
md?.childs?.form?.fm &&
md?.childs?.form?.fm?.status === "ready" &&
md.selected?.id
) {
md.childs.form.fm.reload(); md.childs.form.fm.reload();
// console.log("MASUK???") // console.log("MASUK???")
} }
}catch(ex){ } catch (ex) {}
}
} }
} }
}; };

View File

@ -53,7 +53,6 @@ export const SheetCn: FC<{
local.render(); local.render();
} }
} else { } else {
console.log(typeof onInit)
if (typeof onInit === "function") { if (typeof onInit === "function") {
onInit({ onInit({
data: local, data: local,

View File

@ -20,9 +20,9 @@ export const Typeahead = lazify(
); );
/** Master - Detail - List - Form */ /** Master - Detail - List - Form */
// export const MasterDetail = lazify( export const MasterDetail = lazify(
// async () => (await import("lib/comps/md/MasterDetail")).MasterDetail async () => (await import("lib/comps/md/MasterDetail")).MasterDetail
// ); );
export const MDRenderMaster = lazify( export const MDRenderMaster = lazify(
async () => (await import("lib/comps/md/parts/MDMaster")).MDRenderMaster async () => (await import("lib/comps/md/parts/MDMaster")).MDRenderMaster
); );