diff --git a/comps/filter/parser/filter-where.ts b/comps/filter/parser/filter-where.ts index 856aabb..c729a2f 100755 --- a/comps/filter/parser/filter-where.ts +++ b/comps/filter/parser/filter-where.ts @@ -14,6 +14,7 @@ export const filterWhere = (filter_name: string, p: any) => { if (pf.mode === "raw") { const data = pf.data?._where ? pf.data?._where : pf.data; for (const [k, v] of Object.entries(data)) { + if (k.startsWith("_")) continue; where[k] = v; } } else { diff --git a/comps/form/field/Field.tsx b/comps/form/field/Field.tsx index ff3edfb..7e02195 100755 --- a/comps/form/field/Field.tsx +++ b/comps/form/field/Field.tsx @@ -1,12 +1,31 @@ import { useLocal } from "@/utils/use-local"; import { call_prasi_events } from "lib/exports"; +import { hashSum } from "lib/utils/hash-sum"; import { FC, useEffect } from "react"; import { FieldProp } from "../typings"; import { useField } from "../utils/use-field"; import { validate } from "../utils/validate"; import { FieldInput } from "./FieldInput"; import { Label } from "./Label"; -import { hashSum } from "lib/utils/hash-sum"; + +const prepForSum = (obj: any): any => { + if (Array.isArray(obj)) { + return obj.map((e) => prepForSum(e)); + } + const new_obj: any = {}; + for (const [k, v] of Object.entries(obj) as any) { + if (typeof v === "object" && v.id) { + new_obj[k] = v.id; + continue; + } + if (typeof v === "object" && v.connect.id) { + new_obj[k] = v.connect.id; + continue; + } + new_obj[k] = v; + } + return new_obj; +}; export const Field: FC = (arg) => { const showlabel = arg.show_label || "y"; @@ -22,8 +41,9 @@ export const Field: FC = (arg) => { useEffect(() => { if (fm.save_status === "init" || fm.status !== "ready") return; if (local.prev_val === undefined) { - if (typeof fm.data[name] === "object") { - const sfied = hashSum(fm.data[name]); + if (typeof fm.data[name] === "object" && fm.deps.md) { + const sfied = hashSum(prepForSum(fm.data[name])); + if (sfied !== local.prev_val) { local.prev_val = sfied; } else { @@ -36,8 +56,9 @@ export const Field: FC = (arg) => { } if (local.prev_val !== fm.data[name]) { - if (typeof fm.data[name] === "object") { - const sfied = hashSum(fm.data[name]); + if (typeof fm.data[name] === "object" && fm.deps.md) { + const sfied = hashSum(prepForSum(fm.data[name])); + if (sfied !== local.prev_val) { local.prev_val = sfied; } else { @@ -58,7 +79,9 @@ export const Field: FC = (arg) => { arg.on_change({ value: fm.data[name], name, fm }); } - fm.save_status = "unsaved"; + if (fm.deps.md) { + fm.save_status = "unsaved"; + } if (!fm.events) { fm.events = { diff --git a/comps/form/field/table-edit/TableEdit.tsx b/comps/form/field/table-edit/TableEdit.tsx index 673f2a4..c336653 100755 --- a/comps/form/field/table-edit/TableEdit.tsx +++ b/comps/form/field/table-edit/TableEdit.tsx @@ -190,27 +190,17 @@ export const TableEdit: FC<{ ` )} > - - - {columns.map((header) => { - return ( - 0 - ? css` - width: ${header.width}px; - ` - : "" - )} - > -
+ + {columns.map((header) => { + return ( + 0 ? css` width: ${header.width}px; @@ -218,14 +208,35 @@ export const TableEdit: FC<{ : "" )} > - {header.label} -
- - ); - })} - - - +
0 + ? css` + width: ${header.width}px; + ` + : "" + )} + > + {header.label} +
+ + ); + })} + + + )} + {Array.isArray(value) && value.length ? ( <> {value.map((row: any, idx: number) => { @@ -233,8 +244,21 @@ export const TableEdit: FC<{ {columns.map((header) => { return ( - -
+ 0 + ? css` + width: ${header.width}px; + ` + : "" + )} + > +
{header.renderCell({ props: { row: row, diff --git a/comps/form/field/type/TypeMoney.tsx b/comps/form/field/type/TypeMoney.tsx index ae6c230..ba9b1eb 100755 --- a/comps/form/field/type/TypeMoney.tsx +++ b/comps/form/field/type/TypeMoney.tsx @@ -22,7 +22,6 @@ export const FieldMoney: FC<{ const disabled = typeof field.disabled === "function" ? field.disabled() : field.disabled; - const money = formatMoney(Number(value) || 0); return (