import {Component, Input} from '@angular/core';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {EnvProperties} from "../../utils/properties/env-properties";
@Component({
selector: 'availableOn',
template: `
threshold" class="uk-text-center uk-margin-bottom">
View less
5" class="uk-text-center uk-margin-bottom">
View more
`
})
export class AvailableOnComponent {
@Input() availableOn: {
"downloadName": string, "downloadUrl": string[],
"collectedName": string, "collectedId": string,
"accessMode": string[], "bestAccessMode": string,
"type": string, "year": string, icon: string
}[];
@Input() properties: EnvProperties;
public open = 'assets/common-assets/unlock.svg';
public closed = 'assets/common-assets/lock.svg';
public unknown = 'assets/common-assets/question.svg';
public threshold: number = 4;
public showNum: number = 4;
constructor() {
}
ngOnInit() {
this.availableOn.forEach(available => {
if (available.bestAccessMode) {
if (available.bestAccessMode.toLowerCase().indexOf('open') !== -1) {
available.icon = this.open;
} else if (available.bestAccessMode.toLowerCase().indexOf('not available') !== -1) {
available.icon = this.unknown;
} else {
available.icon = this.closed;
}
} else {
available.icon = this.unknown;
}
}
);
}
public removeUnknown(value: string): string {
if(this.properties.environment === 'production') {
if (value.toLowerCase() === 'unknown') {
return null;
}
}
return value;
}
public scroll() {
HelperFunctions.scroll();
}
}