11import { followLink } from '../utils/follow-link-config.model' ;
22import { CollectionElementLinkType } from '../object-collection/collection-element-link.type' ;
3- import { TopSection } from '../../core/layout/models/section.model' ;
43import { Component , Input , OnChanges , OnInit , PLATFORM_ID , inject } from '@angular/core' ;
54import { isPlatformServer } from '@angular/common' ;
65
@@ -31,17 +30,42 @@ export abstract class AbstractBrowseElementsComponent implements OnInit, OnChang
3130 protected readonly platformId = inject ( PLATFORM_ID ) ;
3231 protected readonly searchService = inject ( SearchService ) ;
3332
34- protected followThumbnailLink : boolean ; // to be overridden
33+ protected abstract followMetricsLink : boolean ; // to be overridden
34+ protected abstract followThumbnailLink : boolean ; // to be overridden
3535
36+ /**
37+ * The context of listable object
38+ */
39+ @Input ( ) context : Context ;
40+
41+ /**
42+ * The pagination options
43+ */
3644 @Input ( ) paginatedSearchOptions : PaginatedSearchOptions ;
3745
38- @Input ( ) context : Context ;
46+ /**
47+ * Optional projection to use during the search
48+ */
49+ @Input ( ) projection = 'preventMetadataSecurity' ;
50+
51+ /**
52+ * Whether to show the badge label or not
53+ */
54+ @Input ( ) showLabel : boolean ;
3955
40- @Input ( ) topSection : TopSection ;
56+ /**
57+ * Whether to show the metrics badges
58+ */
59+ @Input ( ) showMetrics = this . appConfig . browseBy . showMetrics ;
60+
61+ /**
62+ * Whether to show the thumbnail preview
63+ */
64+ @Input ( ) showThumbnails = this . appConfig . browseBy . showThumbnails ;
4165
4266 public collectionElementLinkTypeEnum = CollectionElementLinkType ;
4367
44- paginatedSearchOptionsBS : BehaviorSubject < PaginatedSearchOptions > ;
68+ paginatedSearchOptions$ : BehaviorSubject < PaginatedSearchOptions > ;
4569
4670 searchResults$ : Observable < RemoteData < PaginatedList < SearchResult < DSpaceObject > > > > ;
4771
@@ -51,13 +75,23 @@ export abstract class AbstractBrowseElementsComponent implements OnInit, OnChang
5175 if ( isPlatformServer ( this . platformId ) ) {
5276 return ;
5377 }
54- this . paginatedSearchOptionsBS ?. next ( this . paginatedSearchOptions ) ;
78+ this . paginatedSearchOptions$ ?. next ( this . paginatedSearchOptions ) ;
5579 }
5680
5781 ngOnInit ( ) {
58- const followLinks = this . followThumbnailLink ? [ followLink ( 'thumbnail' ) , followLink ( 'metrics' ) ] : [ followLink ( 'metrics' ) ] ;
59- this . paginatedSearchOptionsBS = new BehaviorSubject < PaginatedSearchOptions > ( this . paginatedSearchOptions ) ;
60- this . searchResults$ = this . paginatedSearchOptionsBS . asObservable ( ) . pipe (
82+ const followLinks = [ ] ;
83+ if ( this . followThumbnailLink ) {
84+ followLinks . push ( followLink ( 'thumbnail' ) ) ;
85+ }
86+ if ( this . followMetricsLink ) {
87+ followLinks . push ( followLink ( 'metrics' ) ) ;
88+ }
89+
90+ this . paginatedSearchOptions = Object . assign ( new PaginatedSearchOptions ( { } ) , this . paginatedSearchOptions , {
91+ projection : this . projection
92+ } ) ;
93+ this . paginatedSearchOptions$ = new BehaviorSubject < PaginatedSearchOptions > ( this . paginatedSearchOptions ) ;
94+ this . searchResults$ = this . paginatedSearchOptions$ . asObservable ( ) . pipe (
6195 mergeMap ( ( paginatedSearchOptions ) =>
6296 this . searchService . search ( paginatedSearchOptions , null , true , true , ...followLinks ) ,
6397 ) ,
0 commit comments