Fixes to select filter.

This commit is contained in:
Mateus Machado Luna 2019-04-02 13:27:54 -03:00
parent cf162001c4
commit 02214425c7
3 changed files with 16 additions and 23 deletions

View File

@ -76,6 +76,16 @@
}
},
mixins: [filter_type_mixin],
watch: {
selected(value) {
if (value) {
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: value
});
}
}
},
computed: {
selected() {
if ( this.query && this.query.metaquery && Array.isArray( this.query.metaquery ) ) {
@ -109,33 +119,13 @@
this.getOptionsValuesCancel = promise.source;
},
onSelect(value){
this.selected = value;
//this.selected = value;
this.$emit('input', {
filter: 'selectbox',
metadatum_id: this.metadatum,
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
value: ( value ) ? value : ''
});
if (value) {
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: value
});
}
},
selectedValues(){
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
return false;
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key === this.metadatum );
if ( index >= 0){
let metadata = this.query.metaquery[ index ];
this.selected = metadata.value;
} else {
return false;
}
},
cleanSearchFromTags(filterTag) {
if (filterTag.filterId == this.filter.id)

View File

@ -296,8 +296,10 @@
},
prepareOptionsForTaxonomy(items, skipSelected) {
this.taxonomy = items[0].taxonomy;
this.taxonomy_id = items[0].taxonomy_id;
if (items[0] != undefined) {
this.taxonomy = items[0].taxonomy;
this.taxonomy_id = items[0].taxonomy_id;
}
this.options = [];
this.options = items.slice(); // copy array.

View File

@ -102,6 +102,7 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
dispatch('search/setFacets', res.data.filters, { root: true } );
else
dispatch('search/setFacets', {}, { root: true } );
})
.catch((thrown) => {
if (axios.isCancel(thrown)) {