From fd4eee8d5629a7599914abb2354420aa497311f4 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 11 Dec 2020 22:50:00 +0100 Subject: [PATCH] Move Filterrow to extra component --- src/app/app.module.ts | 2 + src/app/components/table/table.component.html | 81 ++----------------- .../filter-row/filter-row.component.html | 63 +++++++++++++++ .../filter-row/filter-row.component.scss | 0 .../filter-row/filter-row.component.spec.ts | 25 ++++++ .../filter-row/filter-row.component.ts | 22 +++++ 6 files changed, 118 insertions(+), 75 deletions(-) create mode 100644 src/app/components/tableComponents/filter-row/filter-row.component.html create mode 100644 src/app/components/tableComponents/filter-row/filter-row.component.scss create mode 100644 src/app/components/tableComponents/filter-row/filter-row.component.spec.ts create mode 100644 src/app/components/tableComponents/filter-row/filter-row.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 62de6ae..5c273c0 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -86,6 +86,7 @@ import { EngagementsComponent } from './pages/tables/engagements/engagements.com import { BikeEventsComponent } from './pages/tables/bike-events/bike-events.component'; import { BikeEventTypesComponent } from './pages/tables/bike-event-types/bike-event-types.component'; import { WorkshopTypesComponent } from './pages/tables/workshop-types/workshop-types.component'; +import { FilterRowComponent } from './components/tableComponents/filter-row/filter-row.component'; @NgModule({ declarations: [ @@ -130,6 +131,7 @@ import { WorkshopTypesComponent } from './pages/tables/workshop-types/workshop-t BikeEventsComponent, BikeEventTypesComponent, WorkshopTypesComponent, + FilterRowComponent, ], imports: [ BrowserModule, diff --git a/src/app/components/table/table.component.html b/src/app/components/table/table.component.html index 20121d9..b7639a8 100644 --- a/src/app/components/table/table.component.html +++ b/src/app/components/table/table.component.html @@ -71,83 +71,14 @@ *ngFor="let column of columnInfo" [matColumnDef]="column.dataPath + '.filter'" [sticky]="isStickyColumn(column.dataPath)" - > - - - - - - - - - + > + - diff --git a/src/app/components/tableComponents/filter-row/filter-row.component.html b/src/app/components/tableComponents/filter-row/filter-row.component.html new file mode 100644 index 0000000..96b6194 --- /dev/null +++ b/src/app/components/tableComponents/filter-row/filter-row.component.html @@ -0,0 +1,63 @@ + + + + + + + + diff --git a/src/app/components/tableComponents/filter-row/filter-row.component.scss b/src/app/components/tableComponents/filter-row/filter-row.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/tableComponents/filter-row/filter-row.component.spec.ts b/src/app/components/tableComponents/filter-row/filter-row.component.spec.ts new file mode 100644 index 0000000..11b7cb4 --- /dev/null +++ b/src/app/components/tableComponents/filter-row/filter-row.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FilterRowComponent } from './filter-row.component'; + +describe('FilterRowComponent', () => { + let component: FilterRowComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FilterRowComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FilterRowComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/tableComponents/filter-row/filter-row.component.ts b/src/app/components/tableComponents/filter-row/filter-row.component.ts new file mode 100644 index 0000000..1a9e161 --- /dev/null +++ b/src/app/components/tableComponents/filter-row/filter-row.component.ts @@ -0,0 +1,22 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; + +@Component({ + selector: 'app-filter-row', + templateUrl: './filter-row.component.html', + styleUrls: ['./filter-row.component.scss'] +}) +export class FilterRowComponent { + + @Input() + column: any; + + @Input() + filter: any; + + @Output() filtersChange = new EventEmitter(); + + newFilterValue() { + this.filtersChange.emit(this.filter); + } + +}