This commit is contained in:
rizky 2024-04-14 08:28:08 -07:00
parent dff267ebdd
commit 532fa0b7b0
5 changed files with 20 additions and 18 deletions

View File

@ -15,11 +15,11 @@ type BreadcrumbProps = {
className?: string;
props?: any;
value?: BreadItem[];
item: any;
item?: any;
};
export const Breadcrumb: FC<BreadcrumbProps> = (_arg) => {
const { on_load } = _arg;
const { on_load, item } = _arg;
const local = useLocal({
list: _arg.value || ([] as BreadItem[]),
@ -35,8 +35,8 @@ export const Breadcrumb: FC<BreadcrumbProps> = (_arg) => {
if (local.status === "init") {
let should_load = true;
if (isEditor && breadcrumbData[_arg.item.id]) {
local.list = breadcrumbData[_arg.item.id];
if (isEditor && item && breadcrumbData[item.id]) {
local.list = breadcrumbData[item.id];
local.status = "ready";
should_load = false;
}
@ -44,7 +44,7 @@ export const Breadcrumb: FC<BreadcrumbProps> = (_arg) => {
if (should_load && typeof on_load === "function") {
const callback = (res: any) => {
local.list = res;
breadcrumbData[_arg.item.id] = res;
if (item) breadcrumbData[item.id] = res;
local.status = "ready";
};
const res = on_load();
@ -57,8 +57,10 @@ export const Breadcrumb: FC<BreadcrumbProps> = (_arg) => {
}
}
if (isEditor && local.status !== "ready" && breadcrumbData[_arg.item.id]) {
if (isEditor && local.status !== "ready") {
if (item && breadcrumbData[item.id]) {
local.list = breadcrumbData[_arg.item.id];
}
local.status = "ready";
}

View File

@ -124,15 +124,9 @@ export const Form: FC<FMProps> = (props) => {
`
)}
>
{fm.status !== "init" &&
fm.size.width > 0 &&
childs.map((child, idx) => {
return (
<PassProp fm={fm} key={idx}>
{child}
</PassProp>
);
})}
{fm.status !== "init" && fm.size.width > 0 && (
<PassProp fm={fm}>{body}</PassProp>
)}
<button type="submit" className="c-hidden"></button>
</div>
</form>

View File

@ -63,6 +63,9 @@ export const formInit = (fm: FMLocal, props: FMProps) => {
} else {
fm.data = res;
}
if (!fm.data) {
fm.data = {};
}
if (isEditor) {
const item_id = props.item.id;

View File

@ -60,6 +60,7 @@ export const gen_form = async (modify: (data: any) => void, data: any) => {
result["body"] = data["body"];
result.body.content.childs = [];
console.log(fields);
for (const item of fields.filter((e) => !e.is_pk)) {
result.body.content.childs.push(await newField(item));
}

View File

@ -8,8 +8,10 @@ export const parseGenField = (fields: PropOptRaw) => {
const result = [] as GFCol[];
for (const f of fields) {
if (typeof f === "string") {
try {
const field = JSON.parse(f);
result.push(field);
} catch (e) {}
} else {
const field = JSON.parse(f.value);
field.relation.fields = f.checked.map((e) => JSON.parse(e));