forked from hazza/dspace-angular
Merge remote-tracking branch 'origin/main' into CST-6876
# Conflicts: # src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts # src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts # src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts # src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import {
|
||||
ChangeDetectorRef,
|
||||
Component, ElementRef,
|
||||
EventEmitter, Inject,
|
||||
Input,
|
||||
OnInit,
|
||||
Output, PLATFORM_ID,
|
||||
} from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -14,6 +21,8 @@ import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
import { CollectionElementLinkType } from './collection-element-link.type';
|
||||
import { PaginatedList } from '../../core/data/paginated-list.model';
|
||||
import { Context } from '../../core/shared/context.model';
|
||||
import { setPlaceHolderAttributes } from '../utils/object-list-utils';
|
||||
import { isPlatformBrowser } from '@angular/common';
|
||||
|
||||
/**
|
||||
* Component that can render a list of listable objects in different view modes
|
||||
@@ -152,14 +161,13 @@ export class ObjectCollectionComponent implements OnInit {
|
||||
*/
|
||||
viewModeEnum = ViewMode;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.currentMode$ = this.route
|
||||
.queryParams
|
||||
.pipe(
|
||||
map((params) => isEmpty(params?.view) ? ViewMode.ListElement : params.view),
|
||||
distinctUntilChanged()
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Placeholder class (defined in global-styles)
|
||||
*/
|
||||
placeholderFontClass: string;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param cdRef
|
||||
@@ -168,11 +176,30 @@ export class ObjectCollectionComponent implements OnInit {
|
||||
* Route is a singleton service provided by Angular.
|
||||
* @param router
|
||||
* Router is a singleton service provided by Angular.
|
||||
* @param elementRef
|
||||
* Used only to read DOM for the element width
|
||||
*/
|
||||
constructor(
|
||||
private cdRef: ChangeDetectorRef,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
private router: Router,
|
||||
private elementRef: ElementRef,
|
||||
@Inject(PLATFORM_ID) private platformId: Object) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.currentMode$ = this.route
|
||||
.queryParams
|
||||
.pipe(
|
||||
map((params) => isEmpty(params?.view) ? ViewMode.ListElement : params.view),
|
||||
distinctUntilChanged()
|
||||
);
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
const width = this.elementRef.nativeElement.offsetWidth;
|
||||
this.placeholderFontClass = setPlaceHolderAttributes(width);
|
||||
} else {
|
||||
this.placeholderFontClass = 'hide-placeholder-text';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user