add AND filter functionality

pull/22/head
Florian Hartwich 2017-12-27 12:50:22 +01:00
parent 2daefe0e6c
commit a18bedbc48
1 changed files with 10 additions and 2 deletions

View File

@ -96,8 +96,16 @@ export class StatisticHighScoreComponent {
} }
private filterPlayerAttribute(attribute) { private filterPlayerAttribute(attribute) {
const query = this.searchTerm.value.toLowerCase(); const query = this.searchTerm.value.toLowerCase().split('&');
return this.playersStored[attribute].filter(p => p.name.toLowerCase().includes(query))
return this.playersStored[attribute].filter(player => {
for (let i = 0; i < query.length; i++) {
if (player.name.toLowerCase().includes(query[i].trim())) {
return true;
}
}
return false;
})
} }
} }