1 import {Component,EventEmitter, View, CORE_DIRECTIVES} from 'angular2/angular2';
2 import {Http} from 'angular2/http';
3 import {LiveSearch} from "./livesearch";
6 selector: 'mou-search',
7 directives: [CORE_DIRECTIVES, LiveSearch],
9 templateUrl: './components/search/search.html',
10 styleUrls: ['./components/search/search.css']
13 orgunits: Array<any> = [];
14 loading: boolean = false;
15 facilityType: Array<any> = [];
16 facilityOwnership: Array<any> = [];
17 facilityLocation: Array<any> = [];
20 constructor(public http:Http) {
21 this.newsearch = new EventEmitter();
26 getMoreInfo(orgunit) {
29 this.newsearch.next(orgunit.id);
33 this.visible = !this.visible;
38 if(livesearch.value == "")
46 this.http.get(dhis + "/api/organisationUnitGroups/")
47 .map(res => res.json())
48 .map(res => res.organisationUnitGroups)
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)
57 if(result.name == "Location Rural/Urban"){
58 this.facilityLocation.push(res[i].name);
60 else if(result.name == "Facility Type"){
61 this.facilityType.push(res[i].name);
63 else if(result.name == "")
77 var text = livesearch.value;
78 livesearch.value = "";
80 for(var i = 0; i < text.length; i++){
81 livesearch.value += text.charAt(i);