1 |
49720
|
argiro.kok
|
import {Component, Input, ElementRef} from '@angular/core';
|
2 |
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
3 |
|
|
|
4 |
|
|
@Component({
|
5 |
|
|
selector: 'showAuthors',
|
6 |
|
|
template: `
|
7 |
|
|
<span *ngIf="authors != undefined">
|
8 |
|
|
<div *ngIf="showAll">
|
9 |
|
|
<a class="uk-text-muted" (click)="showAll = !showAll;">View less authors</a>
|
10 |
|
|
</div>
|
11 |
|
|
<span *ngFor="let author of authors.slice(0,30) let i=index">
|
12 |
|
|
<!--a [queryParams]="routerHelper.createQueryParams(['author','au'],[quote(author['name']),'and'])" routerLinkActive="router-link-active" [routerLink]="'/search/advanced/'+searchPage">
|
13 |
|
|
{{author['name']}}
|
14 |
|
|
</a-->
|
15 |
|
|
{{author}}
|
16 |
|
|
<span *ngIf=" i<29 && i<(authors.length-1)">;</span>
|
17 |
|
|
</span>
|
18 |
|
|
<span *ngIf="!showAll && authors.length > 30"> ... </span>
|
19 |
|
|
<span *ngIf="showAll">
|
20 |
|
|
<span *ngFor="let author of authors.slice(30) let i=index">
|
21 |
|
|
<!--a [queryParams]="routerHelper.createQueryParams(['author','au'],[quote(author['name']),'and'])" routerLinkActive="router-link-active" [routerLink]="'/search/advanced/'+searchPage">
|
22 |
|
|
{{author['name']}}
|
23 |
|
|
</a-->
|
24 |
|
|
{{author}}
|
25 |
|
|
<span *ngIf=" i<(authors.length-1)">;</span>
|
26 |
|
|
</span>
|
27 |
|
|
</span>
|
28 |
|
|
<span *ngIf="!showAll && authors.length > 30">
|
29 |
|
|
<a class="uk-text-muted" (click)="showAll = !showAll;">
|
30 |
|
|
view all {{authors.length}} authors
|
31 |
|
|
</a>
|
32 |
|
|
</span>
|
33 |
|
|
<span *ngIf="showAll">
|
34 |
|
|
<a class="uk-text-muted" (click)="showAll = !showAll; scroll()">View less authors</a>
|
35 |
|
|
</span>
|
36 |
|
|
</span>
|
37 |
|
|
|
38 |
|
|
`
|
39 |
|
|
|
40 |
|
|
})
|
41 |
|
|
|
42 |
|
|
export class ShowAuthorsComponent {
|
43 |
|
|
@Input() authors: { [key: string]: string }[];
|
44 |
|
|
@Input() searchPage:string ="publications"
|
45 |
|
|
|
46 |
|
|
public showAll: boolean = false;
|
47 |
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
48 |
|
|
|
49 |
|
|
constructor (private element: ElementRef) {
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
ngOnInit() {
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
public quote(params: string):string {
|
56 |
|
|
return '"'+params+'"';
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
public scroll() {
|
60 |
|
|
console.info("scroll into view");
|
61 |
|
|
if (typeof document !== 'undefined') {
|
62 |
|
|
this.element.nativeElement.scrollIntoView();
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
}
|