diff --git a/config/config.example.yml b/config/config.example.yml index 7a878094d2..b0112ef13a 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -174,6 +174,10 @@ browseBy: fiveYearLimit: 30 # The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items) defaultLowerLimit: 1900 + # The number of entries in a paginated browse results list. + # Rounded to the nearest size in the list of selectable sizes on the + # settings menu. + pageSize: 20 communityList: # No. of communities to list per expansion (show more) diff --git a/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.spec.ts b/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.spec.ts index 15ec9d78db..b6ff177d3d 100644 --- a/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.spec.ts +++ b/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.spec.ts @@ -23,6 +23,8 @@ import { SortDirection, SortOptions } from '../../core/cache/models/sort-options import { PaginationService } from '../../core/pagination/pagination.service'; import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub'; import { FindListOptions } from '../../core/data/find-list-options.model'; +import { APP_CONFIG } from 'src/config/app-config.interface'; +import { environment } from 'src/environments/environment'; describe('BrowseByDatePageComponent', () => { let comp: BrowseByDatePageComponent; @@ -83,7 +85,8 @@ describe('BrowseByDatePageComponent', () => { { provide: DSpaceObjectDataService, useValue: mockDsoService }, { provide: Router, useValue: new RouterMock() }, { provide: PaginationService, useValue: paginationService }, - { provide: ChangeDetectorRef, useValue: mockCdRef } + { provide: ChangeDetectorRef, useValue: mockCdRef }, + { provide: APP_CONFIG, useValue: environment } ], schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); diff --git a/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.ts b/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.ts index 271828a38e..9b031260ce 100644 --- a/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.ts +++ b/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectorRef, Component } from '@angular/core'; +import { ChangeDetectorRef, Component, Inject } from '@angular/core'; import { BrowseByMetadataPageComponent, browseParamsToOptions @@ -19,6 +19,7 @@ import { map } from 'rxjs/operators'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; import { isValidDate } from '../../shared/date.util'; +import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface'; @Component({ selector: 'ds-browse-by-date-page', @@ -43,8 +44,9 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent { protected dsoService: DSpaceObjectDataService, protected router: Router, protected paginationService: PaginationService, - protected cdRef: ChangeDetectorRef) { - super(route, browseService, dsoService, paginationService, router); + protected cdRef: ChangeDetectorRef, + @Inject(APP_CONFIG) protected appConfig: AppConfig) { + super(route, browseService, dsoService, paginationService, router, appConfig); } ngOnInit(): void { diff --git a/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.spec.ts b/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.spec.ts index 60d2fa549b..03152d0d3e 100644 --- a/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.spec.ts +++ b/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.spec.ts @@ -25,6 +25,8 @@ import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.util import { PaginationService } from '../../core/pagination/pagination.service'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub'; +import { APP_CONFIG } from '../../../config/app-config.interface'; +import { environment } from '../../../environments/environment'; describe('BrowseByMetadataPageComponent', () => { let comp: BrowseByMetadataPageComponent; @@ -97,7 +99,8 @@ describe('BrowseByMetadataPageComponent', () => { { provide: BrowseService, useValue: mockBrowseService }, { provide: DSpaceObjectDataService, useValue: mockDsoService }, { provide: PaginationService, useValue: paginationService }, - { provide: Router, useValue: new RouterMock() } + { provide: Router, useValue: new RouterMock() }, + { provide: APP_CONFIG, useValue: environment } ], schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); diff --git a/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts b/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts index c685fe31a7..20817d9675 100644 --- a/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts +++ b/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts @@ -1,5 +1,6 @@ import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs'; -import { Component, OnInit } from '@angular/core'; +import { Component, Inject, OnInit } from '@angular/core'; +import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface'; import { RemoteData } from '../../core/data/remote-data'; import { PaginatedList } from '../../core/data/paginated-list.model'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; @@ -26,9 +27,10 @@ export const BBM_PAGINATION_ID = 'bbm'; templateUrl: './browse-by-metadata-page.component.html' }) /** - * Component for browsing (items) by metadata definition - * A metadata definition (a.k.a. browse id) is a short term used to describe one or multiple metadata fields. - * An example would be 'author' for 'dc.contributor.*' + * Component for browsing (items) by metadata definition. + * A metadata definition (a.k.a. browse id) is a short term used to describe one + * or multiple metadata fields. An example would be 'author' for + * 'dc.contributor.*' */ @rendersBrowseBy(BrowseByDataType.Metadata) export class BrowseByMetadataPageComponent implements OnInit { @@ -51,11 +53,7 @@ export class BrowseByMetadataPageComponent implements OnInit { /** * The pagination config used to display the values */ - paginationConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), { - id: BBM_PAGINATION_ID, - currentPage: 1, - pageSize: 20 - }); + paginationConfig: PaginationComponentOptions; /** * The pagination observable @@ -115,8 +113,14 @@ export class BrowseByMetadataPageComponent implements OnInit { protected browseService: BrowseService, protected dsoService: DSpaceObjectDataService, protected paginationService: PaginationService, - protected router: Router) { - } + protected router: Router, + @Inject(APP_CONFIG) protected appConfig: AppConfig) { + this.paginationConfig = Object.assign(new PaginationComponentOptions(), { + id: BBM_PAGINATION_ID, + currentPage: 1, + pageSize: this.appConfig.browseBy.pageSize, + }); + } ngOnInit(): void { const sortConfig = new SortOptions('default', SortDirection.ASC); diff --git a/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.spec.ts b/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.spec.ts index 554b059ac5..600eab575b 100644 --- a/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.spec.ts +++ b/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.spec.ts @@ -23,6 +23,8 @@ import { SortDirection, SortOptions } from '../../core/cache/models/sort-options import { PaginationService } from '../../core/pagination/pagination.service'; import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub'; import { FindListOptions } from '../../core/data/find-list-options.model'; +import { APP_CONFIG } from 'src/config/app-config.interface'; +import { environment } from 'src/environments/environment'; describe('BrowseByTitlePageComponent', () => { let comp: BrowseByTitlePageComponent; @@ -77,7 +79,8 @@ describe('BrowseByTitlePageComponent', () => { { provide: BrowseService, useValue: mockBrowseService }, { provide: DSpaceObjectDataService, useValue: mockDsoService }, { provide: PaginationService, useValue: paginationService }, - { provide: Router, useValue: new RouterMock() } + { provide: Router, useValue: new RouterMock() }, + { provide: APP_CONFIG, useValue: environment } ], schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); diff --git a/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.ts b/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.ts index 6504a8700a..a6528bed49 100644 --- a/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.ts +++ b/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.ts @@ -1,5 +1,5 @@ import { combineLatest as observableCombineLatest } from 'rxjs'; -import { Component } from '@angular/core'; +import { Component, Inject } from '@angular/core'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { hasValue } from '../../shared/empty.util'; import { @@ -14,6 +14,7 @@ import { BrowseByDataType, rendersBrowseBy } from '../browse-by-switcher/browse- import { PaginationService } from '../../core/pagination/pagination.service'; import { map } from 'rxjs/operators'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; +import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface'; @Component({ selector: 'ds-browse-by-title-page', @@ -30,8 +31,9 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent { protected browseService: BrowseService, protected dsoService: DSpaceObjectDataService, protected paginationService: PaginationService, - protected router: Router) { - super(route, browseService, dsoService, paginationService, router); + protected router: Router, + @Inject(APP_CONFIG) protected appConfig: AppConfig) { + super(route, browseService, dsoService, paginationService, router, appConfig); } ngOnInit(): void { diff --git a/src/config/browse-by-config.interface.ts b/src/config/browse-by-config.interface.ts index 6adba66b92..c67d072731 100644 --- a/src/config/browse-by-config.interface.ts +++ b/src/config/browse-by-config.interface.ts @@ -1,21 +1,32 @@ import { Config } from './config.interface'; /** - * Config that determines how the dropdown list of years are created for browse-by-date components + * Config that determines how the dropdown list of years are created for + * browse-by-date components. */ export interface BrowseByConfig extends Config { /** - * The max amount of years to display using jumps of one year (current year - oneYearLimit) + * The max amount of years to display using jumps of one year + * (current year - oneYearLimit) */ oneYearLimit: number; /** - * Limit for years to display using jumps of five years (current year - fiveYearLimit) + * Limit for years to display using jumps of five years + * (current year - fiveYearLimit) */ fiveYearLimit: number; /** - * The absolute lowest year to display in the dropdown when no lowest date can be found for all items + * The absolute lowest year to display in the dropdown when no lowest date can + * be found for all items. */ defaultLowerLimit: number; + + /** + * Number of entries in the viewport of a paginated browse-by list. + * Rounded to the nearest size in the list of selectable sizes on the settings + * menu. See pageSizeOptions in 'pagination-component-options.model.ts'. + */ + pageSize: number; } diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index 9bb16250fb..fde6d89102 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -209,7 +209,11 @@ export class DefaultAppConfig implements AppConfig { // Limit for years to display using jumps of five years (current year - fiveYearLimit) fiveYearLimit: 30, // The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items) - defaultLowerLimit: 1900 + defaultLowerLimit: 1900, + // The number of entries in a paginated browse results list. + // Rounded to the nearest size in the list of selectable sizes on the + // settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. + pageSize: 20 }; communityList: CommunityListConfig = { diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index 733c4b308c..8a3492c207 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -203,6 +203,10 @@ export const environment: BuildConfig = { fiveYearLimit: 30, // The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items) defaultLowerLimit: 1900, + // The number of entries in a paginated browse results list. + // Rounded to the nearest size in the list of selectable sizes on the + // settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. + pageSize: 20, }, communityList: { pageSize: 20