mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 17:08:34 +00:00
fixes: components with default children
This commit is contained in:
parent
26873b0366
commit
2d95fd7458
3 changed files with 17 additions and 11 deletions
|
|
@ -956,15 +956,6 @@ const EditorComponent = (props) => {
|
|||
appDefinitionChanged(updatedAppDefinition, { skipAutoSave: true, componentDefinitionChanged: true, ...props });
|
||||
}
|
||||
}
|
||||
|
||||
// Other actions can be performed here if needed, like autoSave, ymap, etc.
|
||||
// computeComponentState(updatedAppDefinition.pages[currentPageId]?.components);
|
||||
// autoSave();
|
||||
// props.ymap?.set('appDef', {
|
||||
// newDefinition: updatedAppDefinition,
|
||||
// editingVersionId: props.editingVersion?.id,
|
||||
// });
|
||||
// }
|
||||
};
|
||||
|
||||
const removeComponent = (componentId) => {
|
||||
|
|
|
|||
|
|
@ -186,8 +186,11 @@ export const SubContainer = ({
|
|||
);
|
||||
|
||||
_.set(childrenBoxes, newComponent.id, {
|
||||
component: newComponent.component,
|
||||
parent: parentComponent.component === 'Tabs' ? parentId + '-' + tab : parentId,
|
||||
component: {
|
||||
...newComponent.component,
|
||||
parent: parentComponent.component === 'Tabs' ? parentId + '-' + tab : parentId,
|
||||
},
|
||||
|
||||
layouts: {
|
||||
[currentLayout]: {
|
||||
...layout,
|
||||
|
|
|
|||
|
|
@ -205,12 +205,24 @@ const computeComponentDiff = (appDiff, currentPageId, opts) => {
|
|||
const currentPageComponents = appDiff?.pages[currentPageId]?.components;
|
||||
|
||||
updateDiff = _.toPairs(currentPageComponents ?? []).reduce((result, [id, component]) => {
|
||||
if (_.keys(component).length === 1 && component.withDefaultChildren !== undefined) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const componentMeta = componentTypes.find((comp) => comp.component === component.component.component);
|
||||
|
||||
const metaDiff = diff(componentMeta, component.component);
|
||||
|
||||
result[id] = _.defaultsDeep(metaDiff, defaultComponent);
|
||||
|
||||
if (metaDiff.definition && !_.isEmpty(metaDiff.definition)) {
|
||||
const metaAttributes = _.keys(metaDiff.definition);
|
||||
|
||||
metaAttributes.forEach((attribute) => {
|
||||
result[id][attribute] = metaDiff.definition[attribute];
|
||||
});
|
||||
}
|
||||
|
||||
result[id].type = componentMeta.component;
|
||||
result[id].parent = component.component.parent ?? null;
|
||||
result[id].layouts = appDiff.pages[currentPageId].components[id].layouts;
|
||||
|
|
|
|||
Loading…
Reference in a new issue