From fdc1b299faad0eded1d333e75995d8302de80be2 Mon Sep 17 00:00:00 2001 From: smuddyx Date: Fri, 24 Apr 2020 13:35:20 +0200 Subject: [PATCH] better binding for global song filter --- .../application-frame.module.ts | 4 ++- .../navigation/filter/filter.component.html | 2 +- .../navigation/filter/filter.component.ts | 10 ++++-- src/index.html | 32 +++---------------- 4 files changed, 15 insertions(+), 33 deletions(-) diff --git a/src/app/widget-modules/components/application-frame/application-frame.module.ts b/src/app/widget-modules/components/application-frame/application-frame.module.ts index 3e3e676..b379953 100644 --- a/src/app/widget-modules/components/application-frame/application-frame.module.ts +++ b/src/app/widget-modules/components/application-frame/application-frame.module.ts @@ -5,6 +5,7 @@ import {RouterModule} from '@angular/router'; import {FilterComponent} from './navigation/filter/filter.component'; import {FontAwesomeModule} from '@fortawesome/angular-fontawesome'; import {LinkComponent} from './navigation/link/link.component'; +import {FormsModule} from '@angular/forms'; @NgModule({ @@ -16,7 +17,8 @@ import {LinkComponent} from './navigation/link/link.component'; imports: [ CommonModule, RouterModule, - FontAwesomeModule + FontAwesomeModule, + FormsModule ], exports: [ NavigationComponent diff --git a/src/app/widget-modules/components/application-frame/navigation/filter/filter.component.html b/src/app/widget-modules/components/application-frame/navigation/filter/filter.component.html index 367b29e..dfbadb5 100644 --- a/src/app/widget-modules/components/application-frame/navigation/filter/filter.component.html +++ b/src/app/widget-modules/components/application-frame/navigation/filter/filter.component.html @@ -1 +1 @@ - + diff --git a/src/app/widget-modules/components/application-frame/navigation/filter/filter.component.ts b/src/app/widget-modules/components/application-frame/navigation/filter/filter.component.ts index 5adae26..523f8a3 100644 --- a/src/app/widget-modules/components/application-frame/navigation/filter/filter.component.ts +++ b/src/app/widget-modules/components/application-frame/navigation/filter/filter.component.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {Router} from '@angular/router'; +import {ActivatedRoute, Router} from '@angular/router'; @Component({ selector: 'app-filter', @@ -7,11 +7,15 @@ import {Router} from '@angular/router'; styleUrls: ['./filter.component.less'] }) export class FilterComponent { + public value: string; - constructor(private router: Router) { + constructor(private router: Router, activatedRoute: ActivatedRoute) { + activatedRoute.queryParams.subscribe(_ => { + if (_.q) this.value = _.q; + }) } - public async onInputChange(text: string): Promise { + public async valueChange(text: string): Promise { const route = text ? this.router.createUrlTree(['songs'], {queryParams: {q: text}}) : this.router.createUrlTree(['songs']); diff --git a/src/index.html b/src/index.html index 16edabf..d6ee632 100644 --- a/src/index.html +++ b/src/index.html @@ -91,38 +91,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + /> + id="gear-lg"/> @@ -159,7 +135,7 @@ + id="gear-sm"/>