RC
This commit is contained in:
@@ -5,18 +5,19 @@ export default Component.extend({
|
||||
tagName: 'th',
|
||||
classNames: ['filter', 'filter-pablo-number-range'],
|
||||
classNameBindings: ['has_active_filter_value:active-filter'],
|
||||
placeholder: '-/-',
|
||||
placeholder: '[ ... ]',
|
||||
display_addition: '',
|
||||
apply_filters: function apply_filters() { },
|
||||
eager_filter: true,
|
||||
has_active_filter_value: Ember.computed.or('lower_bound', 'upper_bound'),
|
||||
lower_bound_candidate: '1',
|
||||
upper_bound_candidate: '2',
|
||||
filter_text: Ember.computed('{lower_bound,upper_bound,display_addition}', function () {
|
||||
var gteq, lteq, range;
|
||||
gteq = this.get('lower_bound') || '-';
|
||||
lteq = this.get('upper_bound') || '-';
|
||||
range = gteq + " / " + lteq;
|
||||
upper_bound_candidate: '3',
|
||||
filter_text: Ember.computed('{lower_bound,upper_bound,display_addition,inclusive}', function () {
|
||||
var lower_limit, upper_limit, range, isInclusive;
|
||||
isInclusive = this.get('inclusive');
|
||||
lower_limit = this.get('lower_bound') || '-';
|
||||
upper_limit = this.get('upper_bound') || '-';
|
||||
range = isInclusive ? `[${lower_limit}, ${upper_limit}]` : `(${lower_limit}, ${upper_limit})`;
|
||||
if (this.get('display_addition')) {
|
||||
range += " " + this.get('display_addition');
|
||||
}
|
||||
@@ -25,23 +26,38 @@ 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"));
|
||||
this.set('lower_bound_candidate', '1');
|
||||
return this.set('upper_bound_candidate', '2');
|
||||
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`));
|
||||
},
|
||||
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++
|
||||
}
|
||||
|
||||
this.set(`lower_bound_candidate`, lbc);
|
||||
this.set(`upper_bound_candidate`, hbc);
|
||||
},
|
||||
set_filter: function set_filter(key, value) {
|
||||
this.set('error', '');
|
||||
let lbc = this.get('lower_bound_candidate');
|
||||
let hbc = this.get('upper_bound_candidate')
|
||||
let hbc = this.get('upper_bound_candidate');
|
||||
|
||||
if (hbc < lbc) {
|
||||
this.set('error', `lower limit (${lbc}) cannot be greater \nthan the upper limit (${hbc}).`);
|
||||
this.set('error', `lower limit (${lbc}) cannot be greater than the upper limit (${hbc}).`);
|
||||
console.log(this.error);
|
||||
} else {
|
||||
this.set('lower_bound', parseInt(this.get('lower_bound_candidate')) || '');
|
||||
this.set('upper_bound', parseInt(this.get('upper_bound_candidate')) || '');
|
||||
this.set('lower_bound', lbc || '');
|
||||
this.set('upper_bound', hbc || '');
|
||||
this.$('.dropdown').dropdown('hide');
|
||||
if (this.get('eager_filter')) {
|
||||
return this.get('apply_filters')(this);
|
||||
@@ -50,10 +66,11 @@ export default Component.extend({
|
||||
},
|
||||
clear_filters: function clear_filters() {
|
||||
this.set('lower_bound', '');
|
||||
this.set('inclusive', true);
|
||||
this.set('error', '');
|
||||
this.set('upper_bound', '');
|
||||
this.set('lower_bound_candidate', '1');
|
||||
this.set('upper_bound_candidate', '2');
|
||||
this.set('upper_bound_candidate', '3');
|
||||
if (this.get('eager_filter')) {
|
||||
return this.get('apply_filters')(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user