diff --git a/comps/custom/Breadcrumb.tsx b/comps/custom/Breadcrumb.tsx index ca0fc2d..1afe6af 100755 --- a/comps/custom/Breadcrumb.tsx +++ b/comps/custom/Breadcrumb.tsx @@ -1,6 +1,7 @@ import { useLocal } from "@/utils/use-local"; import { FC, ReactNode, useEffect } from "react"; import { Skeleton } from "../ui/skeleton"; +import { MDLocal } from "../md/utils/typings"; export type BreadItem = { label: React.ReactNode; @@ -15,33 +16,37 @@ type BreadcrumbProps = { className?: string; props?: any; value?: BreadItem[]; - item?: any; + item?: any }; export const Breadcrumb: FC = (_arg) => { const { on_load, item } = _arg; - const local = useLocal({ list: _arg.value || ([] as BreadItem[]), status: "init" as "init" | "loading" | "ready", params: {}, }); - + // code review: md.breadcrumb yang di set di props value dipindahkan di on_load + // dan ketika panjang _arg.value bernilai null maka status berubah menjadi init + // untuk menjalankan on_load + // case: ketika refreshBread dijalankan pada MasterDetail + // md.breadcrum yang awalnya array kosong akan berisi satu array namun + // md.breadcrumb yang diterima di komponen ini tidak berubah tetap seperti + // value default yakni array kosong if (_arg.value) { local.list = _arg.value; local.status = "ready"; + if(!_arg.value.length) local.status = "init" } - if (local.status === "init") { let should_load = true; local.status = "loading"; - if (isEditor && item && breadcrumbData[item.id]) { local.list = breadcrumbData[item.id]; local.status = "ready"; should_load = false; + if(!local.list.length) should_load = true; } - if (should_load && typeof on_load === "function") { const callback = (res: any) => { local.list = res; diff --git a/comps/filter/Filter.tsx b/comps/filter/Filter.tsx new file mode 100644 index 0000000..88d254c --- /dev/null +++ b/comps/filter/Filter.tsx @@ -0,0 +1,26 @@ +import { useLocal } from "@/utils/use-local"; +import get from "lodash.get"; +import { FC, useEffect, useRef } from "react"; + +export const MasterFilter: FC<{ + name: string; + value: any; + child: any; +}> = ({name, value, child }) => { + useEffect(() => { + if (!isEditor) { + const w = window as any; + if (typeof w["prasi_filter"] !== "object") w["prasi_filter"] = {}; + if (typeof w["prasi_filter"][name] !== "object") + w["prasi_filter"][name] = {}; + const val = value(); + w["prasi_filter"][name] = { + ...w["prasi_filter"][name], + ...val + }; + w.prasiContext.render(); + } + },[]) + + return
{child}
; +}; diff --git a/comps/form/Form.tsx b/comps/form/Form.tsx index 552faed..69f5d03 100755 --- a/comps/form/Form.tsx +++ b/comps/form/Form.tsx @@ -10,7 +10,10 @@ import { formReload } from "./utils/reload"; const editorFormWidth = {} as Record; +export { FMLocal } from "./typings"; + export const Form: FC = (props) => { + const { PassProp, body } = props; const fm = useLocal({ data: editorFormData[props.item.id] @@ -104,14 +107,13 @@ export const Form: FC = (props) => { formInit(fm, props); fm.reload(); } - if (document.getElementsByClassName("prasi-toaster").length === 0) { const elemDiv = document.createElement("div"); elemDiv.className = "prasi-toaster"; document.body.appendChild(elemDiv); } const toaster_el = document.getElementsByClassName("prasi-toaster")[0]; - + if (fm.status === "resizing") { setTimeout(() => { fm.status = "ready"; @@ -119,7 +121,6 @@ export const Form: FC = (props) => { }, 100); return null; } - return (
{ diff --git a/comps/form/field/Field.tsx b/comps/form/field/Field.tsx index fb0895c..aa78974 100755 --- a/comps/form/field/Field.tsx +++ b/comps/form/field/Field.tsx @@ -25,10 +25,8 @@ export const Field: FC = (arg) => { if (field.status === "init" && !isEditor) return null; const errors = fm.error.get(field.name); - const props = { ...arg.props }; delete props.className; - return (