restrict result title in 3 rows for search page and 5 rows for landing page (included tooltip for landing)

This commit is contained in:
Alex Martzios 2023-03-28 11:37:44 +03:00
parent a356a08d67
commit 6679e6bac0
2 changed files with 54 additions and 51 deletions

View File

@ -1,5 +1,4 @@
import {Component, Input} from '@angular/core'; import {Component, ElementRef, Input, ViewChild} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
@Component({ @Component({
selector: 'showTitle', selector: 'showTitle',
@ -7,6 +6,7 @@ import {ActivatedRoute} from '@angular/router';
<h1 [ngClass]="classNames" class="uk-h6"> <h1 [ngClass]="classNames" class="uk-h6">
<ng-container *ngTemplateOutlet="_title;"></ng-container> <ng-container *ngTemplateOutlet="_title;"></ng-container>
</h1> </h1>
<ng-template #_title> <ng-template #_title>
<div *ngIf="title != undefined" class="landingTitle uk-text-break"> <div *ngIf="title != undefined" class="landingTitle uk-text-break">
<span *ngIf="title['url'] != undefined && title['url'] != null && title['url'] != ''" <span *ngIf="title['url'] != undefined && title['url'] != null && title['url'] != ''"
@ -25,20 +25,19 @@ import {ActivatedRoute} from '@angular/router';
[innerHTML]="title['name']"> [innerHTML]="title['name']">
</span> </span>
<span *ngIf="(title['name'] == undefined || title['name'] == '') && <span *ngIf="(title['name'] == undefined || title['name'] == '') &&
(title['url'] == undefined || title['url'] == null || title['url'] == '')" (title['url'] == undefined || title['url'] == null || title['url'] == '')">
>
[no title available] [no title available]
</span> </span>
</div> </div>
<div *ngIf="titleName" class="uk-text-break"> <div *ngIf="titleName" #titleDiv class="uk-text-break multi-line-ellipsis lines-5">
<span [innerHTML]="titleName"></span> <span [innerHTML]="titleName" [attr.uk-tooltip]="showTitleTooltip ? 'cls: uk-active uk-width-large' : 'cls: uk-invisible'"
[title]="titleName"></span>
</div> </div>
<div *ngIf="!titleName && !title"> <div *ngIf="!titleName && !title">
<span>No title available</span> <span>No title available</span>
</div> </div>
</ng-template> </ng-template>
` `
}) })
export class ShowTitleComponent { export class ShowTitleComponent {
@ -46,7 +45,11 @@ export class ShowTitleComponent {
@Input() title: { [key: string]: string }; @Input() title: { [key: string]: string };
@Input() iconClass:string; @Input() iconClass:string;
@Input() classNames: string = ""; @Input() classNames: string = "";
@ViewChild("titleDiv") titleDiv: ElementRef;
constructor () {} constructor () {}
get showTitleTooltip():boolean {
return !!this.titleDiv && (this.titleDiv.nativeElement.clientHeight >= 5 * 21);
}
} }

View File

@ -19,7 +19,7 @@
<!-- 1st section (title, metadata) --> <!-- 1st section (title, metadata) -->
<div class="uk-margin-small-bottom"> <div class="uk-margin-small-bottom">
<!-- Title --> <!-- Title -->
<div> <div class="multi-line-ellipsis lines-3">
<h2 class="uk-margin-remove uk-text-break uk-inline-block uk-h6"> <h2 class="uk-margin-remove uk-text-break uk-inline-block uk-h6">
<a *ngIf="!externalUrl && result.id" (click)="onClick()" [queryParams]="createParam()" <a *ngIf="!externalUrl && result.id" (click)="onClick()" [queryParams]="createParam()"
[routerLink]="url" class="uk-link uk-text-decoration-none uk-width-expand"> [routerLink]="url" class="uk-link uk-text-decoration-none uk-width-expand">