</div>
</form>
+ <!-- Searchresult div -->
<div class="row">
<span [hidden]="hideDiv()">
<div class="divresult col-md-10" id="divresult" [hidden]="checkOrgunits()">
</div>
</span>
+ <!-- Filter selectors to be filled inn by getUnitGroupSets() -->
<div id="dropdowndiv" class="btn-group collapse col-md-2">
<ul id="dropdown-menu" role="menu" class="dropdown-menu meny">
<li>Facility</li>
searchBar: any;
filterset: boolean = false;
-
-
constructor(public http:Http) {
this.newsearch = new EventEmitter();
this.visible = true;
}
-
emptyByClick(){
this.orgunits = [];
return document.getElementById("myForm").reset();
}
+ //Gets all unit group sets (category groups) and the unit groups
getUnitGroupSets() {
+ //gets unit group sets and display in selector
this.http.get(dhisAPI + "/api/organisationUnitGroupSets")
.map(res => res.json())
.map(res => res.organisationUnitGroupSets)
this.setOptionHeader(this.locationSelector, res[2].name);
for (var i = 0; i < res.length; i++) {
+ //gets unit groups for each group set and display in selector
this.http.get(res[i].href)
.map(result => result.json())
.subscribe(
)
}
+ //Add group set "header" to selector
setOptionHeader(selector, value) {
this.option = document.createElement("option");
- this.option.text = "All";
+ this.option.text = "Select " + value;
this.option.value = "";
selector.appendChild(this.option);
}
+ //Add group to selector
setOption(selector, value) {
this.option = document.createElement("option");
this.option.text = value;
selector.appendChild(this.option);
}
+ //Checks the status of orgunits-array and if filter is set
checkOrgunits() {
if (this.ownershipSelector.value == "" && this.typeSelector.value == "" && this.locationSelector.value == "") {
this.filteredOrgunits = [];
}
}
-
+ //Filtering the orgunits-array by checking what filter is active
setFilter() {
this.filteredOrgunits = [];
this.filterset = true;