inclusive: change operator instead of lower/upper limits
This commit is contained in:
@@ -26,26 +26,24 @@ export default Component.extend({
|
||||
init: function init() {
|
||||
this._super();
|
||||
this.set('error', '');
|
||||
Ember.defineProperty(this, 'lower_bound', Ember.computed.alias(`filters.${this.get('key')}_gteq`));
|
||||
Ember.defineProperty(this, 'upper_bound', Ember.computed.alias(`filters.${this.get('key')}_lteq`));
|
||||
const isInclusive = this.get('inclusive');
|
||||
Ember.defineProperty(this, 'lower_bound',
|
||||
Ember.computed.alias(`filters.${this.get('key')}${isInclusive ? '_gteq' : '_gt'}`));
|
||||
Ember.defineProperty(this, 'upper_bound',
|
||||
Ember.computed.alias(`filters.${this.get('key')}${isInclusive ? '_lteq' : '_lt'}`));
|
||||
},
|
||||
actions: {
|
||||
toggle_inclusive() {
|
||||
this.set('inclusive', !this.get('inclusive'));
|
||||
const isInclusive = this.get('inclusive');
|
||||
var lbc = this.get('lower_bound_candidate');
|
||||
var hbc = this.get('upper_bound_candidate');
|
||||
|
||||
if (!isInclusive) {
|
||||
lbc++;
|
||||
hbc--;
|
||||
} else {
|
||||
lbc--
|
||||
hbc++
|
||||
}
|
||||
Ember.defineProperty(this, 'lower_bound',
|
||||
Ember.computed.alias(`filters.${this.get('key')}${isInclusive ? '_gteq' : '_gt'}`));
|
||||
Ember.defineProperty(this, 'upper_bound',
|
||||
Ember.computed.alias(`filters.${this.get('key')}${isInclusive ? '_lteq' : '_lt'}`));
|
||||
|
||||
this.set(`lower_bound_candidate`, lbc);
|
||||
this.set(`upper_bound_candidate`, hbc);
|
||||
delete this.filters[`${this.get('key')}${isInclusive ? '_gt' : '_gteq'}`];
|
||||
delete this.filters[`${this.get('key')}${isInclusive ? '_lt' : '_lteq'}`];
|
||||
},
|
||||
set_filter: function set_filter(key, value) {
|
||||
this.set('error', '');
|
||||
@@ -53,7 +51,7 @@ export default Component.extend({
|
||||
let hbc = this.get('upper_bound_candidate');
|
||||
|
||||
if (hbc < lbc) {
|
||||
this.set('error', t('number.range.lower_larger_than_upper_error', {lower: lbc, upper: hbc}));
|
||||
this.set('error', t('number.range.lower_larger_than_upper_error', { lower: lbc, upper: hbc }));
|
||||
console.log(this.error);
|
||||
} else {
|
||||
this.set('lower_bound', lbc || '');
|
||||
@@ -65,9 +63,9 @@ export default Component.extend({
|
||||
}
|
||||
},
|
||||
clear_filters: function clear_filters() {
|
||||
this.set('lower_bound', '');
|
||||
this.set('inclusive', true);
|
||||
this.set('error', '');
|
||||
this.set('lower_bound', '');
|
||||
this.set('upper_bound', '');
|
||||
this.set('lower_bound_candidate', '1');
|
||||
this.set('upper_bound_candidate', '3');
|
||||
|
||||
Reference in New Issue
Block a user