Task filter now searches checklists
This commit is contained in:
@@ -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]]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user