From a09c5b8d0e1554523f408f181468ca3ecb925069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Stawujak?= Date: Wed, 12 Dec 2018 01:43:01 +0100 Subject: [PATCH] SKE-38 attempt filter list competitions --- .../4.2.1/angular/src/app/app.module.ts | 4 +++- .../competitions-list.component.html | 2 +- .../angular/src/app/pipe/filter-classes.pipe.ts | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 SystemKonkursow/4.2.1/angular/src/app/pipe/filter-classes.pipe.ts diff --git a/SystemKonkursow/4.2.1/angular/src/app/app.module.ts b/SystemKonkursow/4.2.1/angular/src/app/app.module.ts index 23d23dc..0f6245e 100644 --- a/SystemKonkursow/4.2.1/angular/src/app/app.module.ts +++ b/SystemKonkursow/4.2.1/angular/src/app/app.module.ts @@ -34,6 +34,7 @@ import { SideBarFooterComponent } from '@app/layout/sidebar-footer.component'; import { RightSideBarComponent } from '@app/layout/right-sidebar.component'; import { CategoriesListComponent } from '@app/categories-list/categories-list.component'; import { CompetitionsListComponent } from '@app/competitions-list/competitions-list.component'; +import { FilterClassesPipe } from '@app/pipe/filter-classes.pipe'; @NgModule({ declarations: [ @@ -56,7 +57,8 @@ import { CompetitionsListComponent } from '@app/competitions-list/competitions-l SideBarFooterComponent, RightSideBarComponent, CategoriesListComponent, - CompetitionsListComponent + CompetitionsListComponent, + FilterClassesPipe ], imports: [ diff --git a/SystemKonkursow/4.2.1/angular/src/app/competitions-list/competitions-list.component.html b/SystemKonkursow/4.2.1/angular/src/app/competitions-list/competitions-list.component.html index 0c76733..27a09d1 100644 --- a/SystemKonkursow/4.2.1/angular/src/app/competitions-list/competitions-list.component.html +++ b/SystemKonkursow/4.2.1/angular/src/app/competitions-list/competitions-list.component.html @@ -1,5 +1,5 @@
-
+
{{ competition.name }}
\ No newline at end of file diff --git a/SystemKonkursow/4.2.1/angular/src/app/pipe/filter-classes.pipe.ts b/SystemKonkursow/4.2.1/angular/src/app/pipe/filter-classes.pipe.ts new file mode 100644 index 0000000..04f9dff --- /dev/null +++ b/SystemKonkursow/4.2.1/angular/src/app/pipe/filter-classes.pipe.ts @@ -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); + } +} \ No newline at end of file