ac7a7c11647bef8e26591020d8c85b139164d793
[u/erikhf/frm.git] / src / components / search / search.ts
1 import {Component,EventEmitter, View, CORE_DIRECTIVES} from 'angular2/angular2';
2 import {Http} from 'angular2/http';
3 import {LiveSearch} from "./livesearch";
4
5 @Component({
6     selector: 'mou-search',
7     directives: [CORE_DIRECTIVES, LiveSearch],
8     events: ['newsearch'],
9     templateUrl: './components/search/search.html',
10     styleUrls: ['./components/search/search.css']
11 })
12 export class Search {
13     orgunits: Array<any> = [];
14     loading: boolean = false;
15     facilityType: Array<any> = [];
16     facilityOwnership: Array<any> = [];
17     facilityLocation: Array<any> = [];
18
19
20     constructor(public http:Http) {
21         this.newsearch = new EventEmitter();
22         this.visible = true;
23
24     }
25
26     getMoreInfo(orgunit) {
27         console.log("yolo");
28         this.newsearch.next(orgunit.id);
29     }
30
31     //pil opp og ned
32
33     toggle() {
34         this.visible = !this.visible;
35     }
36
37     /*getFilterTypes(){
38         this.http.get(dhis + "/api/organisationUnitGroups/")
39             .map(res => res.json())
40             .map(res => res.organisationUnitGroups)
41             .subscribe(
42                 zone.bind(res => {
43                    for(var i = 0; i < res.length; i++){
44                        this.http.get(res[i].href)
45                         .map(result => result.json())
46                         .map(result => result.organisationUnitGroupSet)
47                         .subscribe(
48                             zone.bind(result => {
49                                 if(result.name == "Location Rural/Urban"){
50                                     this.facilityLocation.push(res[i].name);
51                                 }
52                                 else if(result.name == "Facility Type"){
53                                     this.facilityType.push(res[i].name);
54                                 }
55                                 else if(result.name == "")
56                             })
57                         )
58                    }
59
60                 })
61             )
62     }
63
64     setFilterTypes(){
65
66     }*/
67
68     setFilter(){
69         var text = livesearch.value;
70         livesearch.value = "";
71         console.log(text);
72         for(var i = 0; i < text.length; i++){
73             livesearch.value += text.charAt(i);
74         }
75     }
76
77 }
78
79