import {Component, ViewEncapsulation, ComponentRef, ElementRef, Input, EventEmitter, Output} from '@angular/core'; import { Filter} from './searchHelperClasses.class'; @Component({ selector: 'modal-search-filter', template: ` `, encapsulation: ViewEncapsulation.None, }) /** * API to an open search filter window. */ export class SearchFilterModalComponent{ @Input() filter: Filter; @Input() showResultCount:boolean = true; @Output() modalChange = new EventEmitter(); public isOpen:boolean=false; constructor( public _elementRef: ElementRef){} filterModalChange(selected:boolean) { //console.info("Modal Changed"); this.filterChange(selected); this.modalChange.emit({ value: selected }); this.close(); } filterChange(selected:boolean){ if(selected){ this.filter.countSelectedValues++; // this.reorderFilterValues(); }else{ this.filter.countSelectedValues--; // this.reorderFilterValues(); } } getSelectedValues(filter):any{ var selected = []; if(filter.countSelectedValues >0){ for (var i=0; i < filter.values.length; i++){ if(filter.values[i].selected){ selected.push(filter.values[i]); } } } return selected; } getNotSelectedValues(filter):any{ var notSselected = []; if(filter.countSelectedValues >0){ for (var i=0; i < filter.values.length; i++){ if(!filter.values[i].selected){ notSselected.push(filter.values[i]); } } }else { notSselected = filter.values; } return notSselected; } open() { this.isOpen = true; } close() { this.isOpen = false; } }