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 { ArrowRight } from "lucide-react";
|
||||||
import { FC, useEffect } from "react";
|
import { FC, useEffect } from "react";
|
||||||
import { Skeleton } from "../ui/skeleton";
|
import { Skeleton } from "../ui/skeleton";
|
||||||
|
import { formatName } from "lib/gen/utils";
|
||||||
|
|
||||||
export const Detail: FC<{
|
export const Detail: FC<{
|
||||||
detail: (
|
detail: (
|
||||||
|
|
@ -15,7 +16,7 @@ export const Detail: FC<{
|
||||||
bind: (fn: (on_load: any) => void) => void;
|
bind: (fn: (on_load: any) => void) => void;
|
||||||
}) => Promise<any>);
|
}) => Promise<any>);
|
||||||
mode: "standard" | "compact" | "inline";
|
mode: "standard" | "compact" | "inline";
|
||||||
}> = ({ detail, mode, on_load }) => {
|
}> = ({ detail: _detail, mode, on_load }) => {
|
||||||
const local = useLocal({
|
const local = useLocal({
|
||||||
status: "init" as "init" | "loading" | "ready",
|
status: "init" as "init" | "loading" | "ready",
|
||||||
detail: null as any,
|
detail: null as any,
|
||||||
|
|
@ -25,6 +26,20 @@ export const Detail: FC<{
|
||||||
bound: false,
|
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 (!isEditor) {
|
||||||
if (
|
if (
|
||||||
location.pathname !== local.pathname ||
|
location.pathname !== local.pathname ||
|
||||||
|
|
@ -89,7 +104,11 @@ export const Detail: FC<{
|
||||||
if (!isEditor) {
|
if (!isEditor) {
|
||||||
values = local.detail || {};
|
values = local.detail || {};
|
||||||
} else {
|
} else {
|
||||||
values = detail(null);
|
if (typeof on_load === "function") {
|
||||||
|
values = detail(on_load({} as any));
|
||||||
|
} else {
|
||||||
|
values = detail(on_load);
|
||||||
|
}
|
||||||
local.status = "ready";
|
local.status = "ready";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ const prepForSum = (obj: any): any => {
|
||||||
return obj.map((e) => prepForSum(e));
|
return obj.map((e) => prepForSum(e));
|
||||||
}
|
}
|
||||||
const new_obj: any = {};
|
const new_obj: any = {};
|
||||||
|
if (obj) {
|
||||||
for (const [k, v] of Object.entries(obj) as any) {
|
for (const [k, v] of Object.entries(obj) as any) {
|
||||||
if (typeof v === "object" && v.id) {
|
if (typeof v === "object" && v.id) {
|
||||||
new_obj[k] = v.id;
|
new_obj[k] = v.id;
|
||||||
|
|
@ -24,6 +25,7 @@ const prepForSum = (obj: any): any => {
|
||||||
}
|
}
|
||||||
new_obj[k] = v;
|
new_obj[k] = v;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return new_obj;
|
return new_obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { update } from "autosize";
|
|
||||||
import { useLocal } from "lib/utils/use-local";
|
import { useLocal } from "lib/utils/use-local";
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,10 @@ export const MDRenderMaster: FC<{
|
||||||
size: width,
|
size: width,
|
||||||
min_size: min_width,
|
min_size: min_width,
|
||||||
});
|
});
|
||||||
if (md.panel) {
|
// if (md.panel) {
|
||||||
md.panel.min_size = min_width;
|
// md.panel.min_size = min_width;
|
||||||
md.panel.size = width;
|
// md.panel.size = width;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}, Object.values(md.deps || {}) || []);
|
}, Object.values(md.deps || {}) || []);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,11 @@ export const Popover = lazify(
|
||||||
export const Progress = lazify(
|
export const Progress = lazify(
|
||||||
async () => (await import("@/comps/ui/progress")).Progress
|
async () => (await import("@/comps/ui/progress")).Progress
|
||||||
);
|
);
|
||||||
|
|
||||||
export const Dialog = lazify(
|
export const Dialog = lazify(
|
||||||
async () => (await import("@/comps/ui/dialog")).Dialog
|
async () => (await import("@/comps/ui/dialog")).Dialog
|
||||||
);
|
);
|
||||||
|
|
||||||
export const Typeahead = lazify(
|
export const Typeahead = lazify(
|
||||||
async () => (await import("@/comps/ui/typeahead")).Typeahead
|
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 (
|
return (
|
||||||
<div className="c-flex c-space-x-2 c-items-center">
|
<div className="c-flex c-space-x-2 c-items-center">
|
||||||
<div>{value}</div>
|
<div>{_value}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue