diff --git a/src/classes/field-types/relationship/Relationship.vue b/src/classes/field-types/relationship/Relationship.vue index ba7e8b830..2108807d2 100644 --- a/src/classes/field-types/relationship/Relationship.vue +++ b/src/classes/field-types/relationship/Relationship.vue @@ -104,6 +104,7 @@ axios.get('/collection/'+collectionId+'/items?' + qs.stringify( metaquery )) .then( res => { this.loading = false; + this.options = []; let result = res.data; for (let item of result) { this.options.push({ label: item.title, value: item.id }) @@ -137,4 +138,4 @@ } } } - \ No newline at end of file + diff --git a/src/classes/filter-types/category/Checkbox.vue b/src/classes/filter-types/category/Checkbox.vue index 4c5c173e9..28745d3ac 100644 --- a/src/classes/filter-types/category/Checkbox.vue +++ b/src/classes/filter-types/category/Checkbox.vue @@ -32,6 +32,7 @@ collection: '', field: '', selected: [], + taxonomy: '' } }, props: { @@ -41,7 +42,10 @@ field_id: [Number], // not required, but overrides the filter field id if is set collection_id: [Number], // not required, but overrides the filter field id if is set filter_type: [String], // not required, but overrides the filter field type if is set - id: '' + id: '', + query: { + type: Object // concentrate all attributes field id and type + } }, watch: { selected: function(val){ @@ -53,6 +57,7 @@ getValuesCategory( taxonomy ){ return axios.get('/taxonomy/' + taxonomy + '/terms?hideempty=0' ).then( res => { for (let item of res.data) { + this.taxonomy = item.taxonomy; this.options.push(item); } }) @@ -71,6 +76,7 @@ promise.then( () => { this.isLoading = false; + this.selectedValues() }) .catch( error => { this.$console.log('error select', error ); @@ -96,16 +102,28 @@ } return result; }, - onSelect(){ - this.$console.log(this.selected); + selectedValues(){ + if ( !this.query || !this.query.taxquery || !Array.isArray( this.query.taxquery ) ) + return false; + let index = this.query.taxquery.findIndex(newField => newField.taxonomy === this.taxonomy ); + if ( index >= 0){ + let metadata = this.query.taxquery[ index ]; + this.selected = metadata.terms; + } else { + return false; + } + }, + onSelect(){ this.$emit('input', { - filter: 'term', + filter: 'selectbox', + taxonomy: this.taxonomy, + compare: 'IN', field_id: this.field, collection_id: this.collection, - value: this.selected + terms: this.selected }); } } } - \ No newline at end of file + diff --git a/src/classes/filter-types/category/Selectbox.vue b/src/classes/filter-types/category/Selectbox.vue index 144862ba6..de4ad9b61 100644 --- a/src/classes/filter-types/category/Selectbox.vue +++ b/src/classes/filter-types/category/Selectbox.vue @@ -6,6 +6,7 @@ v-model = "selected" @input = "onSelect()" expanded> +