mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
fixes: tabs children are not rendered as the are not in their repsective parent container (#8036)
This commit is contained in:
parent
a2f80374b0
commit
601cb74f53
1 changed files with 31 additions and 4 deletions
|
|
@ -126,7 +126,7 @@ export class PageService {
|
|||
const clonedComponents = await Promise.all(
|
||||
pageComponents.map(async (component) => {
|
||||
const clonedComponent = { ...component, id: undefined, pageId: clonePageId };
|
||||
const newComponent = await manager.save(Component, clonedComponent);
|
||||
const newComponent = await manager.save(manager.create(Component, clonedComponent));
|
||||
|
||||
componentsIdMap[component.id] = newComponent.id;
|
||||
const componentLayouts = await manager.find(Layout, { componentId: component.id });
|
||||
|
|
@ -164,10 +164,37 @@ export class PageService {
|
|||
})
|
||||
);
|
||||
|
||||
const isChildOfTabsOrCalendar = (component, allComponents = [], componentParentId = undefined) => {
|
||||
if (componentParentId) {
|
||||
const parentId = component?.parent?.split('-').slice(0, -1).join('-');
|
||||
|
||||
const parentComponent = allComponents.find((comp) => comp.id === parentId);
|
||||
|
||||
if (parentComponent) {
|
||||
return parentComponent.type === 'Tabs' || parentComponent.type === 'Calendar';
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
for (const component of clonedComponents) {
|
||||
const componentId = componentsIdMap[component.parent];
|
||||
if (componentId) {
|
||||
await manager.update(Component, component.id, { parent: componentId });
|
||||
let parentId = component.parent ? component.parent : null;
|
||||
|
||||
const isParentTabOrCalendar = isChildOfTabsOrCalendar(component, pageComponents, parentId);
|
||||
|
||||
if (isParentTabOrCalendar) {
|
||||
const childTabId = component.parent.split('-')[component.parent.split('-').length - 1];
|
||||
const _parentId = component?.parent?.split('-').slice(0, -1).join('-');
|
||||
const mappedParentId = componentsIdMap[_parentId];
|
||||
|
||||
parentId = `${mappedParentId}-${childTabId}`;
|
||||
} else {
|
||||
parentId = componentsIdMap[parentId];
|
||||
}
|
||||
|
||||
if (parentId) {
|
||||
await manager.update(Component, component.id, { parent: parentId });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue