wip gen form
This commit is contained in:
parent
9590e14ff8
commit
dcc7a39a37
|
|
@ -147,67 +147,71 @@ export const generateForm = async (
|
|||
walkGenForm(new_body, existing_childs as any);
|
||||
}
|
||||
|
||||
const current_body = propFromItem(item)?.body?.value as IItem;
|
||||
if (item.edit) {
|
||||
const current_body = propFromItem(item)?.body?.value as IItem;
|
||||
|
||||
if (current_body) {
|
||||
const mapping = mapCompItemTree(new_body, {
|
||||
shouldAdd({ item }) {
|
||||
if (item.component?.props?.sub_type?.value === "table-edit")
|
||||
return "add-skip-children";
|
||||
if (current_body) {
|
||||
const mapping = mapCompItemTree(new_body, {
|
||||
shouldAdd({ item }) {
|
||||
if (item.component?.props?.sub_type?.value === "table-edit")
|
||||
return "add-skip-children";
|
||||
|
||||
return "add";
|
||||
},
|
||||
});
|
||||
return "add";
|
||||
},
|
||||
});
|
||||
|
||||
reduceItemMapping(current_body, mapping, (old_item, new_item) => {
|
||||
const pold = propFromItem(old_item);
|
||||
const pnew = propFromItem(new_item);
|
||||
reduceItemMapping(current_body, mapping, (old_item, new_item) => {
|
||||
const pold = propFromItem(old_item);
|
||||
const pnew = propFromItem(new_item);
|
||||
|
||||
let result = old_item;
|
||||
if (
|
||||
result.component &&
|
||||
result.component?.id === "32550d01-42a3-4b15-a04a-2c2d5c3c8e67"
|
||||
) {
|
||||
if (pold.type.value !== pnew.type.value) {
|
||||
result = new_item;
|
||||
} else if (pold.sub_type.value !== pnew.sub_type.value) {
|
||||
result = new_item;
|
||||
let result = old_item;
|
||||
if (
|
||||
result.component &&
|
||||
result.component?.id === "32550d01-42a3-4b15-a04a-2c2d5c3c8e67"
|
||||
) {
|
||||
if (pold.type.value !== pnew.type.value) {
|
||||
result = new_item;
|
||||
} else if (pold.sub_type.value !== pnew.sub_type.value) {
|
||||
result = new_item;
|
||||
}
|
||||
|
||||
copyProps(old_item, new_item, [
|
||||
"placeholder",
|
||||
"label",
|
||||
"link__url",
|
||||
"ext__width",
|
||||
"opt__load_trigger",
|
||||
"ext__on_change",
|
||||
"ext__description",
|
||||
"ext__show_label",
|
||||
"ext__disabled",
|
||||
"ext__prefix",
|
||||
"ext__suffix",
|
||||
]);
|
||||
}
|
||||
|
||||
copyProps(old_item, new_item, [
|
||||
"placeholder",
|
||||
"label",
|
||||
"link__url",
|
||||
"ext__width",
|
||||
"opt__load_trigger",
|
||||
"ext__on_change",
|
||||
"ext__description",
|
||||
"ext__show_label",
|
||||
"ext__disabled",
|
||||
"ext__prefix",
|
||||
"ext__suffix",
|
||||
]);
|
||||
return result;
|
||||
});
|
||||
|
||||
if (
|
||||
mapping["32550d01-42a3-4b15-a04a-2c2d5c3c8e67"] &&
|
||||
Object.keys(mapping["32550d01-42a3-4b15-a04a-2c2d5c3c8e67"]).length >
|
||||
0
|
||||
) {
|
||||
for (const val of Object.values(
|
||||
mapping["32550d01-42a3-4b15-a04a-2c2d5c3c8e67"]
|
||||
)) {
|
||||
current_body.childs?.[0]?.childs.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
if (
|
||||
mapping["32550d01-42a3-4b15-a04a-2c2d5c3c8e67"] &&
|
||||
Object.keys(mapping["32550d01-42a3-4b15-a04a-2c2d5c3c8e67"]).length > 0
|
||||
) {
|
||||
for (const val of Object.values(
|
||||
mapping["32550d01-42a3-4b15-a04a-2c2d5c3c8e67"]
|
||||
)) {
|
||||
current_body.childs?.[0]?.childs.push(val);
|
||||
if (current_body?.childs?.length > 0) {
|
||||
new_body = current_body;
|
||||
}
|
||||
}
|
||||
|
||||
if (current_body?.childs?.length > 0) {
|
||||
new_body = current_body;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(result);
|
||||
if (commit) {
|
||||
Object.keys(result).map((e) => {
|
||||
item.edit.setProp(e, result[e]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue