Skip to content

Commit c76bae7

Browse files
authored
Merge pull request DSpace#1771 from mwoodiupui/browse-pagesize
Make the size of a browse result page configurable.
2 parents 8d62228 + 7f696b2 commit c76bae7

10 files changed

Lines changed: 65 additions & 25 deletions

config/config.example.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ browseBy:
174174
fiveYearLimit: 30
175175
# The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
176176
defaultLowerLimit: 1900
177+
# The number of entries in a paginated browse results list.
178+
# Rounded to the nearest size in the list of selectable sizes on the
179+
# settings menu.
180+
pageSize: 20
177181

178182
communityList:
179183
# No. of communities to list per expansion (show more)

src/app/browse-by/browse-by-date-page/browse-by-date-page.component.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { SortDirection, SortOptions } from '../../core/cache/models/sort-options
2323
import { PaginationService } from '../../core/pagination/pagination.service';
2424
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
2525
import { FindListOptions } from '../../core/data/find-list-options.model';
26+
import { APP_CONFIG } from 'src/config/app-config.interface';
27+
import { environment } from 'src/environments/environment';
2628

2729
describe('BrowseByDatePageComponent', () => {
2830
let comp: BrowseByDatePageComponent;
@@ -83,7 +85,8 @@ describe('BrowseByDatePageComponent', () => {
8385
{ provide: DSpaceObjectDataService, useValue: mockDsoService },
8486
{ provide: Router, useValue: new RouterMock() },
8587
{ provide: PaginationService, useValue: paginationService },
86-
{ provide: ChangeDetectorRef, useValue: mockCdRef }
88+
{ provide: ChangeDetectorRef, useValue: mockCdRef },
89+
{ provide: APP_CONFIG, useValue: environment }
8790
],
8891
schemas: [NO_ERRORS_SCHEMA]
8992
}).compileComponents();

src/app/browse-by/browse-by-date-page/browse-by-date-page.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectorRef, Component } from '@angular/core';
1+
import { ChangeDetectorRef, Component, Inject } from '@angular/core';
22
import {
33
BrowseByMetadataPageComponent,
44
browseParamsToOptions
@@ -19,6 +19,7 @@ import { map } from 'rxjs/operators';
1919
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
2020
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
2121
import { isValidDate } from '../../shared/date.util';
22+
import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface';
2223

2324
@Component({
2425
selector: 'ds-browse-by-date-page',
@@ -43,8 +44,9 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
4344
protected dsoService: DSpaceObjectDataService,
4445
protected router: Router,
4546
protected paginationService: PaginationService,
46-
protected cdRef: ChangeDetectorRef) {
47-
super(route, browseService, dsoService, paginationService, router);
47+
protected cdRef: ChangeDetectorRef,
48+
@Inject(APP_CONFIG) protected appConfig: AppConfig) {
49+
super(route, browseService, dsoService, paginationService, router, appConfig);
4850
}
4951

5052
ngOnInit(): void {

src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.util
2525
import { PaginationService } from '../../core/pagination/pagination.service';
2626
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
2727
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
28+
import { APP_CONFIG } from '../../../config/app-config.interface';
29+
import { environment } from '../../../environments/environment';
2830

2931
describe('BrowseByMetadataPageComponent', () => {
3032
let comp: BrowseByMetadataPageComponent;
@@ -97,7 +99,8 @@ describe('BrowseByMetadataPageComponent', () => {
9799
{ provide: BrowseService, useValue: mockBrowseService },
98100
{ provide: DSpaceObjectDataService, useValue: mockDsoService },
99101
{ provide: PaginationService, useValue: paginationService },
100-
{ provide: Router, useValue: new RouterMock() }
102+
{ provide: Router, useValue: new RouterMock() },
103+
{ provide: APP_CONFIG, useValue: environment }
101104
],
102105
schemas: [NO_ERRORS_SCHEMA]
103106
}).compileComponents();

src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs';
2-
import { Component, OnInit } from '@angular/core';
2+
import { Component, Inject, OnInit } from '@angular/core';
3+
import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface';
34
import { RemoteData } from '../../core/data/remote-data';
45
import { PaginatedList } from '../../core/data/paginated-list.model';
56
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
@@ -26,9 +27,10 @@ export const BBM_PAGINATION_ID = 'bbm';
2627
templateUrl: './browse-by-metadata-page.component.html'
2728
})
2829
/**
29-
* Component for browsing (items) by metadata definition
30-
* A metadata definition (a.k.a. browse id) is a short term used to describe one or multiple metadata fields.
31-
* An example would be 'author' for 'dc.contributor.*'
30+
* Component for browsing (items) by metadata definition.
31+
* A metadata definition (a.k.a. browse id) is a short term used to describe one
32+
* or multiple metadata fields. An example would be 'author' for
33+
* 'dc.contributor.*'
3234
*/
3335
@rendersBrowseBy(BrowseByDataType.Metadata)
3436
export class BrowseByMetadataPageComponent implements OnInit {
@@ -51,11 +53,7 @@ export class BrowseByMetadataPageComponent implements OnInit {
5153
/**
5254
* The pagination config used to display the values
5355
*/
54-
paginationConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
55-
id: BBM_PAGINATION_ID,
56-
currentPage: 1,
57-
pageSize: 20
58-
});
56+
paginationConfig: PaginationComponentOptions;
5957

6058
/**
6159
* The pagination observable
@@ -115,8 +113,14 @@ export class BrowseByMetadataPageComponent implements OnInit {
115113
protected browseService: BrowseService,
116114
protected dsoService: DSpaceObjectDataService,
117115
protected paginationService: PaginationService,
118-
protected router: Router) {
119-
}
116+
protected router: Router,
117+
@Inject(APP_CONFIG) protected appConfig: AppConfig) {
118+
this.paginationConfig = Object.assign(new PaginationComponentOptions(), {
119+
id: BBM_PAGINATION_ID,
120+
currentPage: 1,
121+
pageSize: this.appConfig.browseBy.pageSize,
122+
});
123+
}
120124

121125
ngOnInit(): void {
122126
const sortConfig = new SortOptions('default', SortDirection.ASC);

src/app/browse-by/browse-by-title-page/browse-by-title-page.component.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { SortDirection, SortOptions } from '../../core/cache/models/sort-options
2323
import { PaginationService } from '../../core/pagination/pagination.service';
2424
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
2525
import { FindListOptions } from '../../core/data/find-list-options.model';
26+
import { APP_CONFIG } from 'src/config/app-config.interface';
27+
import { environment } from 'src/environments/environment';
2628

2729
describe('BrowseByTitlePageComponent', () => {
2830
let comp: BrowseByTitlePageComponent;
@@ -77,7 +79,8 @@ describe('BrowseByTitlePageComponent', () => {
7779
{ provide: BrowseService, useValue: mockBrowseService },
7880
{ provide: DSpaceObjectDataService, useValue: mockDsoService },
7981
{ provide: PaginationService, useValue: paginationService },
80-
{ provide: Router, useValue: new RouterMock() }
82+
{ provide: Router, useValue: new RouterMock() },
83+
{ provide: APP_CONFIG, useValue: environment }
8184
],
8285
schemas: [NO_ERRORS_SCHEMA]
8386
}).compileComponents();

src/app/browse-by/browse-by-title-page/browse-by-title-page.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { combineLatest as observableCombineLatest } from 'rxjs';
2-
import { Component } from '@angular/core';
2+
import { Component, Inject } from '@angular/core';
33
import { ActivatedRoute, Params, Router } from '@angular/router';
44
import { hasValue } from '../../shared/empty.util';
55
import {
@@ -14,6 +14,7 @@ import { BrowseByDataType, rendersBrowseBy } from '../browse-by-switcher/browse-
1414
import { PaginationService } from '../../core/pagination/pagination.service';
1515
import { map } from 'rxjs/operators';
1616
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
17+
import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface';
1718

1819
@Component({
1920
selector: 'ds-browse-by-title-page',
@@ -30,8 +31,9 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
3031
protected browseService: BrowseService,
3132
protected dsoService: DSpaceObjectDataService,
3233
protected paginationService: PaginationService,
33-
protected router: Router) {
34-
super(route, browseService, dsoService, paginationService, router);
34+
protected router: Router,
35+
@Inject(APP_CONFIG) protected appConfig: AppConfig) {
36+
super(route, browseService, dsoService, paginationService, router, appConfig);
3537
}
3638

3739
ngOnInit(): void {
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
import { Config } from './config.interface';
22

33
/**
4-
* Config that determines how the dropdown list of years are created for browse-by-date components
4+
* Config that determines how the dropdown list of years are created for
5+
* browse-by-date components.
56
*/
67
export interface BrowseByConfig extends Config {
78
/**
8-
* The max amount of years to display using jumps of one year (current year - oneYearLimit)
9+
* The max amount of years to display using jumps of one year
10+
* (current year - oneYearLimit)
911
*/
1012
oneYearLimit: number;
1113

1214
/**
13-
* Limit for years to display using jumps of five years (current year - fiveYearLimit)
15+
* Limit for years to display using jumps of five years
16+
* (current year - fiveYearLimit)
1417
*/
1518
fiveYearLimit: number;
1619

1720
/**
18-
* The absolute lowest year to display in the dropdown when no lowest date can be found for all items
21+
* The absolute lowest year to display in the dropdown when no lowest date can
22+
* be found for all items.
1923
*/
2024
defaultLowerLimit: number;
25+
26+
/**
27+
* Number of entries in the viewport of a paginated browse-by list.
28+
* Rounded to the nearest size in the list of selectable sizes on the settings
29+
* menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
30+
*/
31+
pageSize: number;
2132
}

src/config/default-app-config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ export class DefaultAppConfig implements AppConfig {
209209
// Limit for years to display using jumps of five years (current year - fiveYearLimit)
210210
fiveYearLimit: 30,
211211
// The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
212-
defaultLowerLimit: 1900
212+
defaultLowerLimit: 1900,
213+
// The number of entries in a paginated browse results list.
214+
// Rounded to the nearest size in the list of selectable sizes on the
215+
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
216+
pageSize: 20
213217
};
214218

215219
communityList: CommunityListConfig = {

src/environments/environment.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ export const environment: BuildConfig = {
203203
fiveYearLimit: 30,
204204
// The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
205205
defaultLowerLimit: 1900,
206+
// The number of entries in a paginated browse results list.
207+
// Rounded to the nearest size in the list of selectable sizes on the
208+
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
209+
pageSize: 20,
206210
},
207211
communityList: {
208212
pageSize: 20

0 commit comments

Comments
 (0)