]> git.uio.no Git - u/erikhf/frm.git/blob - src/components/search/search.ts
knapp som toommer search uten styling
[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         this.orgunits = [];
28         console.log("yolo");
29         this.newsearch.next(orgunit.id);
30     }
31
32     toggle() {
33         this.visible = !this.visible;
34     }
35
36
37     hideDiv(){
38         if(livesearch.value == "")
39             return true;
40
41     }
42
43
44
45     /*getFilterTypes(){
46         this.http.get(dhis + "/api/organisationUnitGroups/")
47             .map(res => res.json())
48             .map(res => res.organisationUnitGroups)
49             .subscribe(
50                 zone.bind(res => {
51                    for(var i = 0; i < res.length; i++){
52                        this.http.get(res[i].href)
53                         .map(result => result.json())
54                         .map(result => result.organisationUnitGroupSet)
55                         .subscribe(
56                             zone.bind(result => {
57                                 if(result.name == "Location Rural/Urban"){
58                                     this.facilityLocation.push(res[i].name);
59                                 }
60                                 else if(result.name == "Facility Type"){
61                                     this.facilityType.push(res[i].name);
62                                 }
63                                 else if(result.name == "")
64                             })
65                         )
66                    }
67
68                 })
69             )
70     }
71
72     setFilterTypes(){
73
74     }*/
75
76     setFilter(){
77         var text = livesearch.value;
78         livesearch.value = "";
79         console.log(text);
80         for(var i = 0; i < text.length; i++){
81             livesearch.value += text.charAt(i);
82         }
83     }
84
85 }
86
87