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

View File

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

View File

@ -63,6 +63,9 @@ export const formInit = (fm: FMLocal, props: FMProps) => {
} else { } else {
fm.data = res; fm.data = res;
} }
if (!fm.data) {
fm.data = {};
}
if (isEditor) { if (isEditor) {
const item_id = props.item.id; 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"] = data["body"];
result.body.content.childs = []; result.body.content.childs = [];
console.log(fields);
for (const item of fields.filter((e) => !e.is_pk)) { for (const item of fields.filter((e) => !e.is_pk)) {
result.body.content.childs.push(await newField(item)); result.body.content.childs.push(await newField(item));
} }

View File

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