Uses include instead of multiple request for terms on taxonomy taginput.
This commit is contained in:
parent
044b808019
commit
6249886f29
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
import { tainacan as axios, all } from '../../../js/axios/axios';
|
import { tainacan as axios } from '../../../js/axios/axios';
|
||||||
import { filterTypeMixin, dynamicFilterTypeMixin } from '../filter-types-mixin';
|
import { filterTypeMixin, dynamicFilterTypeMixin } from '../filter-types-mixin';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -58,6 +58,9 @@
|
||||||
this.updateSelectedValues();
|
this.updateSelectedValues();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.updateSelectedValues();
|
||||||
|
},
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
results:'',
|
results:'',
|
||||||
|
@ -151,20 +154,19 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getTerms(metadata) {
|
getTerms(metadata) {
|
||||||
let promises = [];
|
|
||||||
for (let id of metadata.terms) {
|
let params = {
|
||||||
//getting a specific value from api, does not need be in facets api
|
'include': metadata.terms,
|
||||||
promises.push(
|
'order': 'asc'
|
||||||
axios.get('/taxonomy/' + this.taxonomyId + '/terms/' + id + '?order=asc' )
|
};
|
||||||
|
|
||||||
|
return axios.get('/taxonomy/' + this.taxonomyId + '/terms/?' + qs.stringify(params) )
|
||||||
.then( res => {
|
.then( res => {
|
||||||
this.selected.push({ label: res.data.name, value: res.data.id });
|
this.selected = res.data.map(term => { return { label: term.name, value: term.id } });
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.$console.log(error);
|
this.$console.log(error);
|
||||||
})
|
})
|
||||||
);
|
|
||||||
}
|
|
||||||
return all(promises);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue