Task filter now searches checklists

This commit is contained in:
TheHollidayInn 2015-06-25 22:30:47 -05:00
parent 07541ea7e4
commit 8ba621795a
2 changed files with 16 additions and 0 deletions

View file

@ -51,5 +51,14 @@ describe('Task Ordering Filters', function() {
expect(filter('filterByTextAndNotes')(tasks, 'bar')).to.eql([tasks[1]]);
expect(filter('filterByTextAndNotes')(tasks, 'foo')).to.eql([tasks[0], tasks[1]]);
});
it('filters items by checklists', function () {
var tasks = [
{ text: 'foo' },
{ text: 'foo', notes: 'bar', checklist: [ {text: "checkListToFind"} ] }
];
expect(filter('filterByTextAndNotes')(tasks, 'checkListToFind')).to.eql([tasks[1]]);
});
});
});

View file

@ -22,6 +22,13 @@ angular.module('habitrpg')
for (var i = 0; i < input.length; i++) {
if (term.test(input[i].text) || term.test(input[i].notes)) {
result.push(input[i]);
}else if (input[i].checklist) {
var checkListLen = input[i].checklist.length;
for (var j = 0; j < checkListLen; j++) {
if ( term.test(input[i].checklist[j].text) ) {
result.push(input[i]);
}
}
}
}