Adds hierarchy to TermItems based on it's parent.
This commit is contained in:
parent
dcf0c68489
commit
f3aeab8154
|
@ -127,7 +127,7 @@
|
|||
</form>
|
||||
|
||||
<b-loading
|
||||
:active.sync="isLoading"
|
||||
:active.sync="isLoadingCategory"
|
||||
:can-cancel="false"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -50,10 +50,9 @@
|
|||
<option
|
||||
id="tainacan-select-parent-term"
|
||||
v-for="(parentTerm, index) in parentTermsList"
|
||||
v-if="editForm.id != parentTerm.id"
|
||||
:key="index"
|
||||
:value="editForm.parent">
|
||||
{{ parentTerm.name == 0 ? $i18n.get('instruction_select_a_parent_term') : parentTerm.name }}
|
||||
:value="parentTerm.id">
|
||||
{{ parentTerm.name }}
|
||||
</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
@ -99,7 +98,13 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
parentTermsList() {
|
||||
return this.getTerms();
|
||||
let parentTerms = [];
|
||||
parentTerms.push({name: this.$i18n.get('label_no_parent_term'), id: 0});
|
||||
for (let term of this.getTerms()) {
|
||||
if (term.id != this.editForm.id)
|
||||
parentTerms.push({id: term.id, name: term.name});
|
||||
}
|
||||
return parentTerms;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -140,7 +145,6 @@ export default {
|
|||
.then(() => {
|
||||
this.editForm = {};
|
||||
this.closedByForm = true;
|
||||
this.$console.log("Tudo OK AQUI.");
|
||||
this.$emit('onEditionFinished');
|
||||
})
|
||||
.catch((error) => {
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
'not-sortable-item': term.id == 'new' || term.id == undefined || openedTermId != '' ,
|
||||
'not-focusable-item': openedTermId == term.id
|
||||
}"
|
||||
v-for="(term, index) in termsList"
|
||||
:style="{'margin-left': (term.depth * 20) + 'px'}"
|
||||
v-for="(term, index) in orderedTermsList"
|
||||
:key="index">
|
||||
<span
|
||||
class="term-name"
|
||||
|
@ -57,6 +58,9 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
<b-loading
|
||||
:active.sync="isLoadingTerms"
|
||||
:can-cancel="false"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -77,15 +81,18 @@ export default {
|
|||
}
|
||||
},
|
||||
props: {
|
||||
categoryId: Number
|
||||
categoryId: String
|
||||
},
|
||||
computed: {
|
||||
termsList() {
|
||||
//this.orderedTermsList = new Array();
|
||||
//this.buildOrderedTermsList(0, 0);
|
||||
return this.getTerms();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'termsList'() {
|
||||
this.generateOrderedTerms();
|
||||
}
|
||||
},
|
||||
components: {
|
||||
TermEditionForm
|
||||
},
|
||||
|
@ -117,7 +124,6 @@ export default {
|
|||
'deleteTerm'
|
||||
]),
|
||||
...mapGetters('category',[
|
||||
|
||||
'getTerms'
|
||||
]),
|
||||
addNewTerm() {
|
||||
|
@ -188,7 +194,7 @@ export default {
|
|||
|
||||
for (let term of this.termsList) {
|
||||
|
||||
if (term['parent'] != parentId ) {
|
||||
if (term.parent != parentId ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -198,6 +204,11 @@ export default {
|
|||
this.buildOrderedTermsList(term.id, termDepth + 1);
|
||||
}
|
||||
},
|
||||
generateOrderedTerms() {
|
||||
this.orderedTermsList = new Array();
|
||||
this.buildOrderedTermsList(0, 0);
|
||||
this.$console.log(this.orderedTermsList);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
|
@ -207,6 +218,7 @@ export default {
|
|||
.then(() => {
|
||||
// Fill this.form data with current data.
|
||||
this.isLoadingTerms = false;
|
||||
this.generateOrderedTerms();
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.log(error);
|
||||
|
|
|
@ -123,6 +123,7 @@ return [
|
|||
'label_parent_term' => __( 'Parent Term', 'tainacan' ),
|
||||
'label_new_term' => __( 'New Term', 'tainacan' ),
|
||||
'label_category_terms' => __( 'Category Terms', 'tainacan' ),
|
||||
'label_no_parent_term' => __( 'No parent term', 'tainacan' ),
|
||||
|
||||
// Instructions. More complex sentences to guide user and placeholders
|
||||
'instruction_dragndrop_fields_collection' => __( 'Drag and drop Fields here to Collection.', 'tainacan' ),
|
||||
|
|
|
@ -160,7 +160,6 @@ export const updateTerm = ({ commit }, { categoryId, termId, index, name, descri
|
|||
})
|
||||
.then( res => {
|
||||
let term = res.data;
|
||||
console.log(term);
|
||||
commit('setSingleTerm', term);
|
||||
resolve( term );
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue