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

View File

@ -4,6 +4,7 @@ import {PlayerService} from "../../services/logs/player.service";
import {CampaignService} from "../../services/logs/campaign.service";
import {Fraction} from "../../utils/fraction.enum";
import {FormControl} from "@angular/forms";
import {Observable} from "rxjs/Observable";
@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() {
@ -89,8 +96,16 @@ export class StatisticHighScoreComponent {
}
private filterPlayerAttribute(attribute) {
const query = this.searchTerm.value.toLowerCase();
return this.playersStored[attribute].filter(p => p.name.toLowerCase().includes(query))
const query = this.searchTerm.value.toLowerCase().split('&');
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

@ -48,7 +48,7 @@ ngx-datatable {
}
:host /deep/ .ngx-datatable.scroll-vertical .datatable-body::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
border-radius: 10px;
}
@ -57,11 +57,9 @@ ngx-datatable {
background: #4b4b4b;
-webkit-box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5);
}
/* Table Scrollbar END */
.in-table-btn {
position: absolute;
margin-top: -5px;