import {Component, Input, Output, EventEmitter} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import {ClaimResult} from '../claim-utils/claimEntities.class';
declare var UIkit:any;
@Component({
selector: 'claim-results',
template:`
0 " class="uk-list uk-list-divider">
-
Publisher: {{result.publisher}}
Journal: {{result.journal}} ({{result.date}})
0 " class="uk-article-meta">Authors: {{author}}{{(i < (result.authors.slice(0,10).length-1))?"; ":""}}{{(i == result.authors.slice(0,10).length-1 && result.authors.length > 10)?"...":""}}
0" class="uk-article-meta">Editors: {{author}}{{(i < (result.authors.slice(0,10).length-1))?"; ":""}}{{(i == result.authors.slice(0,10).length-1 && result.authors.length > 10)?"...":""}}
`,
})
export class ClaimResultsComponent {
@Input() results;
@Input() selectedResults;
@Input() localStoragePrefix:string = "";
private isSelected(id:string){
var found:boolean = false;
for (var _i = 0; _i < this.selectedResults.length; _i++) {
let item = this.selectedResults[_i];
if(item.id == id){
found=true;
}
}
return found;
}
add(item){
if(this.selectedResults.length > 150){
UIkit.notification({
message : 'Your basket exceeds the number of allowed results (150)',
status : 'warning',
timeout : 1500,
pos : 'top-center'
});
return;
}
var found:boolean = this.isSelected( item.id);
if (!found) {
this.selectedResults.push(item);
UIkit.notification({
message : 'A new research result added in your basket.',
status : 'primary',
timeout : 1500,
pos : 'top-center'
});
if(this.results != null){
localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.selectedResults));
}
}else{
UIkit.notification({
message : 'The research result is already in your basket.',
status : 'warning',
timeout : 1500,
pos : 'top-center'
});
}
}
}