diff options
Diffstat (limited to 'client/src/app/shared/search')
-rw-r--r-- | client/src/app/shared/search/search.component.ts | 10 | ||||
-rw-r--r-- | client/src/app/shared/search/search.service.ts | 6 |
2 files changed, 9 insertions, 7 deletions
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 @@ | |||
1 | import { Component, EventEmitter, Output, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | 2 | ||
3 | import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown'; | 3 | import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown'; |
4 | 4 | ||
@@ -13,8 +13,6 @@ import { SearchService } from './search.service'; | |||
13 | }) | 13 | }) |
14 | 14 | ||
15 | export class SearchComponent implements OnInit { | 15 | export class SearchComponent implements OnInit { |
16 | @Output() search = new EventEmitter<Search>(); | ||
17 | |||
18 | fieldChoices = { | 16 | fieldChoices = { |
19 | name: 'Name', | 17 | name: 'Name', |
20 | author: 'Author', | 18 | author: 'Author', |
@@ -30,7 +28,9 @@ export class SearchComponent implements OnInit { | |||
30 | constructor(private searchService: SearchService) {} | 28 | constructor(private searchService: SearchService) {} |
31 | 29 | ||
32 | ngOnInit() { | 30 | ngOnInit() { |
33 | this.searchService.searchChanged.subscribe( | 31 | // Subscribe is the search changed |
32 | // Usually changed by videos list component | ||
33 | this.searchService.updateSearch.subscribe( | ||
34 | newSearchCriterias => { | 34 | newSearchCriterias => { |
35 | // Put a field by default | 35 | // Put a field by default |
36 | if (!newSearchCriterias.field) { | 36 | if (!newSearchCriterias.field) { |
@@ -58,7 +58,7 @@ export class SearchComponent implements OnInit { | |||
58 | } | 58 | } |
59 | 59 | ||
60 | doSearch() { | 60 | doSearch() { |
61 | this.search.emit(this.searchCriterias); | 61 | this.searchService.searchUpdated.next(this.searchCriterias); |
62 | } | 62 | } |
63 | 63 | ||
64 | getStringChoice(choiceKey: SearchField) { | 64 | 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'; | |||
7 | // Remove it when we'll be able to subscribe to router changes | 7 | // Remove it when we'll be able to subscribe to router changes |
8 | @Injectable() | 8 | @Injectable() |
9 | export class SearchService { | 9 | export class SearchService { |
10 | searchChanged: Subject<Search>; | 10 | searchUpdated: Subject<Search>; |
11 | updateSearch: Subject<Search>; | ||
11 | 12 | ||
12 | constructor() { | 13 | constructor() { |
13 | this.searchChanged = new Subject<Search>(); | 14 | this.updateSearch = new Subject<Search>(); |
15 | this.searchUpdated = new Subject<Search>(); | ||
14 | } | 16 | } |
15 | } | 17 | } |