[Library | Trunk]: Add onchanges function on search filter

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59113 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2020-07-14 12:41:09 +00:00
parent d6135ec6b8
commit 1c71fcfe8c
1 changed files with 20 additions and 4 deletions

View File

@ -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){