2017-12-19 13:53:46 +01:00
|
|
|
import {Component, Input, ElementRef} from '@angular/core';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'availableOn',
|
|
|
|
template: `
|
|
|
|
<dl class="uk-description-list-line">
|
2018-06-28 16:52:45 +02:00
|
|
|
<dt class="title">Available on</dt>
|
2018-05-16 17:42:42 +02:00
|
|
|
<dd class="line" *ngFor="let available of availableOn.slice(0, showNum) let i=index" >
|
|
|
|
<div>
|
2018-06-28 16:52:45 +02:00
|
|
|
<!--div class="{{available['bestAccessMode']}}"-->
|
|
|
|
<div [class]="available['bestAccessMode'] ? available['bestAccessMode'] : 'UNKNOWN ACCESSMODE'">
|
2017-12-19 13:53:46 +01:00
|
|
|
<span *ngIf="available.downloadUrl.length > 1"
|
|
|
|
class="custom-external custom-icon">
|
|
|
|
{{available.downloadName}}
|
|
|
|
<span *ngFor="let url of available.downloadUrl; let i=index;">
|
|
|
|
<a href="{{url}}" target="_blank"
|
2018-06-28 16:52:45 +02:00
|
|
|
|
|
|
|
attr.uk-tooltip="pos:right; delay:10"
|
|
|
|
[title]="available.accessMode[i] ? available.accessMode[i] : 'UNKNOWN ACCESSMODE'">
|
2018-05-18 14:47:26 +02:00
|
|
|
[{{(i+1) | number}}]
|
2017-12-19 13:53:46 +01:00
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
<a class="custom-external custom-icon"
|
|
|
|
*ngIf="available['downloadUrl'].length == 1"
|
|
|
|
href="{{available['downloadUrl']}}"
|
|
|
|
target="_blank"
|
2018-06-28 16:52:45 +02:00
|
|
|
|
|
|
|
attr.uk-tooltip="pos:right; delay:10"
|
|
|
|
[title]="available.bestAccessMode ? available.bestAccessMode : 'UNKNOWN ACCESSMODE'">
|
2017-12-19 13:53:46 +01:00
|
|
|
{{available.downloadName}}
|
|
|
|
</a>
|
|
|
|
<span *ngIf="available.collectedName" class="uk-text-bold">via</span>
|
|
|
|
<a *ngIf="available.collectedName"
|
|
|
|
[queryParams]="{datasourceId: available.collectedId}" routerLinkActive="router-link-active" routerLink="/search/dataprovider">
|
|
|
|
{{available.collectedName}}
|
|
|
|
</a>
|
2018-02-13 15:52:23 +01:00
|
|
|
<span *ngIf="available.type || available.year">(<span *ngIf="available.type">{{available.type}}<span *ngIf="available.year">, </span></span><span *ngIf="available.year">{{available.year}}</span>)</span>
|
2017-12-19 13:53:46 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</dl>
|
2018-05-16 17:42:42 +02:00
|
|
|
|
|
|
|
<div *ngIf="showNum > threshold" class="uk-text-right">
|
|
|
|
<a (click)="showNum = threshold; scroll()">
|
|
|
|
View less
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div *ngIf="showNum == threshold && availableOn && availableOn.length > 5">...</div>
|
|
|
|
<div *ngIf="showNum == threshold && availableOn && availableOn.length > 5" class="uk-text-right">
|
|
|
|
<a (click)="showNum = availableOn.length;">
|
|
|
|
View more
|
|
|
|
</a>
|
|
|
|
</div>
|
2017-12-19 13:53:46 +01:00
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class AvailableOnComponent {
|
|
|
|
@Input() availableOn: { "downloadName": string, "downloadUrl": string[],
|
|
|
|
"collectedName": string, "collectedId": string,
|
|
|
|
"accessMode": string[], "bestAccessMode": string,
|
|
|
|
"type": string, "year":string }[];
|
|
|
|
|
2018-05-16 17:42:42 +02:00
|
|
|
public threshold: number = 5;
|
|
|
|
public showNum: number = 5;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
constructor (private element: ElementRef) {}
|
|
|
|
|
|
|
|
ngOnInit() {}
|
|
|
|
|
|
|
|
public scroll() {
|
|
|
|
console.info("scroll into view");
|
|
|
|
if (typeof document !== 'undefined') {
|
|
|
|
this.element.nativeElement.scrollIntoView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|