1- import { ChangeDetectionStrategy , Component , OnInit } from '@angular/core' ;
1+ import { ChangeDetectionStrategy , Component , ElementRef , Inject , OnInit , PLATFORM_ID } from '@angular/core' ;
22import { PaginatedSearchOptions } from '../../shared/search/models/paginated-search-options.model' ;
33import { fadeIn , fadeInOut } from '../../shared/animations/fade' ;
44import { RemoteData } from '../../core/data/remote-data' ;
@@ -11,12 +11,13 @@ import { SortDirection, SortOptions } from '../../core/cache/models/sort-options
1111import { environment } from '../../../environments/environment' ;
1212import { ViewMode } from '../../core/shared/view-mode.model' ;
1313import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service' ;
14- import {
15- toDSpaceObjectListRD
16- } from '../../core/shared/operators' ;
17- import {
18- Observable ,
19- } from 'rxjs' ;
14+ import { toDSpaceObjectListRD } from '../../core/shared/operators' ;
15+ import { Observable } from 'rxjs' ;
16+ import { followLink , FollowLinkConfig } from '../../shared/utils/follow-link-config.model' ;
17+ import { APP_CONFIG , AppConfig } from '../../../config/app-config.interface' ;
18+ import { isPlatformBrowser } from '@angular/common' ;
19+ import { setPlaceHolderAttributes } from '../../shared/utils/object-list-utils' ;
20+
2021@Component ( {
2122 selector : 'ds-recent-item-list' ,
2223 templateUrl : './recent-item-list.component.html' ,
@@ -31,14 +32,22 @@ export class RecentItemListComponent implements OnInit {
3132 itemRD$ : Observable < RemoteData < PaginatedList < Item > > > ;
3233 paginationConfig : PaginationComponentOptions ;
3334 sortConfig : SortOptions ;
35+
3436 /**
3537 * The view-mode we're currently on
3638 * @type {ViewMode }
3739 */
3840 viewMode = ViewMode . ListElement ;
39- constructor ( private searchService : SearchService ,
41+
42+ private _placeholderFontClass : string ;
43+
44+ constructor (
45+ private searchService : SearchService ,
4046 private paginationService : PaginationService ,
41- public searchConfigurationService : SearchConfigurationService
47+ public searchConfigurationService : SearchConfigurationService ,
48+ protected elementRef : ElementRef ,
49+ @Inject ( APP_CONFIG ) private appConfig : AppConfig ,
50+ @Inject ( PLATFORM_ID ) private platformId : Object ,
4251 ) {
4352
4453 this . paginationConfig = Object . assign ( new PaginationComponentOptions ( ) , {
@@ -50,16 +59,29 @@ export class RecentItemListComponent implements OnInit {
5059 this . sortConfig = new SortOptions ( environment . homePage . recentSubmissions . sortField , SortDirection . DESC ) ;
5160 }
5261 ngOnInit ( ) : void {
62+ const linksToFollow : FollowLinkConfig < Item > [ ] = [ ] ;
63+ if ( this . appConfig . browseBy . showThumbnails ) {
64+ linksToFollow . push ( followLink ( 'thumbnail' ) ) ;
65+ }
66+
5367 this . itemRD$ = this . searchService . search (
5468 new PaginatedSearchOptions ( {
5569 pagination : this . paginationConfig ,
5670 sort : this . sortConfig ,
5771 } ) ,
58- ) . pipe ( toDSpaceObjectListRD ( ) ) as Observable < RemoteData < PaginatedList < Item > > > ;
72+ undefined ,
73+ undefined ,
74+ undefined ,
75+ ...linksToFollow ,
76+ ) . pipe (
77+ toDSpaceObjectListRD ( )
78+ ) as Observable < RemoteData < PaginatedList < Item > > > ;
5979 }
80+
6081 ngOnDestroy ( ) : void {
6182 this . paginationService . clearPagination ( this . paginationConfig . id ) ;
6283 }
84+
6385 onLoadMore ( ) : void {
6486 this . paginationService . updateRouteWithUrl ( this . searchConfigurationService . paginationID , [ 'search' ] , {
6587 sortField : environment . homePage . recentSubmissions . sortField ,
@@ -68,5 +90,17 @@ export class RecentItemListComponent implements OnInit {
6890 } ) ;
6991 }
7092
93+ get placeholderFontClass ( ) : string {
94+ if ( this . _placeholderFontClass === undefined ) {
95+ if ( isPlatformBrowser ( this . platformId ) ) {
96+ const width = this . elementRef . nativeElement . offsetWidth ;
97+ this . _placeholderFontClass = setPlaceHolderAttributes ( width ) ;
98+ } else {
99+ this . _placeholderFontClass = 'hide-placeholder-text' ;
100+ }
101+ }
102+ return this . _placeholderFontClass ;
103+ }
104+
71105}
72106
0 commit comments