diff --git a/searchPages/searchUtils/searchFilter.component.ts b/searchPages/searchUtils/searchFilter.component.ts index 7adcb170..5e1f1e41 100644 --- a/searchPages/searchUtils/searchFilter.component.ts +++ b/searchPages/searchUtils/searchFilter.component.ts @@ -1,4 +1,14 @@ -import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core'; +import { + Component, + Input, + Output, + EventEmitter, + ViewChild, + ElementRef, + OnInit, + OnChanges, + SimpleChanges +} from '@angular/core'; import { Filter, Value} from './searchHelperClasses.class'; @Component({ @@ -6,7 +16,7 @@ import { Filter, Value} from './searchHelperClasses.class'; templateUrl: 'searchFilter.component.html' }) -export class SearchFilterComponent { +export class SearchFilterComponent implements OnInit, OnChanges{ @Input() filter:Filter; @Input() showResultCount:boolean = true; @@ -32,8 +42,14 @@ export class SearchFilterComponent { ngOnInit() { this.filter.values = this.filter.values.filter(value => !value.name.toLowerCase().includes('unknown') && !value.name.toLowerCase().includes('not available')); } - - public _formatTitle(title,length){ + + ngOnChanges(changes: SimpleChanges) { + if(changes.filter) { + this.filter.values = this.filter.values.filter(value => !value.name.toLowerCase().includes('unknown') && !value.name.toLowerCase().includes('not available')); + } + } + + public _formatTitle(title,length){ return (((title+" ("+length+")").length >this._maxCharacters)?(title.substring(0,(this._maxCharacters - (" ("+length+")").length - ('...').length))+"..."):title+" ("+(length>95?"100":length)+")") } public _formatName(value){