[Library | Trunk]: PIDs add title, fix truncate on 2 lines. Remove input properties
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60852 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
006c347932
commit
7533e7d3ff
|
@ -1,4 +1,4 @@
|
||||||
import {Component, Input} from '@angular/core';
|
import {AfterViewInit, Component, ElementRef, HostListener, Input, OnInit, ViewChild} from '@angular/core';
|
||||||
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||||
import {EnvProperties} from "../../utils/properties/env-properties";
|
import {EnvProperties} from "../../utils/properties/env-properties";
|
||||||
import {properties} from "../../../../environments/environment";
|
import {properties} from "../../../../environments/environment";
|
||||||
|
@ -6,105 +6,82 @@ import {properties} from "../../../../environments/environment";
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'showIdentifiers',
|
selector: 'showIdentifiers',
|
||||||
template: `
|
template: `
|
||||||
<ng-container *ngFor="let key of getKeys(identifiers) let i=index">
|
<div class="uk-text-muted">Persistent Identifiers</div>
|
||||||
<div>
|
<div class="uk-height-max-medium uk-overflow-auto uk-margin-small-top">
|
||||||
<span *ngIf="countSizeOfPreviousIdentifiers(i) < pageSize || showAll" class="uk-margin-right">
|
<ng-container *ngFor="let key of keys let i=index">
|
||||||
<span class="uk-text-muted uk-text-uppercase">{{key}}: </span>
|
<div [class.multi-line-ellipsis]="large.get(key) && !showAll" [class.lines-2]="keys.length === 1" [class.line-1]="keys.length > 1">
|
||||||
|
<p class="custom-break uk-margin-remove">
|
||||||
|
<span [id]="key">
|
||||||
|
<span class="uk-text-bold uk-text-uppercase">{{key}}: </span>
|
||||||
<ng-container *ngFor="let item of identifiers.get(key) let j=index">
|
<ng-container *ngFor="let item of identifiers.get(key) let j=index">
|
||||||
<span *ngIf="(sizeOfPreviousIdentifiers + j) < pageSize || showAll">
|
<a *ngIf="key=='doi'" [href]="properties.doiURL + item" target="_blank" class="uk-display-inline">
|
||||||
<span class="uk-display-inline-block">
|
{{item}} <span class="custom-external custom-icon space"></span>
|
||||||
<a *ngIf="key=='doi'" [href]="properties.doiURL + item" target="_blank">
|
</a>
|
||||||
{{item}} <span class="custom-external custom-icon space"></span>
|
<a *ngIf="key=='pmc'" [href]="properties.pmcURL + item" target="_blank">
|
||||||
</a>
|
{{item}} <span class="custom-external custom-icon space"></span>
|
||||||
<a *ngIf="key=='pmc'" [href]="properties.pmcURL + item" target="_blank">
|
</a>
|
||||||
{{item}} <span class="custom-external custom-icon space"></span>
|
<a *ngIf="key=='pmid'" [href]="properties.pmidURL + item" target="_blank">
|
||||||
</a>
|
{{item}} <span class="custom-external custom-icon space"></span>
|
||||||
<a *ngIf="key=='pmid'" [href]="properties.pmidURL + item" target="_blank">
|
</a>
|
||||||
{{item}} <span class="custom-external custom-icon space"></span>
|
<a *ngIf="key=='handle'" [href]="properties.handleURL + item" target="_blank">
|
||||||
</a>
|
{{item}} <span class="custom-external custom-icon space"></span>
|
||||||
<a *ngIf="key=='handle'" [href]="properties.handleURL + item" target="_blank">
|
</a>
|
||||||
{{item}} <span class="custom-external custom-icon space"></span>
|
<ng-container *ngIf="(j !== (identifiers.get(key).length - 1))">, </ng-container>
|
||||||
</a>
|
</ng-container>
|
||||||
</span>
|
|
||||||
<!-- <span *ngIf="j !== (identifiers.get(key).length - 1)">, </span>-->
|
|
||||||
|
|
||||||
<span *ngIf="(j !== (identifiers.get(key).length - 1)) && (showAll || ((sizeOfPreviousIdentifiers+j+1) < pageSize))">, </span>
|
|
||||||
<span *ngIf="!showAll && (sizeOfPreviousIdentifiers+j+1) == pageSize && sizeOfIdentifiers > pageSize"> ... </span>
|
|
||||||
|
|
||||||
</span>
|
|
||||||
</ng-container>
|
|
||||||
</span>
|
</span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<div *ngIf="!showAll && countIdentifiers() > pageSize" class="uk-text-right">
|
</div>
|
||||||
<a (click)="showAll = !showAll;">
|
<div *ngIf="isLarge && showViewAll" class="uk-text-right uk-margin-small-top">
|
||||||
View all {{countIdentifiers() | number}} identifiers
|
<a (click)="showAll = !showAll">View {{showAll?'less':'all'}}</a>
|
||||||
</a>
|
</div>
|
||||||
</div>
|
|
||||||
<div *ngIf="showAll && countIdentifiers() > pageSize" class="uk-text-right">
|
|
||||||
<a (click)="showAll = !showAll;">View less identifiers</a>
|
|
||||||
</div>
|
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
|
|
||||||
export class ShowIdentifiersComponent {
|
export class ShowIdentifiersComponent implements OnInit, AfterViewInit {
|
||||||
@Input() identifiers: Map<string, string[]>;
|
@Input() identifiers: Map<string, string[]>;
|
||||||
@Input() properties: EnvProperties = properties;
|
@Input() showViewAll: boolean = false;
|
||||||
public showAll: boolean = false;
|
large: Map<string, boolean> = new Map<string, boolean>();
|
||||||
public sizeOfIdentifiers: number = -1;
|
showAll: boolean = false;
|
||||||
public sizeOfPreviousIdentifiers: number = -1;
|
properties: EnvProperties = properties;
|
||||||
public pageSize: number = 3;
|
|
||||||
|
|
||||||
constructor() {}
|
@HostListener('window:resize', ['$event'])
|
||||||
|
onResize(event) {
|
||||||
|
this.checkLarge();
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {}
|
ngOnInit() {
|
||||||
|
this.checkLarge();
|
||||||
|
}
|
||||||
|
|
||||||
public countIdentifiers(): number {
|
ngAfterViewInit() {
|
||||||
if (this.sizeOfIdentifiers < 0) {
|
this.checkLarge();
|
||||||
let num: number = 0;
|
}
|
||||||
if (this.identifiers != undefined) {
|
|
||||||
this.identifiers.forEach((value, key, map) => {
|
checkLarge() {
|
||||||
num += value.length;
|
let overflow = (this.keys.length === 1?42:21);
|
||||||
});
|
if(typeof document !== "undefined") {
|
||||||
|
this.keys.forEach(key => {
|
||||||
|
this.large.set(key, document.getElementById(key) && document.getElementById(key).offsetHeight > overflow)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get isLarge() {
|
||||||
|
for(let key of this.keys) {
|
||||||
|
if (this.large.get(key)) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
this.sizeOfIdentifiers = num;
|
|
||||||
}
|
}
|
||||||
return this.sizeOfIdentifiers;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public countSizeOfPreviousIdentifiers(index: number): number {
|
public get keys(): string[] {
|
||||||
let num: number = 0;
|
return Array.from(this.identifiers.keys()).sort((a: string, b: string) => {
|
||||||
let i: number = 0;
|
if (a === 'doi') {
|
||||||
if (this.identifiers != undefined) {
|
|
||||||
let self = this;
|
|
||||||
this.getKeys(this.identifiers).forEach(function(key: string) {
|
|
||||||
// console.debug("value:", self.identifiers.get(key));
|
|
||||||
if (i < index) {
|
|
||||||
num += self.identifiers.get(key).length;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
})
|
|
||||||
// this.identifiers.forEach(function (value, key, map) {
|
|
||||||
// console.debug("value:", value);
|
|
||||||
// if (i < index) {
|
|
||||||
// num += value.length;
|
|
||||||
// }
|
|
||||||
// i++;
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
this.sizeOfPreviousIdentifiers = num;
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
public scroll() {
|
|
||||||
HelperFunctions.scroll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public getKeys(map) {
|
|
||||||
return Array.from(map.keys()).sort((a: string, b: string) => {
|
|
||||||
if(a === 'doi') {
|
|
||||||
return -1;
|
return -1;
|
||||||
} else if(b === 'doi') {
|
} else if (b === 'doi') {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
role="alert">{{warningMessage}}</div>
|
role="alert">{{warningMessage}}</div>
|
||||||
<div *ngIf="errorMessage.length > 0" class="uk-alert uk-alert-danger uk-margin-large-top"
|
<div *ngIf="errorMessage.length > 0" class="uk-alert uk-alert-danger uk-margin-large-top"
|
||||||
role="alert">{{errorMessage}}</div>
|
role="alert">{{errorMessage}}</div>
|
||||||
<div [style.display]="showLoading ? 'inline' : 'none'"
|
<div *ngIf="showLoading" class="uk-position-center">
|
||||||
class="uk-animation-fade uk-margin-large-top uk-width-1-1" role="alert">
|
<loading></loading>
|
||||||
<span *ngIf="!dashboard" class="loading-gif uk-align-center"></span>
|
|
||||||
<loading *ngIf="dashboard"></loading>
|
|
||||||
</div>
|
</div>
|
||||||
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
|
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
|
||||||
[texts]="pageContents['top']"></helper>
|
[texts]="pageContents['top']"></helper>
|
||||||
|
@ -177,9 +175,7 @@
|
||||||
<!-- Identifiers -->
|
<!-- Identifiers -->
|
||||||
<div *ngIf="resultLandingInfo.identifiers && resultLandingInfo.identifiers.size > 0"
|
<div *ngIf="resultLandingInfo.identifiers && resultLandingInfo.identifiers.size > 0"
|
||||||
class="uk-margin-medium-bottom">
|
class="uk-margin-medium-bottom">
|
||||||
<showIdentifiers [identifiers]="resultLandingInfo.identifiers"
|
<showIdentifiers [identifiers]="resultLandingInfo.identifiers" [showViewAll]="true"></showIdentifiers>
|
||||||
[properties]="properties">
|
|
||||||
</showIdentifiers>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Subjects -->
|
<!-- Subjects -->
|
||||||
<div *ngIf="resultLandingInfo.subjects || resultLandingInfo.otherSubjects ||
|
<div *ngIf="resultLandingInfo.subjects || resultLandingInfo.otherSubjects ||
|
||||||
|
|
|
@ -170,7 +170,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Identifiers -->
|
<!-- Identifiers -->
|
||||||
<div *ngIf="result.identifiers && result.identifiers.size > 0" class="uk-margin-small-bottom">
|
<div *ngIf="result.identifiers && result.identifiers.size > 0" class="uk-margin-small-bottom">
|
||||||
<showIdentifiers [identifiers]="result.identifiers" [properties]="properties"></showIdentifiers>
|
<showIdentifiers [identifiers]="result.identifiers"></showIdentifiers>
|
||||||
</div>
|
</div>
|
||||||
<!-- Publisher -->
|
<!-- Publisher -->
|
||||||
<div *ngIf="result.publisher && result.publisher != ''" class="uk-margin-small-bottom">
|
<div *ngIf="result.publisher && result.publisher != ''" class="uk-margin-small-bottom">
|
||||||
|
|
Loading…
Reference in New Issue