fixing lib
This commit is contained in:
parent
d14e07a1fc
commit
d733a1c52b
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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<FieldProp> = (arg) => {
|
||||
const showlabel = arg.show_label || "y";
|
||||
|
|
@ -22,8 +41,9 @@ export const Field: FC<FieldProp> = (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<FieldProp> = (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<FieldProp> = (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 = {
|
||||
|
|
|
|||
|
|
@ -190,27 +190,17 @@ export const TableEdit: FC<{
|
|||
`
|
||||
)}
|
||||
>
|
||||
<thead>
|
||||
<tr className=" ">
|
||||
{columns.map((header) => {
|
||||
return (
|
||||
<th
|
||||
key={header.key}
|
||||
className={cx(
|
||||
css`
|
||||
background-color: #f9f9f9;
|
||||
`,
|
||||
header.width > 0
|
||||
? css`
|
||||
width: ${header.width}px;
|
||||
`
|
||||
: ""
|
||||
)}
|
||||
>
|
||||
<div
|
||||
{show_header !== "n" && (
|
||||
<thead>
|
||||
<tr className=" ">
|
||||
{columns.map((header) => {
|
||||
return (
|
||||
<th
|
||||
key={header.key}
|
||||
className={cx(
|
||||
"rdg-cell c-py-2 c-px-4 c-flex c-flex-row c-items-center c-h-full",
|
||||
|
||||
css`
|
||||
background-color: #f9f9f9;
|
||||
`,
|
||||
header.width > 0
|
||||
? css`
|
||||
width: ${header.width}px;
|
||||
|
|
@ -218,14 +208,35 @@ export const TableEdit: FC<{
|
|||
: ""
|
||||
)}
|
||||
>
|
||||
{header.label}
|
||||
</div>
|
||||
</th>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="c-pb-2">
|
||||
<div
|
||||
className={cx(
|
||||
"rdg-cell c-py-2 c-px-4 c-flex c-flex-row c-items-center c-h-full",
|
||||
|
||||
header.width > 0
|
||||
? css`
|
||||
width: ${header.width}px;
|
||||
`
|
||||
: ""
|
||||
)}
|
||||
>
|
||||
{header.label}
|
||||
</div>
|
||||
</th>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
</thead>
|
||||
)}
|
||||
<tbody
|
||||
className={cx(
|
||||
"c-pb-2",
|
||||
css`
|
||||
label {
|
||||
width: 100%;
|
||||
}
|
||||
`
|
||||
)}
|
||||
>
|
||||
{Array.isArray(value) && value.length ? (
|
||||
<>
|
||||
{value.map((row: any, idx: number) => {
|
||||
|
|
@ -233,8 +244,21 @@ export const TableEdit: FC<{
|
|||
<tr>
|
||||
{columns.map((header) => {
|
||||
return (
|
||||
<td>
|
||||
<div className="c-flex c-flex-row c-py-2 c-w-full c-h-full">
|
||||
<td
|
||||
className={cx(
|
||||
header.width > 0
|
||||
? css`
|
||||
width: ${header.width}px;
|
||||
`
|
||||
: ""
|
||||
)}
|
||||
>
|
||||
<div
|
||||
className={cx(
|
||||
"c-flex c-flex-row c-pb-1 c-w-full c-h-full",
|
||||
idx === 0 && "c-pt-1"
|
||||
)}
|
||||
>
|
||||
{header.renderCell({
|
||||
props: {
|
||||
row: row,
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div className="c-flex-grow c-flex-row c-flex c-w-full c-h-full">
|
||||
<input
|
||||
|
|
|
|||
Loading…
Reference in New Issue