mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 01:42:42 +00:00
Expand filtering functionality
This commit is contained in:
@@ -141,9 +141,18 @@ const ListPage = createClass({
|
|||||||
|
|
||||||
getSortedBrews : function(brews){
|
getSortedBrews : function(brews){
|
||||||
const testString = _.deburr(this.state.filterString).toLowerCase();
|
const testString = _.deburr(this.state.filterString).toLowerCase();
|
||||||
|
|
||||||
|
const checkString = (stringToTest)=>{
|
||||||
|
return (_.deburr(stringToTest).toLowerCase().includes(testString));
|
||||||
|
};
|
||||||
|
|
||||||
brews = _.filter(brews, (brew)=>{
|
brews = _.filter(brews, (brew)=>{
|
||||||
return (_.deburr(brew.title).toLowerCase().includes(testString)) ||
|
const brewStrings = []
|
||||||
(_.deburr(brew.description).toLowerCase().includes(testString));
|
.concat(brew.title)
|
||||||
|
.concat(brew.description)
|
||||||
|
.concat(brew.tags);
|
||||||
|
|
||||||
|
return _.filter(brewStrings, (brewString)=>{return checkString(brewString);}).length > 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
return _.orderBy(brews, (brew)=>{ return this.sortBrewOrder(brew); }, this.state.sortDir);
|
return _.orderBy(brews, (brew)=>{ return this.sortBrewOrder(brew); }, this.state.sortDir);
|
||||||
|
|||||||
Reference in New Issue
Block a user