}
)
}
-
- filterUnits(orgunits) {
- var filteredOrgunits: Array<any> = [];
- for (var i = 0; i < orgunits.length; i++) {
- this.http.get(orgunits[i].href)
- .map(res => res.json())
- .subscribe(
- zone.bind(orgunits => {
- if (ownershipSelector.value == "" && typeSelector.value == "" && locationSelector.value == "") {
- filteredOrgunits.push(orgunits);
- }
- else {
- var os = false;
- var ls = false;
- var ts = false;
- for (var group in orgunits.organisationUnitGroups) {
- if (ownershipSelector.value != "") {
- if (orgunits.organisationUnitGroups[group].name == ownershipSelector.value) {
- os = true;
- }
- }
- if (ownershipSelector.value == "") {
- os = true;
- }
- if (typeSelector.value != "") {
- if (orgunits.organisationUnitGroups[group].name == typeSelector.value) {
- ts = true;
- }
- }
- if (typeSelector.value == "") {
- ts = true;
- }
- if (locationSelector.value != "") {
- if (orgunits.organisationUnitGroups[group].name == locationSelector.value) {
- ls = true;
- }
- }
- if (locationSelector.value == "") {
- ls = true;
- }
- if (os == true && ts == true && ls == true) {
- filteredOrgunits.push(orgunits);
- os = false;
- ts = false;
- ls = false;
- }
- }
- }
- })
- )
- }
- return filteredOrgunits;
- }
}
name="livesearch"
id="livesearch"
placeholder="Search"
- value=""/>
+ value=""
+ (change)="checkOrgunits()"/>
<!--<button class="exitsearch" id="exitsearch" (click)="emptyByClick()">
✗ </button>-->
<button type="button" class="knapp col-md-2" (click)="toggle()"
- onclick="$('#ownershipSelector, #typeSelector, #locationSelector').prop('selectedIndex',0);"
data-toggle="collapse" data-target="#dropdown-menu">
{{ visible ? '▽' : '✗' }}
</button>
toggle() {
this.visible = !this.visible;
- //this.getUnitGroupSets();
+ if(this.visible){
+ this.ownershipSelector.selectedIndex = 0;
+ this.typeSelector.selectedIndex = 0;
+ this.locationSelector.selectedIndex = 0;
+ this.checkOrgunits();
+ }
}
hideDiv(){
}
checkOrgunits(){
- if(!this.orgunits.length == false && !this.filterset){
+ if (this.ownershipSelector.value == "" && this.typeSelector.value == "" && this.locationSelector.value == "") {
+ this.filteredOrgunits = [];
+ for(var i = 0; i < this.orgunits.length; i++) {
+ this.filteredOrgunits.push(this.orgunits[i]);
+ }
+ }
+ else if(!this.orgunits.length == false && !this.filterset){
this.setFilter();
- this.filterset = true;
}
else if(!this.orgunits.length){
this.filteredOrgunits = [];
setFilter(){
this.filteredOrgunits = [];
-
+ this.filterset = true;
for (var i = 0; i < this.orgunits.length; i++) {
this.http.get(this.orgunits[i].href)
.map(res => res.json())
}
else {
var os = false; var ls = false;var ts = false;
- for (var group in orgunits.organisationUnitGroups) {
+ for (var j = 0; j < orgunits.organisationUnitGroups.length; j++) {
if (this.ownershipSelector.value != "") {
- if (orgunits.organisationUnitGroups[group].name == this.ownershipSelector.value) {
+ if (orgunits.organisationUnitGroups[j].name == this.ownershipSelector.value) {
os = true;
}
}
os = true;
}
if (this.typeSelector.value != "") {
- if (orgunits.organisationUnitGroups[group].name == this.typeSelector.value) {
+ if (orgunits.organisationUnitGroups[j].name == this.typeSelector.value) {
ts = true;
}
}
ts = true;
}
if (this.locationSelector.value != "") {
- if (orgunits.organisationUnitGroups[group].name == this.locationSelector.value) {
+ if (orgunits.organisationUnitGroups[j].name == this.locationSelector.value) {
ls = true;
}
}
os = false;
ts = false;
ls = false;
-
}
}
}