From e21a3d60e3ea28ed26611b07af141936f02faba6 Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Mon, 20 May 2024 16:36:53 +0100 Subject: [PATCH] fix: Fix Switch Page From Link to Page - MEED-6882 - Meeds-io/meeds#2019 (#71) Prior to this change, when szwitching a page from a link into a page to create using a page template, the page layout isn't displayed properly. This is due to the fact that the passed nodeId isn't of type id, in addition to the fact that the created page reference isn't updated when cloning the navigation. --- .../io/meeds/layout/service/NavigationLayoutService.java | 2 ++ .../components/site-navigation/NodeItemMenu.vue | 8 +++++++- .../site-navigation/SiteNavigationElementDrawer.vue | 8 +++++++- .../site-navigation/SiteNavigationNodeDrawer.vue | 2 +- .../vue-app/layout-editor/components/LayoutEditor.vue | 2 +- .../vue-app/layout-editor/components/content/Content.vue | 5 +++-- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/layout-service/src/main/java/io/meeds/layout/service/NavigationLayoutService.java b/layout-service/src/main/java/io/meeds/layout/service/NavigationLayoutService.java index 2d099da3d..80bf52e5c 100644 --- a/layout-service/src/main/java/io/meeds/layout/service/NavigationLayoutService.java +++ b/layout-service/src/main/java/io/meeds/layout/service/NavigationLayoutService.java @@ -150,6 +150,8 @@ public NodeData createDraftNode(Long nodeId, String username) throws ObjectNotFo getNodeLabels(nodeId, username).getLabels()), username); } else { + NodeState state = clonedNode.getState().builder().pageRef(clonedPageKey).build(); + navigationService.updateNode(Long.parseLong(clonedNode.getId()), state); return navigationService.getNodeById(Long.parseLong(clonedNode.getId())); } } diff --git a/layout-webapp/src/main/webapp/vue-app/common-layout-components/components/site-navigation/NodeItemMenu.vue b/layout-webapp/src/main/webapp/vue-app/common-layout-components/components/site-navigation/NodeItemMenu.vue index fa55990b1..c9fd15872 100644 --- a/layout-webapp/src/main/webapp/vue-app/common-layout-components/components/site-navigation/NodeItemMenu.vue +++ b/layout-webapp/src/main/webapp/vue-app/common-layout-components/components/site-navigation/NodeItemMenu.vue @@ -35,7 +35,7 @@ { const pageRef = createdPage?.key?.ref || `${createdPage?.key.site.typeName}::${createdPage?.key.site.name}::${createdPage?.pageContext?.key.name}`; this.$root.$emit('save-node-with-page', { diff --git a/layout-webapp/src/main/webapp/vue-app/common-layout-components/components/site-navigation/SiteNavigationNodeDrawer.vue b/layout-webapp/src/main/webapp/vue-app/common-layout-components/components/site-navigation/SiteNavigationNodeDrawer.vue index 819c64a70..5e1083245 100644 --- a/layout-webapp/src/main/webapp/vue-app/common-layout-components/components/site-navigation/SiteNavigationNodeDrawer.vue +++ b/layout-webapp/src/main/webapp/vue-app/common-layout-components/components/site-navigation/SiteNavigationNodeDrawer.vue @@ -410,7 +410,7 @@ export default { this.loading = true; this.$navigationLayoutService.updateNode(this.navigationNode.id, this.nodeLabel, pageRef, this.visible, this.isScheduled, startScheduleDate, endScheduleDate, nodeLabels?.labels, pageData?.nodeTarget || this.navigationNode.target, this.nodeIcon) .then(() => { - this.openTargetPage(pageData); + this.openTargetPage(pageData, this.navigationNode.id); this.$root.$emit('refresh-navigation-nodes'); this.$root.$emit('close-add-element-drawer'); this.close(); diff --git a/layout-webapp/src/main/webapp/vue-app/layout-editor/components/LayoutEditor.vue b/layout-webapp/src/main/webapp/vue-app/layout-editor/components/LayoutEditor.vue index 209b0c08d..8e12dab05 100644 --- a/layout-webapp/src/main/webapp/vue-app/layout-editor/components/LayoutEditor.vue +++ b/layout-webapp/src/main/webapp/vue-app/layout-editor/components/LayoutEditor.vue @@ -56,7 +56,7 @@ export default { return this.getQueryParam('pageId') || this.pageKey?.ref || (this.pageKey && `${this.pageKey.site.typeName}::${this.pageKey.site.name}::${this.pageKey.name}`); }, nodeId() { - return this.getQueryParam('nodeId'); + return this.getQueryParam('nodeId') || (this.pageTemplateId && eXo.env.portal.selectedNodeId); }, draftNodeId() { return this.draftNode?.id; diff --git a/layout-webapp/src/main/webapp/vue-app/layout-editor/components/content/Content.vue b/layout-webapp/src/main/webapp/vue-app/layout-editor/components/content/Content.vue index cc34d4fb2..fa50c14f7 100644 --- a/layout-webapp/src/main/webapp/vue-app/layout-editor/components/content/Content.vue +++ b/layout-webapp/src/main/webapp/vue-app/layout-editor/components/content/Content.vue @@ -152,8 +152,8 @@ export default { }, setLayout(layout) { this.initContainer(layout); - this.isCompatible = this.$layoutUtils.parseSections(layout); - if (!this.isCompatible) { + const isCompatible = this.$layoutUtils.parseSections(layout); + if (!isCompatible) { const applications = this.$layoutUtils.getApplications(layout); layout.children = []; const parentContainer = this.$layoutUtils.newParentContainer(layout); @@ -162,6 +162,7 @@ export default { if (applications?.length && applications?.length > 1) { this.$layoutUtils.newSection(parentContainer, 1, 1, 2, this.$layoutUtils.flexTemplate); } + this.isCompatible = !applications?.length; this.modified = true; } if (this.layoutToEdit) {