Updates on numeric interval list filter.
This commit is contained in:
parent
f5d8d2c80a
commit
3438dab861
|
@ -135,6 +135,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
// Labels (used mainly on Aria Labels and Inputs)
|
||||
'label' => __( 'label', 'tainacan' ),
|
||||
'label_clean' => __( 'Clear', 'tainacan' ),
|
||||
'label_none' => __( 'None', 'tainacan' ),
|
||||
'label_clear_filters' => __( 'Clear filters', 'tainacan' ),
|
||||
'label_and' => __( 'and', 'tainacan' ),
|
||||
'label_selected' => __( 'Selected', 'tainacan' ),
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<template>
|
||||
<div>
|
||||
<b-select
|
||||
expanded
|
||||
:placeholder="$i18n.get('instruction_select_a_interval')"
|
||||
@input="changeInterval"
|
||||
v-model="selectedInterval">
|
||||
<option value="">
|
||||
{{ $i18n.get('label_clean') }}
|
||||
{{ $i18n.get('label_none') }}
|
||||
</option>
|
||||
<option
|
||||
v-for="(interval, index) in filterTypeOptions.intervals"
|
||||
|
@ -32,6 +33,11 @@
|
|||
mounted() {
|
||||
this.selectedValues();
|
||||
},
|
||||
watch: {
|
||||
'query.metaquery'() {
|
||||
this.selectedValues();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeInterval() {
|
||||
if (this.selectedInterval !== '') {
|
||||
|
@ -40,16 +46,16 @@
|
|||
this.emit();
|
||||
} else {
|
||||
this.$emit('input', {
|
||||
filter: 'range',
|
||||
type: 'DECIMAL',
|
||||
compare: 'BETWEEN',
|
||||
metadatum_id: this.metadatumId,
|
||||
collection_id: this.collectionId,
|
||||
value: ''
|
||||
value: [null, null]
|
||||
});
|
||||
this.valueEnd = null;
|
||||
this.valueInit = null;
|
||||
this.$emit('sendValuesToTags', { label: '', value: null });
|
||||
}
|
||||
|
||||
},
|
||||
// emit the operation for listeners
|
||||
emit() {
|
||||
|
@ -64,7 +70,7 @@
|
|||
});
|
||||
|
||||
if (values[0] != undefined && values[1] != undefined) {
|
||||
let labelValue = this.filterTypeOptions.intervals[this.selectedInterval].label + (this.filterTypeOptions.showIntervalOnTag ? `(${values[0]}-${values[1]})` : '');
|
||||
let labelValue = this.filterTypeOptions.intervals[this.selectedInterval].label + (this.filterTypeOptions.showIntervalOnTag ? ` (${values[0]}-${values[1]})` : '');
|
||||
this.$emit('sendValuesToTags', { label: labelValue, value: values });
|
||||
}
|
||||
},
|
||||
|
@ -89,10 +95,12 @@
|
|||
anInterval => anInterval.from == this.valueInit && anInterval.to == this.valueEnd
|
||||
);
|
||||
|
||||
let labelValue = this.filterTypeOptions.intervals[this.selectedInterval].label + (this.filterTypeOptions.showIntervalOnTag ? `(${this.valueInit}-${this.valueEnd})` : '');
|
||||
let labelValue = this.filterTypeOptions.intervals[this.selectedInterval].label + (this.filterTypeOptions.showIntervalOnTag ? ` (${this.valueInit}-${this.valueEnd})` : '');
|
||||
this.$emit('sendValuesToTags', { label: labelValue, value: [ this.valueInit, this.valueEnd ] });
|
||||
} else {
|
||||
return false;
|
||||
this.valueInit = null;
|
||||
this.valueEnd = null;
|
||||
this.selectedInterval = '';
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ export const remove_fetch_only_meta = ( { commit }, metadatum ) => {
|
|||
|
||||
// Tax Queries from filters
|
||||
export const add_taxquery = ( { commit }, filter ) => {
|
||||
if (filter && (filter.terms == undefined || filter.terms == null || filter.terms == '' || filter.terms.length == 0 )) {
|
||||
if (filter && (filter.terms === undefined || filter.terms === null || filter.terms === '' || filter.terms.length === 0 )) {
|
||||
commit('removeTaxQuery', filter );
|
||||
} else {
|
||||
commit('addTaxQuery', filter );
|
||||
|
@ -146,12 +146,15 @@ export const setAdminViewMode = ({ commit }, adminViewMode ) => {
|
|||
|
||||
// Remove filter tag
|
||||
export const addFilterTag = ( { commit }, filterTag ) => {
|
||||
commit('addFilterTag', filterTag );
|
||||
if (filterTag && (filterTag.value === undefined || filterTag.value === null || filterTag.value === '' || filterTag.value.length === 0 ))
|
||||
commit('removeFilterTag', filterTag);
|
||||
else
|
||||
commit('addFilterTag', filterTag);
|
||||
};
|
||||
|
||||
// Remove filter tag
|
||||
export const removeFilterTag = ( { commit }, filterTag ) => {
|
||||
commit('removeFilterTag', filterTag );
|
||||
commit('removeFilterTag', filterTag);
|
||||
};
|
||||
|
||||
// Remove filter tag
|
||||
|
|
|
@ -94,7 +94,7 @@ export const removeMetaQuery = ( state, filter ) => {
|
|||
state.postquery.metaquery = ( ! state.postquery.metaquery ) ? [] : state.postquery.metaquery;
|
||||
|
||||
let index = state.postquery.metaquery.findIndex( item => item.key == filter.metadatum_id);
|
||||
|
||||
|
||||
if (index >= 0) {
|
||||
if (!filter.isMultiValue && Array.isArray(state.postquery.metaquery[index].value) && state.postquery.metaquery[index].value.length > 1) {
|
||||
let otherIndex = state.postquery.metaquery[index].value.findIndex(item => item == filter.value);
|
||||
|
|
Loading…
Reference in New Issue