Skip to content

Commit

Permalink
Revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nummi committed Sep 22, 2019
1 parent 468bc61 commit 88e1972
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
34 changes: 15 additions & 19 deletions app/controllers/records.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,6 @@ export default Controller.extend({
).join(' ').toLowerCase();
},

passesFilter(record) {
if(!this.filterValue) {
return true;
}

return get(record, `filterValues.${this.filterValue}`);
},

passesSearch(record) {
if (isEmpty(this.searchValue)) {
return true;
}

const exp = `.*${escapeRegExp(this.searchValue.toLowerCase())}.*`;
return !!this.recordToString(record).match(new RegExp(exp));
},

/**
* The lists's schema containing info about the list's columns.
* This is usually a static object except in this case each model
Expand All @@ -62,8 +45,21 @@ export default Controller.extend({
}),

filteredRecords: computed('searchValue', 'model.@each.{columnValues,filterValues}', 'filterValue', function() {
return this.model.filter((record) => {
return this.passesFilter(record) && this.passesSearch(record);
let search = this.searchValue;
let filter = this.filterValue;

return this.model.filter(item => {
// check filters
if (filter && !get(item, `filterValues.${filter}`)) {
return false;
}

// check search
if (!isEmpty(search)) {
let searchString = this.recordToString(item);
return !!searchString.match(new RegExp(`.*${escapeRegExp(search.toLowerCase())}.*`));
}
return true;
});
}),

Expand Down
8 changes: 0 additions & 8 deletions app/helpers/is-empty.js

This file was deleted.

0 comments on commit 88e1972

Please sign in to comment.