1
|
import {Component, Input} from '@angular/core';
|
2
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
3
|
|
4
|
@Component({
|
5
|
selector: 'relatedTo',
|
6
|
template: `
|
7
|
<div class="uk-margin-bottom">
|
8
|
<div class="uk-text-small">
|
9
|
<div class="uk-text-muted">
|
10
|
Communities:
|
11
|
</div>
|
12
|
<div class="uk-margin-small-left" *ngFor="let item of contexts.slice(0, showNum); let i=index">
|
13
|
<span *ngIf="!item['inline']">
|
14
|
<span>{{item['labelContext']}}</span>
|
15
|
<span *ngIf="item['labelCategory']"><span uk-icon="icon: arrow-right"></span>{{item['labelCategory']}}</span>
|
16
|
<span *ngIf="item['labelConcept']">: {{item['labelConcept']}}</span>
|
17
|
</span>
|
18
|
<mark *ngIf="item['inline']">
|
19
|
<span>{{item['labelContext']}}</span>
|
20
|
<span *ngIf="item['labelCategory']"><span
|
21
|
uk-icon="icon: arrow-right"></span>{{item['labelCategory']}}</span>
|
22
|
<span *ngIf="item['labelConcept']">: {{item['labelConcept']}}</span>
|
23
|
</mark>
|
24
|
</div>
|
25
|
</div>
|
26
|
<div *ngIf="showNum > threshold" class="uk-text-right">
|
27
|
<a (click)="showNum = threshold; scroll()">
|
28
|
View less
|
29
|
</a>
|
30
|
</div>
|
31
|
<div *ngIf="showNum == threshold && contexts && contexts.length > threshold" class="uk-text-right">
|
32
|
<a (click)="showNum = contexts.length;">
|
33
|
View more
|
34
|
</a>
|
35
|
</div>
|
36
|
</div>
|
37
|
`
|
38
|
})
|
39
|
|
40
|
export class RelatedToComponent {
|
41
|
@Input() contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean }[];
|
42
|
|
43
|
public threshold: number = 5;
|
44
|
public showNum: number = 5;
|
45
|
|
46
|
constructor() {
|
47
|
}
|
48
|
|
49
|
ngOnInit() {
|
50
|
}
|
51
|
|
52
|
public scroll() {
|
53
|
HelperFunctions.scroll();
|
54
|
}
|
55
|
}
|