diff --git a/comps/list/TableList.tsx b/comps/list/TableList.tsx index 8afa22b..c5d27eb 100755 --- a/comps/list/TableList.tsx +++ b/comps/list/TableList.tsx @@ -49,6 +49,8 @@ type TableListProp = { render_row?: (child: any, data: any) => ReactNode; rowHeight?: number; render_col?: (props: any) => ReactNode; + soft_delete_field: string; + }; const w = window as any; const selectCellClassname = css` diff --git a/comps/md/gen/tbl-list/on_load.ts b/comps/md/gen/tbl-list/on_load.ts index 9e14b0d..f94bc4f 100755 --- a/comps/md/gen/tbl-list/on_load.ts +++ b/comps/md/gen/tbl-list/on_load.ts @@ -50,7 +50,8 @@ export const on_load = ({ reload: () => Promise; orderBy?: Record; paging: { take: number; skip: number }; - mode: 'count' | 'query' + mode: 'count' | 'query'; + where?: any } `; }; diff --git a/exports.tsx b/exports.tsx index a77052b..e6d032c 100755 --- a/exports.tsx +++ b/exports.tsx @@ -114,3 +114,4 @@ export { getPathname } from "./utils/pathname"; export * from "@/comps/ui/typeahead"; export * from "@/comps/ui/input"; +export {softDeleteFilter} from "@/utils/soft-delete-filter" \ No newline at end of file diff --git a/gen/gen_table_list/on_load.ts b/gen/gen_table_list/on_load.ts index 34c857b..76ace3b 100755 --- a/gen/gen_table_list/on_load.ts +++ b/gen/gen_table_list/on_load.ts @@ -50,7 +50,8 @@ type TableOnLoad = { reload: () => Promise; orderBy?: Record; paging: { take: number; skip: number }; - mode: 'count' | 'query' + mode: 'count' | 'query'; + where?: any } `; }; diff --git a/utils/soft-delete-filter.ts b/utils/soft-delete-filter.ts new file mode 100755 index 0000000..49e6024 --- /dev/null +++ b/utils/soft-delete-filter.ts @@ -0,0 +1,25 @@ +export const softDeleteFilter = ( + where: any, + soft: { + field: string; + type: "boolean" | "nullable"; + } +) => { + console.log({where}) + const defaultParam = typeof where === "object" ? where : {} + const result = { + AND: [ + typeof where === "object" ? { ...defaultParam }, + { + [soft.field]: + soft.type === "boolean" + ? true + : { + not: null, + }, + }, + ], + } + console.log(result) + return result; +};