]> git.uio.no Git - u/erikhf/frm.git/commitdiff
Merge branch 'master' of git.uio.no:u/erikhf/frm master
authorRoza Moustafa <roza.92m@hotmail.com>
Sun, 13 Dec 2015 10:16:40 +0000 (11:16 +0100)
committerRoza Moustafa <roza.92m@hotmail.com>
Sun, 13 Dec 2015 10:16:40 +0000 (11:16 +0100)
1  2 
src/components/search/search.html
src/components/search/search.ts

index 67694037877ce140ce9ac72d9defe01c3b17849e,3ca52b007ac4312f483305eb1c44820bbe332fd2..7a819f34ca2b29bf8225026542597c180aa9963b
                      onfocus="this.placeholder = ''"
                      value=""/>
  
-             <!--Show and empty filtermenu-->
-             <button type="button" class="filterbutton col-md-2" (click)="toggle()"
-                     data-toggle="collapse" data-target="#dropdown-menu">
+             <!--Show or hide, and empty filtermenu-->
+             <button type="button" class="filterbutton col-md-2" (click)="toggle()">
                  {{ visible ? '&xdtri;' : '&khcy;' }}
              </button>
          </div>
      </form>
  
-     <!-- Searchresult div -->
+     <!-- Searchresult -->
      <div class="row">
          <span [hidden]="hideDiv()">
              <div class="divresult col-md-10" id="divresult" [hidden]="checkOrgunits()">
@@@ -41,7 -40,7 +40,7 @@@
                          <a id="left-menu" href="#"><span class="glyphicon glyphicon-map-marker glyresult"></span>  {{orgunit.name}}</a>
                      </li>
                      <li *ng-if="filteredOrgunits.length == 0">
 -                        <p class="nomatch"><span class="glyphicon glyphicon-info-sign glyinfo"></span>  No matching results </p>
 +                        <p class="nomatch"><span class="glyphicon glyphicon-info-sign glyinfo"></span>   No matching results </p>
                      </li>
                  </ul>
              </div>
index 441e88390f7ce3d304bd2a65e8d39e7c02ddccac,80425c488abc3c3e8dcc6697dcccd45b02e79209..35054d57be240c19d71d3f3b65d5444eec47e115
@@@ -10,9 -10,9 +10,9 @@@ declare var zone: Zone
      selector: 'mou-search',
      directives: [CORE_DIRECTIVES, LiveSearch],
      events: ['newsearch'],
 -    templateUrl: './components/search/search.html',
 -    styleUrls: ['./components/search/search.css']
 +    templateUrl: './components/search/search.html'
  })
 +
  export class Search {
      orgunits: Array<any> = [];
      filteredOrgunits: Array<any> = [];
      getMoreInfo(orgunit) {
          this.orgunits = [];
          this.newsearch.next(orgunit.id);
+         if(!this.visible){
+             this.visible = !this.visible;
+             this.resetSelector();
+             document.getElementById("dropdown-menu").style.display = "none";
+         }
          return document.getElementById("searchform").reset();
      }
  
      //When filtermenu is open show x else show arraowdown
          this.visible = !this.visible;
          if (this.visible) {
              this.resetSelector();
+             document.getElementById("dropdown-menu").style.display = "none";
+         }
+         else{
+             document.getElementById("dropdown-menu").style.display = "block";
          }
      }
  
+     //Resets the filter values in selectors
      resetSelector(){
          this.ownershipSelector.selectedIndex = 0;
          this.typeSelector.selectedIndex = 0;
@@@ -60,9 -69,9 +69,9 @@@
  
      //Hide results when search bar input is erased
      hideDiv() {
-         if (this.searchBar.value == "")
+         if (this.searchBar.value == ""){
              return true;
+         }
      }
  
      //Click out results and empty the search bar
  
      //Checks the status of orgunits-array and if filter is set
      checkOrgunits() {
+         //If all selectors are empty
          if (this.ownershipSelector.value == "" && this.typeSelector.value == "" && this.locationSelector.value == "") {
+             //empty filteredOrgunits
              this.filteredOrgunits = [];
              for (var i = 0; i < this.orgunits.length; i++) {
+                 //push orgunits to filteredOrgunits
                  this.filteredOrgunits.push(this.orgunits[i]);
              }
          }
+         //If orgunits.length is more than zero and filterset is false, call setFilter()
          else if (!this.orgunits.length == false && !this.filterset) {
              this.setFilter();
          }
+         //If orgunits has no elements, empty filteredOrgunits
          else if (!this.orgunits.length) {
              this.filteredOrgunits = [];
+             //if filterset is true, set to false
              if (this.filterset) {
                  this.filterset = false;
              }
          }
+         //If filteredOrgunits has no elements, return false
          if(this.filteredOrgunits.length == 0){
              return false;
          }
+         //If filteredOrgunits has elements return true if orgunits has elements or false if orgunits has no elements
          else{
              return !this.orgunits.length;
          }
      setFilter() {
          this.filteredOrgunits = [];
          this.filterset = true;
+         //loop orgunits to get orgunit object
          for (var i = 0; i < this.orgunits.length; i++) {
              this.http.get(this.orgunits[i].href)
                  .map(res => res.json())
                  .subscribe(
                      zone.bind(orgunits => {
+                         //if no filter is selected, push all orgunit objects to filteredOrgunits
                          if (this.ownershipSelector.value == "" && this.typeSelector.value == "" && this.locationSelector.value == "") {
                              this.filteredOrgunits.push(orgunits);
                          }
+                         //if filter is set, sort
                          else {
                              var os = false;
                              var ls = false;
                                  if (this.locationSelector.value == "") {
                                      ls = true;
                                  }
+                                 //if all boolean values are true, add orgunit object to filteredOrgunits
                                  if (os == true && ts == true && ls == true) {
                                      this.filteredOrgunits.push(orgunits);
                                      os = false;