inital version

This commit is contained in:
Pablo Bañales
2018-11-22 17:11:45 -03:00
parent 6458155d7c
commit 3c10e0537d
9 changed files with 4241 additions and 3162 deletions
@@ -0,0 +1,62 @@
import Ember from 'ember';
import Component from '@ember/component';
export default Component.extend({
tagName: 'th',
classNames: ['filter', 'filter-pablo-number-range'],
classNameBindings: ['has_active_filter_value:active-filter'],
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;
if (this.get('display_addition')) {
range += " " + this.get('display_addition');
}
return range;
}),
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');
},
actions: {
set_filter: function set_filter(key, value) {
this.set('error', '');
let lbc = this.get('lower_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}).`);
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.$('.dropdown').dropdown('hide');
if (this.get('eager_filter')) {
return this.get('apply_filters')(this);
}
}
},
clear_filters: function clear_filters() {
this.set('lower_bound', '');
this.set('error', '');
this.set('upper_bound', '');
this.set('lower_bound_candidate', '1');
this.set('upper_bound_candidate', '2');
if (this.get('eager_filter')) {
return this.get('apply_filters')(this);
}
}
}
});
+16 -11
View File
@@ -1,12 +1,17 @@
{{yield (hash
input = (component "table-filters/input" apply_filters=(action 'apply_filters') filters=filters)
date = (component "table-filters/date" apply_filters=(action 'apply_filters') filters=filters)
date-range = (component "table-filters/date-range" apply_filters=(action 'apply_filters') filters=filters)
number-range = (component "table-filters/number-range" apply_filters=(action 'apply_filters') filters=filters)
dropdown-select = (component "table-filters/dropdown-select" apply_filters=(action 'apply_filters') filters=filters)
dropdown-select-multiple = (component "table-filters/dropdown-select-multiple" apply_filters=(action 'apply_filters') filters=filters)
option-buttons = (component "table-filters/option-buttons" apply_filters=(action 'apply_filters') filters=filters)
boolean-checkboxes = (component "table-filters/boolean-checkboxes" apply_filters=(action 'apply_filters') filters=filters)
select-multiple = (component "table-filters/select-multiple" apply_filters=(action 'apply_filters') filters=filters)
actions = (component 'table-filters/actions' apply_filters=(action 'apply_filters') clear_filters=(action 'clear_filters') filter_calls=filter_calls)
)}}
input = (component "table-filters/input" apply_filters=(action 'apply_filters') filters=filters)
date = (component "table-filters/date" apply_filters=(action 'apply_filters') filters=filters)
date-range = (component "table-filters/date-range" apply_filters=(action 'apply_filters') filters=filters)
number-range = (component "table-filters/number-range" apply_filters=(action 'apply_filters') filters=filters)
pablo-number-range = (component "table-filters/pablo-number-range" apply_filters=(action 'apply_filters')
filters=filters)
dropdown-select = (component "table-filters/dropdown-select" apply_filters=(action 'apply_filters') filters=filters)
dropdown-select-multiple = (component "table-filters/dropdown-select-multiple" apply_filters=(action 'apply_filters')
filters=filters)
option-buttons = (component "table-filters/option-buttons" apply_filters=(action 'apply_filters') filters=filters)
boolean-checkboxes = (component "table-filters/boolean-checkboxes" apply_filters=(action 'apply_filters')
filters=filters)
select-multiple = (component "table-filters/select-multiple" apply_filters=(action 'apply_filters') filters=filters)
actions = (component 'table-filters/actions' apply_filters=(action 'apply_filters') clear_filters=(action
'clear_filters') filter_calls=filter_calls)
)}}
@@ -0,0 +1,22 @@
ui-dropdown class='left basic labeled top left pointing icon select-number' action='nothing'
= filter_text
.menu
.item class='number-range-container'
'Between
.ui.input.select-number= input type='number' value=lower_bound_candidate enter=(action 'set_filter')
' and
.ui.input.select-number= input type='number' value=upper_bound_candidate enter=(action 'set_filter')
if error
// .flash-message {{error}}
br
.ui.pointing.red.basic.label {{error}}
.divider
.options-container
button.ui.mini.secondary.button{action 'clear_filters'}= t 'Clear'
'
button.ui.mini.primary.button{action 'set_filter'}= t 'Apply'
= yield
if has_active_filter_value
i.close.icon.clear-target-date-filter{action 'clear_filters'}