Skip to content

Commit 8ab555d

Browse files
authored
fix: update page template without losing content - MEED-9942 (#491)
Updating a page template was failing since the content was emptied when we update the template properties. The fix will update the content only when the operation is started from the layout editor, otherwise, when the template is updated from the template list, the content won't be changed.
1 parent 3a037e6 commit 8ab555d

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

layout-webapp/src/main/webapp/vue-app/common-layout/components/drawer/EditPageDrawer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export default {
218218
},
219219
created() {
220220
this.$root.$on('layout-page-properties-open', this.open);
221-
if (document.body.computedStyleMap().get('--allPagesLightGrey')) {
221+
if (document.body.computedStyleMap && document.body.computedStyleMap().get('--allPagesLightGrey')) {
222222
this.defaultBackgroundColor = document.body.computedStyleMap().get('--allPagesLightGrey')[0] || this.defaultBackgroundColor;
223223
}
224224
},

layout-webapp/src/main/webapp/vue-app/common-page-template/components/PageTemplateDrawer.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export default {
127127
duplicate: null,
128128
templateId: null,
129129
pageLayoutContent: null,
130+
editLayoutProperties: false,
130131
}),
131132
watch: {
132133
description() {
@@ -165,14 +166,17 @@ export default {
165166
this.$root.$off('layout-page-template-drawer-open', this.open);
166167
},
167168
methods: {
168-
async open(template, duplicate, generateIllustration) {
169+
async open(template, duplicate, generateIllustration, editLayoutProperties) {
169170
this.templateId = template.id || this.$root.pageTemplate?.id || null;
171+
this.editLayoutProperties = editLayoutProperties;
170172
this.pageLayoutContent = template.content;
171173
if (this.templateId) {
172174
const pageTemplate = await this.$pageTemplateService.getPageTemplate(this.templateId, true);
173175
this.description = pageTemplate?.description || '';
174176
this.duplicate = duplicate;
175-
this.pageLayoutContent = pageTemplate.content;
177+
if (this.duplicate) {
178+
this.pageLayoutContent = pageTemplate.content;
179+
}
176180
}
177181
if (generateIllustration) {
178182
const parentElement = document.querySelector('.layout-sections-parent .layout-page-body').parentElement;
@@ -208,7 +212,9 @@ export default {
208212
.then(pageTemplate => {
209213
const newTemplate = (this.$root.pageTemplate && !this.$root.pageTemplate.name);
210214
pageTemplate.disabled = newTemplate ? false : pageTemplate.disabled;
211-
pageTemplate.content = this.pageLayoutContent;
215+
if (!this.editLayoutProperties) {
216+
pageTemplate.content = this.pageLayoutContent;
217+
}
212218
return this.$pageTemplateService.updatePageTemplate(pageTemplate)
213219
.then(() => {
214220
if (newTemplate) {

layout-webapp/src/main/webapp/vue-app/page-template/components/list/PageTemplateItemMenu.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
</v-list-item>
6161
<v-list-item
6262
dense
63-
@click="$root.$emit('layout-page-template-drawer-open', pageTemplate)">
63+
@click="$root.$emit('layout-page-template-drawer-open', pageTemplate, false, false, true)">
6464
<v-card
6565
color="transparent"
6666
min-width="15"

0 commit comments

Comments
 (0)