Compare commits

...

3 Commits

Author SHA1 Message Date
Florian Hartwich 1e83e0c8a8 reformat code 2017-12-27 12:50:49 +01:00
Florian Hartwich a18bedbc48 add AND filter functionality 2017-12-27 12:50:22 +01:00
Florian Hartwich 2daefe0e6c add observable for filter 2017-12-27 12:21:41 +01:00
3 changed files with 21 additions and 7 deletions

View File

@ -3,7 +3,7 @@
<div class="input-group search-field"> <div class="input-group search-field">
<input id="search-tasks" <input id="search-tasks"
placeholder="Spielername" placeholder="Spielername (mehrere mit '&' trennen)"
type="text" #query class="form-control" type="text" #query class="form-control"
(keyup.enter)="filterPlayers()" (keyup.enter)="filterPlayers()"
[formControl]="searchTerm"> [formControl]="searchTerm">
@ -58,6 +58,7 @@
</ngx-datatable-column> </ngx-datatable-column>
<ngx-datatable-column [width]="valueColWidth" name="Tode" prop="death"></ngx-datatable-column> <ngx-datatable-column [width]="valueColWidth" name="Tode" prop="death"></ngx-datatable-column>
</ngx-datatable> </ngx-datatable>
<ngx-datatable <ngx-datatable
[rows]="players.respawn" [rows]="players.respawn"
[reorderable]="reorderable" [reorderable]="reorderable"

View File

@ -4,6 +4,7 @@ import {PlayerService} from "../../services/logs/player.service";
import {CampaignService} from "../../services/logs/campaign.service"; import {CampaignService} from "../../services/logs/campaign.service";
import {Fraction} from "../../utils/fraction.enum"; import {Fraction} from "../../utils/fraction.enum";
import {FormControl} from "@angular/forms"; import {FormControl} from "@angular/forms";
import {Observable} from "rxjs/Observable";
@Component({ @Component({
@ -61,6 +62,12 @@ export class StatisticHighScoreComponent {
}) })
} }
}); });
const searchTermStream = this.searchTerm.valueChanges.debounceTime(400);
Observable.merge(searchTermStream)
.distinctUntilChanged().map(query => this.filterPlayers())
.subscribe();
} }
initData() { initData() {
@ -89,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;
})
} }
} }

View File

@ -57,11 +57,9 @@ ngx-datatable {
background: #4b4b4b; background: #4b4b4b;
-webkit-box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5); -webkit-box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5);
} }
/* Table Scrollbar END */ /* Table Scrollbar END */
.in-table-btn { .in-table-btn {
position: absolute; position: absolute;
margin-top: -5px; margin-top: -5px;