Skip to content

Commit cc80da9

Browse files
authored
Merge pull request DSpace#1955 from arvoConsultores/DS-1774
The number of bitstreams on item pages are now configurable
2 parents 74b27e4 + 599a5fd commit cc80da9

8 files changed

Lines changed: 48 additions & 14 deletions

File tree

config/config.example.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ item:
210210
undoTimeout: 10000 # 10 seconds
211211
# Show the item access status label in items lists
212212
showAccessStatuses: false
213+
bitstream:
214+
# Number of entries in the bitstream list in the item view page.
215+
# Rounded to the nearest size in the list of selectable sizes on the
216+
# settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
217+
pageSize: 5
213218

214219
# Collection Page Config
215220
collection:
@@ -298,4 +303,4 @@ info:
298303
# display in supported metadata fields. By default, only dc.description.abstract is supported.
299304
markdown:
300305
enabled: false
301-
mathjax: false
306+
mathjax: false

src/app/item-page/full/field-components/file-section/full-file-section.component.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { NotificationsService } from '../../../../shared/notifications/notificat
1818
import { NotificationsServiceStub } from '../../../../shared/testing/notifications-service.stub';
1919
import { PaginationService } from '../../../../core/pagination/pagination.service';
2020
import { PaginationServiceStub } from '../../../../shared/testing/pagination-service.stub';
21+
import { APP_CONFIG } from 'src/config/app-config.interface';
22+
import { environment } from 'src/environments/environment';
2123

2224
describe('FullFileSectionComponent', () => {
2325
let comp: FullFileSectionComponent;
@@ -69,7 +71,8 @@ describe('FullFileSectionComponent', () => {
6971
providers: [
7072
{ provide: BitstreamDataService, useValue: bitstreamDataService },
7173
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
72-
{ provide: PaginationService, useValue: paginationService }
74+
{ provide: PaginationService, useValue: paginationService },
75+
{ provide: APP_CONFIG, useValue: environment },
7376
],
7477

7578
schemas: [NO_ERRORS_SCHEMA]

src/app/item-page/full/field-components/file-section/full-file-section.component.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input, OnInit } from '@angular/core';
1+
import { Component, Inject, Input, OnInit } from '@angular/core';
22
import { Observable } from 'rxjs';
33
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
44

@@ -14,6 +14,7 @@ import { NotificationsService } from '../../../../shared/notifications/notificat
1414
import { TranslateService } from '@ngx-translate/core';
1515
import { hasValue, isEmpty } from '../../../../shared/empty.util';
1616
import { PaginationService } from '../../../../core/pagination/pagination.service';
17+
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface';
1718

1819
/**
1920
* This component renders the file section of the item
@@ -34,26 +35,26 @@ export class FullFileSectionComponent extends FileSectionComponent implements On
3435
originals$: Observable<RemoteData<PaginatedList<Bitstream>>>;
3536
licenses$: Observable<RemoteData<PaginatedList<Bitstream>>>;
3637

37-
pageSize = 5;
3838
originalOptions = Object.assign(new PaginationComponentOptions(), {
3939
id: 'obo',
4040
currentPage: 1,
41-
pageSize: this.pageSize
41+
pageSize: this.appConfig.item.bitstream.pageSize
4242
});
4343

4444
licenseOptions = Object.assign(new PaginationComponentOptions(), {
4545
id: 'lbo',
4646
currentPage: 1,
47-
pageSize: this.pageSize
47+
pageSize: this.appConfig.item.bitstream.pageSize
4848
});
4949

5050
constructor(
5151
bitstreamDataService: BitstreamDataService,
5252
protected notificationsService: NotificationsService,
5353
protected translateService: TranslateService,
54-
protected paginationService: PaginationService
54+
protected paginationService: PaginationService,
55+
@Inject(APP_CONFIG) protected appConfig: AppConfig
5556
) {
56-
super(bitstreamDataService, notificationsService, translateService);
57+
super(bitstreamDataService, notificationsService, translateService, appConfig);
5758
}
5859

5960
ngOnInit(): void {

src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { MetadataFieldWrapperComponent } from '../../../field-components/metadat
1717
import { createPaginatedList } from '../../../../shared/testing/utils.test';
1818
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
1919
import { NotificationsServiceStub } from '../../../../shared/testing/notifications-service.stub';
20+
import { APP_CONFIG } from 'src/config/app-config.interface';
21+
import { environment } from 'src/environments/environment';
2022

2123
describe('FileSectionComponent', () => {
2224
let comp: FileSectionComponent;
@@ -65,7 +67,8 @@ describe('FileSectionComponent', () => {
6567
declarations: [FileSectionComponent, VarDirective, FileSizePipe, MetadataFieldWrapperComponent],
6668
providers: [
6769
{ provide: BitstreamDataService, useValue: bitstreamDataService },
68-
{ provide: NotificationsService, useValue: new NotificationsServiceStub() }
70+
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
71+
{ provide: APP_CONFIG, useValue: environment }
6972
],
7073

7174
schemas: [NO_ERRORS_SCHEMA]

src/app/item-page/simple/field-components/file-section/file-section.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input, OnInit } from '@angular/core';
1+
import { Component, Inject, Input, OnInit } from '@angular/core';
22
import { BehaviorSubject } from 'rxjs';
33
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
44

@@ -10,6 +10,7 @@ import { PaginatedList } from '../../../../core/data/paginated-list.model';
1010
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
1111
import { TranslateService } from '@ngx-translate/core';
1212
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators';
13+
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface';
1314

1415
/**
1516
* This component renders the file section of the item
@@ -35,13 +36,15 @@ export class FileSectionComponent implements OnInit {
3536

3637
isLastPage: boolean;
3738

38-
pageSize = 5;
39+
pageSize: number;
3940

4041
constructor(
4142
protected bitstreamDataService: BitstreamDataService,
4243
protected notificationsService: NotificationsService,
43-
protected translateService: TranslateService
44+
protected translateService: TranslateService,
45+
@Inject(APP_CONFIG) protected appConfig: AppConfig
4446
) {
47+
this.pageSize = this.appConfig.item.bitstream.pageSize;
4548
}
4649

4750
ngOnInit(): void {

src/config/default-app-config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,13 @@ export class DefaultAppConfig implements AppConfig {
246246
undoTimeout: 10000 // 10 seconds
247247
},
248248
// Show the item access status label in items lists
249-
showAccessStatuses: false
249+
showAccessStatuses: false,
250+
bitstream: {
251+
// Number of entries in the bitstream list in the item view page.
252+
// Rounded to the nearest size in the list of selectable sizes on the
253+
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
254+
pageSize: 5
255+
}
250256
};
251257

252258
// Collection Page Config

src/config/item-config.interface.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@ export interface ItemConfig extends Config {
66
};
77
// This is used to show the access status label of items in results lists
88
showAccessStatuses: boolean;
9+
10+
bitstream: {
11+
// Number of entries in the bitstream list in the item view page.
12+
// Rounded to the nearest size in the list of selectable sizes on the
13+
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
14+
pageSize: number;
15+
}
916
}

src/environments/environment.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,13 @@ export const environment: BuildConfig = {
229229
undoTimeout: 10000 // 10 seconds
230230
},
231231
// Show the item access status label in items lists
232-
showAccessStatuses: false
232+
showAccessStatuses: false,
233+
bitstream: {
234+
// Number of entries in the bitstream list in the item view page.
235+
// Rounded to the nearest size in the list of selectable sizes on the
236+
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
237+
pageSize: 5
238+
}
233239
},
234240
collection: {
235241
edit: {

0 commit comments

Comments
 (0)