Updates on Numeric Interval Filter.
This commit is contained in:
parent
c4fd86c70c
commit
f5d8d2c80a
|
@ -24,8 +24,8 @@
|
||||||
mixins: [ filterTypeMixin ],
|
mixins: [ filterTypeMixin ],
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
valueInit: 0,
|
valueInit: null,
|
||||||
valueEnd: 10,
|
valueEnd: null,
|
||||||
isValid: false,
|
isValid: false,
|
||||||
withError: false
|
withError: false
|
||||||
}
|
}
|
||||||
|
@ -33,15 +33,34 @@
|
||||||
mounted() {
|
mounted() {
|
||||||
this.selectedValues();
|
this.selectedValues();
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
'query.metaquery'() {
|
||||||
|
this.selectedValues();
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// only validate if the first value is higher than first
|
// only validate if the first value is higher than first
|
||||||
validate_values: _.debounce( function (){
|
validate_values: _.debounce( function () {
|
||||||
if ( parseFloat( this.valueInit ) > parseFloat( this.valueEnd )) {
|
if (this.valueInit == null || this.valueEnd == null)
|
||||||
//this.valueEnd = parseFloat( this.valueInit ) + 1;
|
return
|
||||||
//this.withError = true;
|
|
||||||
|
if (this.valueInit.constructor == Number)
|
||||||
|
this.valueInit = this.valueInit.valueOf();
|
||||||
|
|
||||||
|
if (this.valueEnd.constructor == Number)
|
||||||
|
this.valueEnd = this.valueEnd.valueOf();
|
||||||
|
|
||||||
|
this.valueInit = parseFloat(this.valueInit);
|
||||||
|
this.valueEnd = parseFloat(this.valueEnd);
|
||||||
|
|
||||||
|
if (isNaN(this.valueInit) || isNaN(this.valueEnd))
|
||||||
|
return
|
||||||
|
|
||||||
|
if (this.valueInit > this.valueEnd) {
|
||||||
|
this.error_message();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//this.withError = false;
|
//this.withError = false;
|
||||||
this.emit();
|
this.emit();
|
||||||
}, 600),
|
}, 600),
|
||||||
|
@ -79,15 +98,16 @@
|
||||||
if ( index >= 0 ){
|
if ( index >= 0 ){
|
||||||
let metaquery = this.query.metaquery[ index ];
|
let metaquery = this.query.metaquery[ index ];
|
||||||
if ( metaquery.value && metaquery.value.length > 1 ) {
|
if ( metaquery.value && metaquery.value.length > 1 ) {
|
||||||
this.valueInit = metaquery.value[0];
|
this.valueInit = new Number(metaquery.value[0]);
|
||||||
this.valueEnd = metaquery.value[1];
|
this.valueEnd = new Number(metaquery.value[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaquery.value[0] != undefined && metaquery.value[1] != undefined)
|
if (metaquery.value[0] != undefined && metaquery.value[1] != undefined)
|
||||||
this.$emit('sendValuesToTags', { label: this.valueInit + ' - ' + this.valueEnd, value: metaquery.values });
|
this.$emit('sendValuesToTags', { label: this.valueInit + ' - ' + this.valueEnd, value: metaquery.value });
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
this.valueInit = null;
|
||||||
|
this.valueEnd = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ export const set_advanced_query = ({commit}, advancedSearchQuery) => {
|
||||||
|
|
||||||
// Meta Queries from filters
|
// Meta Queries from filters
|
||||||
export const add_metaquery = ( { commit }, filter ) => {
|
export const add_metaquery = ( { commit }, filter ) => {
|
||||||
console.log(filter)
|
|
||||||
if (filter && (filter.value === undefined || filter.value === null || filter.value.length === 0 || filter.value === '')) {
|
if (filter && (filter.value === undefined || filter.value === null || filter.value.length === 0 || filter.value === '')) {
|
||||||
commit('removeMetaQuery', filter );
|
commit('removeMetaQuery', filter );
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue