From eb4d36c730a05c21bcb11f5f25ee93e6eae312b9 Mon Sep 17 00:00:00 2001 From: Rizky Date: Mon, 24 Jun 2024 21:15:34 -0700 Subject: [PATCH] fix --- comps/filter/MasterFilter.tsx | 5 ++--- comps/form/gen/on_load.ts | 1 + comps/list/TableList.tsx | 6 +++--- gen/gen_form/on_load.ts | 1 + utils/prasi-events.ts | 5 ++++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/comps/filter/MasterFilter.tsx b/comps/filter/MasterFilter.tsx index 1b54c98..89786ab 100755 --- a/comps/filter/MasterFilter.tsx +++ b/comps/filter/MasterFilter.tsx @@ -1,11 +1,10 @@ import { useLocal } from "@/utils/use-local"; -import { FC, ReactNode, useEffect } from "react"; +import { FC, ReactNode } from "react"; import { createPortal } from "react-dom"; import { GenField } from "../form/typings"; -import { default_filter_local, filter_window } from "./utils/types"; import { FilterContent } from "./FilterContent"; -import { getPathname } from "lib/utils/pathname"; import { getFilter } from "./utils/get-filter"; +import { default_filter_local } from "./utils/types"; type FilterMode = "regular" | "inline" | "popup"; diff --git a/comps/form/gen/on_load.ts b/comps/form/gen/on_load.ts index 39254c5..bb11af5 100755 --- a/comps/form/gen/on_load.ts +++ b/comps/form/gen/on_load.ts @@ -40,6 +40,7 @@ async (opt) => { raw_id = md.selected[pk]; } } + if (parseInt(raw_id)) raw_id = parseInt(raw_id); ${opt?.before_load ? opt.before_load : `let id = raw_id`} let item = {}; diff --git a/comps/list/TableList.tsx b/comps/list/TableList.tsx index fc65b03..184601c 100755 --- a/comps/list/TableList.tsx +++ b/comps/list/TableList.tsx @@ -211,7 +211,7 @@ export const TableList: FC = ({ const orderBy = local.sort.orderBy || undefined; const where = filterWhere(filter_name, __props); - call_prasi_events("tablelist", "where", [where]); + call_prasi_events("tablelist", "where", [__props?.gen__table, where]); const load_args: any = { async reload() {}, @@ -327,7 +327,7 @@ export const TableList: FC = ({ ); if (mode_child) { const tbl = _item.edit.childs[0].edit.childs.find( - (e) => get(e, "id") === mode_child.id + (e: any) => get(e, "id") === mode_child.id ); const meta = tbl; if (meta && meta.childs) { @@ -830,7 +830,7 @@ function isAtBottom({ currentTarget }: React.UIEvent): boolean { ); } -function getProp(child: IItem, name: string, defaultValue?: any) { +function getProp(child: any, name: string, defaultValue?: any) { const fn = new Function( `return ${get(child, `component.props.${name}.valueBuilt`) || `null`}` ); diff --git a/gen/gen_form/on_load.ts b/gen/gen_form/on_load.ts index 9e085c2..bd9b3b4 100755 --- a/gen/gen_form/on_load.ts +++ b/gen/gen_form/on_load.ts @@ -40,6 +40,7 @@ async (opt) => { raw_id = md.selected[pk]; } } + if (parseInt(raw_id)) raw_id = parseInt(raw_id); ${ opt?.before_load diff --git a/utils/prasi-events.ts b/utils/prasi-events.ts index d851aea..4b1e711 100755 --- a/utils/prasi-events.ts +++ b/utils/prasi-events.ts @@ -1,4 +1,5 @@ import { FMLocal } from "../.."; +import { Prisma } from "../../typings/prisma"; const events = { form: { @@ -10,7 +11,9 @@ const events = { before_load: async (fm: FMLocal) => {}, after_load: async (fm: FMLocal) => {}, }, - tablelist: { where: async (where: any) => {} }, + tablelist: { + where: async (table: T, where: any) => {}, + }, }; let w = null as any;