aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/search/search.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/search/search.component.ts')
-rw-r--r--client/src/app/shared/search/search.component.ts21
1 files changed, 19 insertions, 2 deletions
diff --git a/client/src/app/shared/search/search.component.ts b/client/src/app/shared/search/search.component.ts
index c14c2d99c..ed1ce807a 100644
--- a/client/src/app/shared/search/search.component.ts
+++ b/client/src/app/shared/search/search.component.ts
@@ -1,9 +1,10 @@
1import { Component, EventEmitter, Output } from '@angular/core'; 1import { Component, EventEmitter, Output, OnInit } from '@angular/core';
2 2
3import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown'; 3import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown';
4 4
5import { Search } from './search.model'; 5import { Search } from './search.model';
6import { SearchField } from './search-field.type'; 6import { SearchField } from './search-field.type';
7import { SearchService } from './search.service'; // Temporary
7 8
8@Component({ 9@Component({
9 selector: 'my-search', 10 selector: 'my-search',
@@ -11,7 +12,7 @@ import { SearchField } from './search-field.type';
11 directives: [ DROPDOWN_DIRECTIVES ] 12 directives: [ DROPDOWN_DIRECTIVES ]
12}) 13})
13 14
14export class SearchComponent { 15export class SearchComponent implements OnInit {
15 @Output() search = new EventEmitter<Search>(); 16 @Output() search = new EventEmitter<Search>();
16 17
17 fieldChoices = { 18 fieldChoices = {
@@ -26,6 +27,21 @@ export class SearchComponent {
26 value: '' 27 value: ''
27 }; 28 };
28 29
30 constructor(private searchService: SearchService) {}
31
32 ngOnInit() {
33 this.searchService.searchChanged.subscribe(
34 newSearchCriterias => {
35 // Put a field by default
36 if (!newSearchCriterias.field) {
37 newSearchCriterias.field = 'name';
38 }
39
40 this.searchCriterias = newSearchCriterias;
41 }
42 );
43 }
44
29 get choiceKeys() { 45 get choiceKeys() {
30 return Object.keys(this.fieldChoices); 46 return Object.keys(this.fieldChoices);
31 } 47 }
@@ -35,6 +51,7 @@ export class SearchComponent {
35 $event.stopPropagation(); 51 $event.stopPropagation();
36 52
37 this.searchCriterias.field = choice; 53 this.searchCriterias.field = choice;
54 this.doSearch();
38 } 55 }
39 56
40 doSearch() { 57 doSearch() {