From 7533e7d3ff39c3b1c00c57a01b66ac3cdb4d7871 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Tue, 13 Apr 2021 12:33:40 +0000 Subject: [PATCH] [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 --- .../showIdentifiers.component.ts | 145 ++++++++---------- .../result/resultLanding.component.html | 10 +- .../result-preview.component.html | 2 +- 3 files changed, 65 insertions(+), 92 deletions(-) diff --git a/landingPages/landing-utils/showIdentifiers.component.ts b/landingPages/landing-utils/showIdentifiers.component.ts index d9bf563d..2f11d5af 100644 --- a/landingPages/landing-utils/showIdentifiers.component.ts +++ b/landingPages/landing-utils/showIdentifiers.component.ts @@ -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 {EnvProperties} from "../../utils/properties/env-properties"; import {properties} from "../../../../environments/environment"; @@ -6,105 +6,82 @@ import {properties} from "../../../../environments/environment"; @Component({ selector: 'showIdentifiers', template: ` - -
- - {{key}}: +
Persistent Identifiers
+ + ` }) -export class ShowIdentifiersComponent { +export class ShowIdentifiersComponent implements OnInit, AfterViewInit { @Input() identifiers: Map; - @Input() properties: EnvProperties = properties; - public showAll: boolean = false; - public sizeOfIdentifiers: number = -1; - public sizeOfPreviousIdentifiers: number = -1; - public pageSize: number = 3; + @Input() showViewAll: boolean = false; + large: Map = new Map(); + showAll: boolean = false; + properties: EnvProperties = properties; - constructor() {} + @HostListener('window:resize', ['$event']) + onResize(event) { + this.checkLarge(); + } - ngOnInit() {} + ngOnInit() { + this.checkLarge(); + } - public countIdentifiers(): number { - if (this.sizeOfIdentifiers < 0) { - let num: number = 0; - if (this.identifiers != undefined) { - this.identifiers.forEach((value, key, map) => { - num += value.length; - }); + ngAfterViewInit() { + this.checkLarge(); + } + + checkLarge() { + 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 { - let num: number = 0; - let i: number = 0; - 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') { + public get keys(): string[] { + return Array.from(this.identifiers.keys()).sort((a: string, b: string) => { + if (a === 'doi') { return -1; - } else if(b === 'doi') { + } else if (b === 'doi') { return 1; } else { return 0; diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index 2dc6675c..7ccf57d9 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -6,10 +6,8 @@ role="alert">{{warningMessage}}
-