From 3f707349423fb076700ee35ee1f42d86fba4755a Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Mon, 13 Aug 2018 11:30:25 -0300 Subject: [PATCH] Improvements on Terms list refactoring. --- .../components/edition/term-edition-form.vue | 5 +- .../components/lists/recursive-terms-list.vue | 44 +++++----- src/admin/components/lists/terms-list.vue | 80 ++++++++++++++----- src/js/store/modules/taxonomy/actions.js | 23 +++++- src/js/store/modules/taxonomy/mutations.js | 48 +++++++++-- 5 files changed, 145 insertions(+), 55 deletions(-) diff --git a/src/admin/components/edition/term-edition-form.vue b/src/admin/components/edition/term-edition-form.vue index 73e8c09a6..767337ad7 100644 --- a/src/admin/components/edition/term-edition-form.vue +++ b/src/admin/components/edition/term-edition-form.vue @@ -130,7 +130,7 @@ }, methods: { ...mapActions('taxonomy', [ - 'sendTerm', + 'sendChildTerm', 'updateChildTerm', ]), ...mapGetters('taxonomy', [ @@ -139,7 +139,7 @@ saveEdition(term) { if (term.id === 'new') { - this.sendTerm({ + this.sendChildTerm({ taxonomyId: this.taxonomyId, name: this.editForm.name, description: this.editForm.description, @@ -170,7 +170,6 @@ headerImageId: this.editForm.header_image_id, }) .then(() => { - this.editForm.saved = true; this.formErrors = {}; this.$emit('onEditionFinished', this.editForm); }) diff --git a/src/admin/components/lists/recursive-terms-list.vue b/src/admin/components/lists/recursive-terms-list.vue index 846aca36f..5e309bb38 100644 --- a/src/admin/components/lists/recursive-terms-list.vue +++ b/src/admin/components/lists/recursive-terms-list.vue @@ -20,14 +20,14 @@ class="label-details"> + v-if="term.id == 'new'"> {{ $i18n.get('info_not_saved') }} { - // this.$console.log(error); - // }); - // } - // } + // Updates parent IDs for orphans + if (this.term.children != undefined && this.term.children.length > 0) { + for (let orphanTerm of this.term.children) { + this.updateChildTerm({ + taxonomyId: this.taxonomyId, + termId: orphanTerm.id, + name: orphanTerm.name, + description: orphanTerm.description, + parent: this.term.parent, + oldParent: this.term.id + }) + .catch((error) => { + this.$console.log(error); + }); + } + } } }, } diff --git a/src/admin/components/lists/terms-list.vue b/src/admin/components/lists/terms-list.vue index fa5d15a69..01ba3bf5f 100644 --- a/src/admin/components/lists/terms-list.vue +++ b/src/admin/components/lists/terms-list.vue @@ -12,7 +12,7 @@