Permalink
Browse files

fix(project): make operator options configurable

  • Loading branch information...
jeremyvergnas committed Mar 7, 2017
1 parent dc1f52c commit fdd16f7e016770c72ffb04763a21a312daa5aeda
Showing with 28 additions and 15 deletions.
  1. +9 −15 src/filter.js
  2. +19 −0 src/index.js
@@ -1,9 +1,11 @@
import {customElement, bindable, bindingMode} from 'aurelia-framework';
import {inject, customElement, bindable, bindingMode} from 'aurelia-framework';
import {resolvedView} from 'aurelia-view-manager';
import {CriteriaBuilder} from './criteriaBuilder';
import {Configuration} from 'aurelia-config';

@customElement('filter')
@resolvedView('spoonx/filter', 'filter')
@inject(Configuration.of('aurelia-filter'))
export class Filter extends CriteriaBuilder {
@bindable({defaultBindingMode: bindingMode.twoWay}) criteria = {};
@bindable columns = [];
@@ -26,20 +28,7 @@ export class Filter extends CriteriaBuilder {
key : 'operator',
type : 'select',
label : false,
options: [
{name: 'contains', value: 'contains'},
{name: 'equals', value: 'equals'},
{name: 'not equals', value: 'not'},
{name: 'in', value: 'in'},
{name: 'not in', value: '!'},
{name: 'begins with', value: 'startsWith'},
{name: 'ends with', value: 'endsWith'},
{name: 'between', value: 'between'},
{name: 'greater than', value: 'greaterThan'},
{name: 'less than', value: 'lessThan'},
{name: 'less or equal than', value: 'lessThanOrEqual'},
{name: 'greater or equal than', value: 'greaterThanOrEqual'}
]
options: []
};

valueElement = {
@@ -51,6 +40,11 @@ export class Filter extends CriteriaBuilder {
}
};

constructor(config) {
super();
this.operatorElement.options = config.operatorOptions;
}

attached() {
if (this.entity) {
this.getEntityFields();
@@ -9,3 +9,22 @@ export function configure(aurelia) {

aurelia.globalResources('./filter');
}

export const config = {
'aurelia-filter': {
operatorOptions : [
{name: 'equals', value: 'equals'},
{name: 'not equals', value: 'not'},
{name: 'in', value: 'in'},
{name: 'not in', value: '!'},
{name: 'contains', value: 'contains'},
{name: 'begins with', value: 'startsWith'},
{name: 'ends with', value: 'endsWith'},
{name: 'between', value: 'between'},
{name: 'greater than', value: 'greaterThan'},
{name: 'less than', value: 'lessThan'},
{name: 'less or equal than', value: 'lessThanOrEqual'},
{name: 'greater or equal than', value: 'greaterThanOrEqual'}
]
}
};

0 comments on commit fdd16f7

Please sign in to comment.