fixing detail + field bug
This commit is contained in:
parent
d611e4f4a4
commit
9261600dc0
|
|
@ -3,6 +3,7 @@ import { cx } from "class-variance-authority";
|
|||
import { ArrowRight } from "lucide-react";
|
||||
import { FC, useEffect } from "react";
|
||||
import { Skeleton } from "../ui/skeleton";
|
||||
import { formatName } from "lib/gen/utils";
|
||||
|
||||
export const Detail: FC<{
|
||||
detail: (
|
||||
|
|
@ -15,7 +16,7 @@ export const Detail: FC<{
|
|||
bind: (fn: (on_load: any) => void) => void;
|
||||
}) => Promise<any>);
|
||||
mode: "standard" | "compact" | "inline";
|
||||
}> = ({ detail, mode, on_load }) => {
|
||||
}> = ({ detail: _detail, mode, on_load }) => {
|
||||
const local = useLocal({
|
||||
status: "init" as "init" | "loading" | "ready",
|
||||
detail: null as any,
|
||||
|
|
@ -25,6 +26,20 @@ export const Detail: FC<{
|
|||
bound: false,
|
||||
});
|
||||
|
||||
let detail: any = _detail;
|
||||
if (typeof detail !== "function") {
|
||||
detail = (load: any) => {
|
||||
const result: any = {};
|
||||
if (typeof load === "object" && !!load) {
|
||||
for (const [k, v] of Object.entries(load)) {
|
||||
if (k !== "id")
|
||||
if (typeof v !== "object") result[k] = [formatName(k), v];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
if (!isEditor) {
|
||||
if (
|
||||
location.pathname !== local.pathname ||
|
||||
|
|
@ -89,7 +104,11 @@ export const Detail: FC<{
|
|||
if (!isEditor) {
|
||||
values = local.detail || {};
|
||||
} else {
|
||||
values = detail(null);
|
||||
if (typeof on_load === "function") {
|
||||
values = detail(on_load({} as any));
|
||||
} else {
|
||||
values = detail(on_load);
|
||||
}
|
||||
local.status = "ready";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,16 +13,18 @@ const prepForSum = (obj: any): any => {
|
|||
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 (obj) {
|
||||
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;
|
||||
}
|
||||
if (typeof v === "object" && v.connect.id) {
|
||||
new_obj[k] = v.connect.id;
|
||||
continue;
|
||||
}
|
||||
new_obj[k] = v;
|
||||
}
|
||||
return new_obj;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { update } from "autosize";
|
||||
import { useLocal } from "lib/utils/use-local";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ export const MDRenderMaster: FC<{
|
|||
size: width,
|
||||
min_size: min_width,
|
||||
});
|
||||
if (md.panel) {
|
||||
md.panel.min_size = min_width;
|
||||
md.panel.size = width;
|
||||
}
|
||||
// if (md.panel) {
|
||||
// md.panel.min_size = min_width;
|
||||
// md.panel.size = width;
|
||||
// }
|
||||
}
|
||||
}, Object.values(md.deps || {}) || []);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { lazify, lazifyMany } from "@/utils/lazify";
|
|||
import __get from "lodash.get";
|
||||
import { sum } from "./utils/sum";
|
||||
|
||||
export const _sum = sum;
|
||||
export const _sum = sum;
|
||||
export const _get = __get;
|
||||
|
||||
export const Accordion = lazify(
|
||||
|
|
@ -19,9 +19,11 @@ export const Popover = lazify(
|
|||
export const Progress = lazify(
|
||||
async () => (await import("@/comps/ui/progress")).Progress
|
||||
);
|
||||
|
||||
export const Dialog = lazify(
|
||||
async () => (await import("@/comps/ui/dialog")).Dialog
|
||||
);
|
||||
|
||||
export const Typeahead = lazify(
|
||||
async () => (await import("@/comps/ui/typeahead")).Typeahead
|
||||
);
|
||||
|
|
|
|||
|
|
@ -171,9 +171,14 @@ export const FormatValue: FC<{
|
|||
);
|
||||
}
|
||||
|
||||
let _value = value;
|
||||
if (typeof value === 'string' && value.startsWith('BigInt::')) {
|
||||
_value = value.substring('BigInt::'.length)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="c-flex c-space-x-2 c-items-center">
|
||||
<div>{value}</div>
|
||||
<div>{_value}</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue