From bddab65ae58e347693b777cccf791201fdbcff4d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 18 Jul 2016 15:39:10 +0200 Subject: Client: save page params as well --- client/src/app/shared/search/search.component.ts | 10 +++++----- client/src/app/shared/search/search.service.ts | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/search/search.component.ts b/client/src/app/shared/search/search.component.ts index d33701bc8..e864fbc17 100644 --- a/client/src/app/shared/search/search.component.ts +++ b/client/src/app/shared/search/search.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Output, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown'; @@ -13,8 +13,6 @@ import { SearchService } from './search.service'; }) export class SearchComponent implements OnInit { - @Output() search = new EventEmitter(); - fieldChoices = { name: 'Name', author: 'Author', @@ -30,7 +28,9 @@ export class SearchComponent implements OnInit { constructor(private searchService: SearchService) {} ngOnInit() { - this.searchService.searchChanged.subscribe( + // Subscribe is the search changed + // Usually changed by videos list component + this.searchService.updateSearch.subscribe( newSearchCriterias => { // Put a field by default if (!newSearchCriterias.field) { @@ -58,7 +58,7 @@ export class SearchComponent implements OnInit { } doSearch() { - this.search.emit(this.searchCriterias); + this.searchService.searchUpdated.next(this.searchCriterias); } getStringChoice(choiceKey: SearchField) { diff --git a/client/src/app/shared/search/search.service.ts b/client/src/app/shared/search/search.service.ts index 0e41cdd34..c7993db3d 100644 --- a/client/src/app/shared/search/search.service.ts +++ b/client/src/app/shared/search/search.service.ts @@ -7,9 +7,11 @@ import { Search } from './search.model'; // Remove it when we'll be able to subscribe to router changes @Injectable() export class SearchService { - searchChanged: Subject; + searchUpdated: Subject; + updateSearch: Subject; constructor() { - this.searchChanged = new Subject(); + this.updateSearch = new Subject(); + this.searchUpdated = new Subject(); } } -- cgit v1.2.3