diff --git a/layout-webapp/src/main/webapp/vue-app/common-layout-components/js/PageTemplateService.js b/layout-webapp/src/main/webapp/vue-app/common-layout-components/js/PageTemplateService.js index 97ab4147f..a2fc2f7d5 100644 --- a/layout-webapp/src/main/webapp/vue-app/common-layout-components/js/PageTemplateService.js +++ b/layout-webapp/src/main/webapp/vue-app/common-layout-components/js/PageTemplateService.js @@ -43,7 +43,7 @@ export function getPageTemplate(id) { }); } -export function createPageTemplate(pageContent) { +export function createPageTemplate(pageContent, disabled) { return fetch('/layout/rest/pageTemplates', { credentials: 'include', method: 'POST', @@ -52,6 +52,7 @@ export function createPageTemplate(pageContent) { }, body: JSON.stringify({ content: pageContent, + disabled: disabled || false, }), }).then((resp) => { if (resp?.ok) { diff --git a/layout-webapp/src/main/webapp/vue-app/layout-editor/components/drawer/PageTemplateDrawer.vue b/layout-webapp/src/main/webapp/vue-app/layout-editor/components/drawer/PageTemplateDrawer.vue index a53500670..18df98b62 100644 --- a/layout-webapp/src/main/webapp/vue-app/layout-editor/components/drawer/PageTemplateDrawer.vue +++ b/layout-webapp/src/main/webapp/vue-app/layout-editor/components/drawer/PageTemplateDrawer.vue @@ -142,7 +142,7 @@ export default { }, methods: { open(pageTemplate, duplicate) { - this.templateId = pageTemplate.id || null; + this.templateId = pageTemplate.id || this.$root.pageTemplate?.id || null; this.pageLayoutContent = pageTemplate.content; this.duplicate = duplicate; this.$nextTick().then(() => this.$refs.drawer.open()); @@ -155,10 +155,15 @@ export default { const savePageRequest = (!this.duplicate && this.templateId) ? this.$pageTemplateService.getPageTemplate(this.templateId) - .then(pageTemplate => this.$pageTemplateService.updatePageTemplate({ - ...pageTemplate, - content: this.pageLayoutContent, - })) + .then(pageTemplate => { + const newTemplate = (this.$root.pageTemplate && !this.$root.pageTemplate.name); + const disabled = newTemplate ? false : pageTemplate.disabled; + return this.$pageTemplateService.updatePageTemplate({ + ...pageTemplate, + disabled, + content: this.pageLayoutContent, + }); + }) : this.$pageTemplateService.createPageTemplate(this.pageLayoutContent); return savePageRequest .then(pageTemplate => { @@ -170,6 +175,12 @@ export default { .then(() => this.$translationService.saveTranslations('pageTemplate', this.templateId, 'title', this.titleTranslations)) .then(() => this.$translationService.saveTranslations('pageTemplate', this.templateId, 'description', this.descriptionTranslations)) .then(() => this.$refs?.pagePreview?.save()) + .then(() => { + if (this.$root.pageTemplate) { + return this.$pageTemplateService.getPageTemplate(this.templateId) + .then(pageTemplate => this.$root.pageTemplate = pageTemplate); + } + }) .then(() => { this.$root.$emit('page-templates-saved'); this.close(); diff --git a/layout-webapp/src/main/webapp/vue-app/layout-editor/components/toolbar/actions/SaveTemplateButton.vue b/layout-webapp/src/main/webapp/vue-app/layout-editor/components/toolbar/actions/SaveTemplateButton.vue index 6df82f48c..9a9f4909b 100644 --- a/layout-webapp/src/main/webapp/vue-app/layout-editor/components/toolbar/actions/SaveTemplateButton.vue +++ b/layout-webapp/src/main/webapp/vue-app/layout-editor/components/toolbar/actions/SaveTemplateButton.vue @@ -20,7 +20,7 @@ -->