fixing detail + field bug

This commit is contained in:
rizky 2024-08-14 02:34:24 -07:00
parent d611e4f4a4
commit 9261600dc0
6 changed files with 45 additions and 18 deletions

View File

@ -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";
}

View File

@ -13,6 +13,7 @@ const prepForSum = (obj: any): any => {
return obj.map((e) => prepForSum(e));
}
const new_obj: any = {};
if (obj) {
for (const [k, v] of Object.entries(obj) as any) {
if (typeof v === "object" && v.id) {
new_obj[k] = v.id;
@ -24,6 +25,7 @@ const prepForSum = (obj: any): any => {
}
new_obj[k] = v;
}
}
return new_obj;
};

View File

@ -1,4 +1,3 @@
import { update } from "autosize";
import { useLocal } from "lib/utils/use-local";
import { useEffect, useRef } from "react";

View File

@ -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 || {}) || []);

View File

@ -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
);

View File

@ -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>
);
};