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 ? '▽' : 'х' }}
</button>
</div>
</form>
- <!-- Searchresult div -->
+ <!-- Searchresult -->
<div class="row">
<span [hidden]="hideDiv()">
<div class="divresult col-md-10" id="divresult" [hidden]="checkOrgunits()">
<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>
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;
//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;