fix
This commit is contained in:
parent
3cbe406f67
commit
c1b3a9ac51
|
|
@ -1,6 +1,6 @@
|
|||
import { TableList } from "lib/comps/list/TableList";
|
||||
import { useLocal } from "lib/utils/use-local";
|
||||
import { FC, useRef } from "react";
|
||||
import { FC, useEffect, useRef } from "react";
|
||||
import { FMLocal } from "../../typings";
|
||||
|
||||
export const TableEdit: FC<{
|
||||
|
|
@ -17,7 +17,6 @@ export const TableEdit: FC<{
|
|||
const local = useLocal(
|
||||
{
|
||||
tbl: null as any,
|
||||
rowHeight: new WeakMap<any, Record<string, HTMLDivElement>>(),
|
||||
},
|
||||
() => {}
|
||||
);
|
||||
|
|
@ -32,6 +31,10 @@ export const TableEdit: FC<{
|
|||
}
|
||||
const value = fm.data[name];
|
||||
|
||||
useEffect(() => {
|
||||
local.tbl.render();
|
||||
}, [3000]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="c-w-full c-h-full c-flex c-flex-col">
|
||||
|
|
@ -85,16 +88,31 @@ export const TableEdit: FC<{
|
|||
>
|
||||
<TableList
|
||||
row_height={(row) => {
|
||||
const rh = local.rowHeight.get(row);
|
||||
|
||||
let h = 50;
|
||||
if (rh) {
|
||||
for (const div of Object.values(rh)) {
|
||||
if (div) {
|
||||
if (div.offsetHeight > 50) h = div.offsetHeight + 6;
|
||||
if (local.tbl) {
|
||||
const data = local.tbl.data;
|
||||
const el = local.tbl.el as HTMLDivElement;
|
||||
let idx = 0;
|
||||
if (Array.isArray(data)) {
|
||||
for (let k = 0; k < data.length; k++) {
|
||||
if (data[k] === row) {
|
||||
idx = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rowdiv = el.querySelectorAll(`.rdg-row`)[
|
||||
idx
|
||||
] as HTMLDivElement;
|
||||
if (rowdiv) {
|
||||
rowdiv.querySelectorAll(".field").forEach((field) => {
|
||||
const div = field as HTMLDivElement;
|
||||
h = Math.max(h, div.offsetHeight + 10);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return h;
|
||||
}}
|
||||
feature={[]}
|
||||
|
|
@ -123,16 +141,8 @@ export const TableEdit: FC<{
|
|||
const fm_row = { ...fm, render: local.render };
|
||||
fm_row.data = props.row;
|
||||
local.tbl = tbl;
|
||||
|
||||
const key = props.column.key;
|
||||
|
||||
if (!local.rowHeight.has(props.row)) {
|
||||
local.rowHeight.set(props.row, {});
|
||||
}
|
||||
const rh = local.rowHeight.get(props.row);
|
||||
if (rh && tbl.el) {
|
||||
rh[props.column.key] = tbl.el.querySelector(".field");
|
||||
}
|
||||
return (
|
||||
<PassProp
|
||||
idx={props.rowIdx}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
import { createId } from "@paralleldrive/cuid2";
|
||||
import { createItem, parseGenField } from "lib/gen/utils";
|
||||
import { set } from "lib/utils/set";
|
||||
import get from "lodash.get";
|
||||
import { generateSelect } from "../../md/gen/md-select";
|
||||
import { newField } from "./fields";
|
||||
import { get_rel_many } from "./get_rel_many";
|
||||
import { on_load } from "./on_load";
|
||||
import { genFormOnInit } from "./gen-form/on-init";
|
||||
import { genFormOnLoad } from "./gen-form/on-load";
|
||||
import { genFormOnSubmit } from "./gen-form/on-submit";
|
||||
import { genFormOnInit } from "./gen-form/on-init";
|
||||
import { genFormSubmit } from "./gen-form/submit";
|
||||
import { get_rel_many } from "./get_rel_many";
|
||||
import { walkGenForm } from "./walker";
|
||||
|
||||
export const generateForm = async (
|
||||
|
|
@ -43,12 +41,23 @@ export const generateForm = async (
|
|||
}
|
||||
let is_md = !!_is_md;
|
||||
if (typeof _is_md === "undefined") {
|
||||
if (
|
||||
item.edit.parent?.item.edit.parent?.item.component?.id ===
|
||||
"cb52075a-14ab-455a-9847-6f1d929a2a73"
|
||||
) {
|
||||
is_md = true;
|
||||
let cur = item.edit.parent as any;
|
||||
while (cur) {
|
||||
if (cur) {
|
||||
if (cur.item.component?.id === "cb52075a-14ab-455a-9847-6f1d929a2a73") {
|
||||
is_md = true;
|
||||
break;
|
||||
}
|
||||
if (cur.item.edit?.parent) {
|
||||
cur = cur.item.edit.parent;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log(is_md);
|
||||
}
|
||||
|
||||
if (pk) {
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@ export const walkGenForm = (
|
|||
) => {
|
||||
const fields = {} as Record<string, PrasiItem>;
|
||||
|
||||
for (const item of new_childs[0].childs) {
|
||||
const name = item.component?.props?.name;
|
||||
console.log(name);
|
||||
if (Array.isArray(new_childs) && new_childs[0] && new_childs[0].childs) {
|
||||
for (const item of new_childs[0].childs) {
|
||||
const name = item.component?.props?.name;
|
||||
console.log(name);
|
||||
}
|
||||
}
|
||||
// for (const item of existing_childs) {
|
||||
// walk(item);
|
||||
|
|
|
|||
|
|
@ -635,8 +635,8 @@ export const TableList: FC<TableListProp> = ({
|
|||
},
|
||||
},
|
||||
]}
|
||||
rows={genRows(200)}
|
||||
/>
|
||||
rows={genRows(200)}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<DataGrid
|
||||
|
|
|
|||
Loading…
Reference in New Issue