SKE-38 attempt filter list competitions

This commit is contained in:
Przemysław Stawujak 2018-12-12 01:43:01 +01:00
parent e1d9fa6ebc
commit a09c5b8d0e
3 changed files with 19 additions and 2 deletions

View File

@ -34,6 +34,7 @@ import { SideBarFooterComponent } from '@app/layout/sidebar-footer.component';
import { RightSideBarComponent } from '@app/layout/right-sidebar.component'; import { RightSideBarComponent } from '@app/layout/right-sidebar.component';
import { CategoriesListComponent } from '@app/categories-list/categories-list.component'; import { CategoriesListComponent } from '@app/categories-list/categories-list.component';
import { CompetitionsListComponent } from '@app/competitions-list/competitions-list.component'; import { CompetitionsListComponent } from '@app/competitions-list/competitions-list.component';
import { FilterClassesPipe } from '@app/pipe/filter-classes.pipe';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -56,7 +57,8 @@ import { CompetitionsListComponent } from '@app/competitions-list/competitions-l
SideBarFooterComponent, SideBarFooterComponent,
RightSideBarComponent, RightSideBarComponent,
CategoriesListComponent, CategoriesListComponent,
CompetitionsListComponent CompetitionsListComponent,
FilterClassesPipe
], ],
imports: [ imports: [

View File

@ -1,5 +1,5 @@
<div class="flex-container" id="competitions-list-area"> <div class="flex-container" id="competitions-list-area">
<div class="flex-item" *ngFor="let competition of competitionsList"> <div class="flex-item" *ngFor="let competition of (competitionsList | filterClasses : [2, 6])">
{{ competition.name }} {{ competition.name }}
</div> </div>
</div> </div>

View File

@ -0,0 +1,15 @@
import { Pipe, PipeTransform } from '@angular/core';
import { CompetitionDto } from '@shared/service-proxies/service-proxies';
@Pipe({ name: 'filterClasses' })
export class FilterClassesPipe implements PipeTransform {
transform(allCompetitions: CompetitionDto[], args?: any) {
console.log(args);
let minClass = args[0];
let maxClass = args[1];
return allCompetitions
.filter(competition => competition.minClass >= minClass && competition.maxClass <= maxClass);
}
}