Skip to content

Commit

Permalink
fix: Fix duplicating Site Template - Meeds-io/MIPs#175
Browse files Browse the repository at this point in the history
Prior to this change, when duplicating a site template, the form is displayed as it's about a new Site Template. This change will display the form as it was an edition of an existing Site template for better UX consistency.
  • Loading branch information
boubaker authored and exo-swf committed Feb 6, 2025
1 parent 5d08bdb commit 4cf6827
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
v-model="siteTemplate.icon"
class="text-header mt-4" />
<site-template-layout
v-if="isNew"
v-if="isNewNoDuplication"
ref="siteTemplateLayout"
:site-template="siteTemplate"
class="mt-4" />
Expand Down Expand Up @@ -137,6 +137,9 @@ export default {
disabled() {
return !this.title?.length;
},
isNewNoDuplication() {
return this.isNew && !this.sourceSiteId;
},
},
watch: {
description() {
Expand Down Expand Up @@ -184,8 +187,8 @@ export default {
siteTemplate = await this.$siteTemplateService.saveAsSiteTemplate(this.siteTemplate, this.sourceSiteId);
} else {
siteTemplate = await this.$siteTemplateService.createSiteTemplate(this.siteTemplate);
this.siteTemplate.id = siteTemplate.id;
}
this.siteTemplate.id = siteTemplate.id;
} else {
siteTemplate = await this.$siteTemplateService.updateSiteTemplate(this.siteTemplate);
}
Expand All @@ -196,7 +199,7 @@ export default {

await this.$translationService.saveTranslations('siteTemplate', siteTemplate.id, 'title', this.titleTranslations);
await this.$translationService.saveTranslations('siteTemplate', siteTemplate.id, 'description', this.descriptionTranslations);
if (this.isNew) {
if (this.isNewNoDuplication) {
await this.$refs?.siteTemplateLayout?.save();
this.$root.$emit('alert-message', this.$t('layout.siteTemplateCreatedSuccessfully'), 'success');
this.$root.$emit('site-template-created', siteTemplate);
Expand Down

0 comments on commit 4cf6827

Please sign in to comment.