Fixed bug where search does not update when filter is set
authorYrjan A. F. Fraschetti <yrjanaff@1x-193-157-241-240.uio.no>
Sun, 6 Dec 2015 12:42:07 +0000 (13:42 +0100)
committerYrjan A. F. Fraschetti <yrjanaff@1x-193-157-241-240.uio.no>
Sun, 6 Dec 2015 12:42:07 +0000 (13:42 +0100)
src/components/search/search.html
src/components/search/search.ts

index 57c19eb..c425196 100644 (file)
@@ -14,8 +14,7 @@
                     name="livesearch"
                     id="livesearch"
                     placeholder="Search"
-                    value=""
-                    (change)="checkOrgunits()"/>
+                    value="" (keydown)="searchKeydown()"/>
 
 
             <!--<button class="exitsearch" id="exitsearch" (click)="emptyByClick()">
index dc5d2a3..07fc1b2 100644 (file)
@@ -26,6 +26,7 @@ export class Search {
     searchBar: any;
     filterset: boolean = false;
     emptySearch: any;
+    dropdown: any;
     slide: any;
 
 
@@ -40,6 +41,7 @@ export class Search {
         this.searchBar = document.getElementById("livesearch");
         this.orglist = document.getElementById("orglist");
         this.a = document.getElementById("testunit");
+        this.dropdown = document.getElementById("dropdown-menu");
     }
 
     getMoreInfo(orgunit) {
@@ -51,7 +53,7 @@ export class Search {
 
     toggle() {
         this.visible = !this.visible;
-        if(this.visible){
+        if(!this.visible){
             this.ownershipSelector.selectedIndex = 0;
             this.typeSelector.selectedIndex = 0;
             this.locationSelector.selectedIndex = 0;
@@ -65,11 +67,17 @@ export class Search {
 
     }
 
-
     emptyByClick(){
         return this.emptySearch = document.getElementById("divresult").style.visibility = "hidden";
     }
 
+    searchKeydown(){
+        if(this.filterset){
+            this.filterset = false;
+            this.setFilter();
+        }
+    }
+
 
     getUnitGroupSets(){
         this.http.get(dhisAPI + "/api/organisationUnitGroupSets")
@@ -136,7 +144,6 @@ export class Search {
             if(this.filterset) {
                 this.filterset = false;
             }
-
         }
         return !this.orgunits.length;
     }