Fixes (issue #42): Provide a way to remove filter applied on Numeric Range

This commit is contained in:
weryques 2018-05-14 15:05:41 -03:00
parent f5153000ab
commit de71284697
1 changed files with 33 additions and 17 deletions

View File

@ -28,6 +28,7 @@
:class="{'has-content': value_init !== undefined && value_init !== ''}"
size="is-small"
type="number"
step="any"
@input="validate_values()"
class="column"
v-model="value_init"/>
@ -35,23 +36,22 @@
:class="{'has-content': value_end !== undefined && value_end !== ''}"
size="is-small"
type="number"
step="any"
@input="validate_values()"
@focus="isTouched = true"
class="column"
v-model="value_end"/>
</div>
<ul
<div
class="selected-list-box"
v-if="isValid && !clear">
<li>
<b-tag
attached
closable
@close="clearSearch()">
{{ showSearch() }}
</b-tag>
</li>
</ul>
</div>
</div>
</template>
@ -134,8 +134,9 @@
} else {
if ( parseFloat( this.value_init ) > parseFloat( this.value_end )) {
this.value_end = parseFloat( this.value_init ) + 1;
//this.value_end = parseFloat( this.value_init ) + 1;
//this.error_message();
return;
}
}
this.emit( this );
@ -182,13 +183,15 @@
}
return this.date_init.toLocaleString().split(' ')[0] + ' - ' + this.date_end.toLocaleString().split(' ')[0];
} else {
return this.value_init + ' - ' +this.value_end;
}
// else {
// return this.value_init + ' - ' +this.value_end;
// }
},
clearSearch(){
this.clear = true;
this.$emit('input', {
filter: 'range',
compare: 'BETWEEN',
@ -201,15 +204,15 @@
this.date_init = null;
this.date_end = null;
this.isTouched = false;
} else {
this.value_end = null;
this.value_init = null;
} else {
// this.value_end = null;
// this.value_init = null;
this.isTouched = false;
}
}
},
// emit the operation for listeners
emit:( vm ) => {
emit: ( vm ) => {
let values = [];
let type = '';
@ -237,14 +240,27 @@
|| vm.value_init === '' || vm.value_end === ''){
values = [];
type = 'DECIMAL';
vm.isValid = false;
vm.clear = true;
//vm.isValid = false;
//vm.clear = true;
vm.clearSearch();
return;
} else {
values = [ vm.value_init, vm.value_end ];
type = 'DECIMAL';
vm.isValid = true;
vm.clear = false;
if(vm.value_init !== vm.value_end &&
vm.value_init % 1 !== 0 ||
vm.value_end % 1 !== 0) {
type = 'NUMERIC';
} else if(vm.value_init !== vm.value_end){
type = 'DECIMAL';
} else {
type = '';
}
//vm.isValid = true;
//vm.clear = false;
}
}