openaire-library/claims/linking/selected/selectedResults.component.ts

37 lines
898 B
TypeScript

import {Component, Input} from '@angular/core';
import {ClaimEntity} from '../../claim-utils/claimHelper.class';
@Component({
selector: 'claim-selected-results',
templateUrl: 'selectedResults.component.html'
})
export class ClaimSelectedResultsComponent {
@Input() results: ClaimEntity[];
@Input() sectionTitle: string = "Research Results";
@Input() localStoragePrefix: string = "";
@Input() enableRemove:boolean = true;
ngOnInit() {
}
remove(item: any) {
const index: number = this.results.indexOf(item);
if (index > -1) {
this.results.splice(index, 1);
if (this.results != null) {
localStorage.setItem(this.localStoragePrefix, JSON.stringify(this.results));
}
}
}
sliceString(mystr, size: number): string {
const sliced = String(mystr).substr(0, size);
return sliced + (String(mystr).length > size ? '...' : '');
}
}