Skip to content

Commit aa36284

Browse files
committed
[DSC-1454] Add environment configuration
1 parent be8c220 commit aa36284

7 files changed

Lines changed: 37 additions & 6 deletions

File tree

config/config.example.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ item:
308308
# Rounded to the nearest size in the list of selectable sizes on the
309309
# settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
310310
pageSize: 5
311+
# The maximum number of metadata values to add to the metatag list of the item page
312+
metatagLimit: 20
313+
# The maximum number of values for repeatable metadata to show in the full item
314+
metadataLimit: 20
311315

312316
# When the search results are retrieved, for each item type the metadata with a valid authority value are inspected.
313317
# Referenced items will be fetched with a find all by id strategy to avoid individual rest requests

src/app/core/metadata/metadata.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ export class MetadataService {
243243
*/
244244
private setCitationAuthorTags(): void {
245245
// limit author to first 20 entries to avoid issue with item page rendering
246-
const values: string[] = this.getMetaTagValues(['dc.author', 'dc.contributor.author', 'dc.creator']).slice(0, 20);
246+
const values: string[] = this.getMetaTagValues(['dc.author', 'dc.contributor.author', 'dc.creator'])
247+
.slice(0, this.appConfig.item.metatagLimit);
247248
this.addMetaTags('citation_author', values);
248249
}
249250

src/app/item-page/full/full-item-page.component.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { RemoteData } from '../../core/data/remote-data';
2323
import { ServerResponseService } from '../../core/services/server-response.service';
2424
import { SignpostingDataService } from '../../core/data/signposting-data.service';
2525
import { LinkHeadService } from '../../core/services/link-head.service';
26+
import { APP_CONFIG } from '../../../config/app-config.interface';
2627

2728
const mockItem: Item = Object.assign(new Item(), {
2829
bundles: createSuccessfulRemoteDataObject$(createPaginatedList([])),
@@ -145,6 +146,12 @@ describe('FullItemPageComponent', () => {
145146
type: 'test'
146147
};
147148

149+
const appConfig = {
150+
item: {
151+
metadataLimit: 20
152+
}
153+
};
154+
148155
beforeEach(waitForAsync(() => {
149156
authService = jasmine.createSpyObj('authService', {
150157
isAuthenticated: observableOf(true),
@@ -193,7 +200,8 @@ describe('FullItemPageComponent', () => {
193200
{ provide: ServerResponseService, useValue: serverResponseService },
194201
{ provide: SignpostingDataService, useValue: signpostingDataService },
195202
{ provide: LinkHeadService, useValue: linkHeadService },
196-
{ provide: PLATFORM_ID, useValue: 'server' }
203+
{ provide: PLATFORM_ID, useValue: 'server' },
204+
{ provide: APP_CONFIG, useValue: appConfig },
197205
],
198206
schemas: [NO_ERRORS_SCHEMA]
199207
}).overrideComponent(FullItemPageComponent, {

src/app/item-page/full/full-item-page.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { AuthorizationDataService } from '../../core/data/feature-authorization/
1919
import { ServerResponseService } from '../../core/services/server-response.service';
2020
import { SignpostingDataService } from '../../core/data/signposting-data.service';
2121
import { LinkHeadService } from '../../core/services/link-head.service';
22+
import { APP_CONFIG, AppConfig } from '../../../config/app-config.interface';
2223

2324
/**
2425
* This component renders a full item page.
@@ -40,7 +41,7 @@ export class FullItemPageComponent extends ItemPageComponent implements OnInit,
4041

4142
metadataMapLimit$: BehaviorSubject<Map<string, number>> = new BehaviorSubject<Map<string, number>>(new Map<string, number>());
4243

43-
limitSize = 20;
44+
limitSize = this.appConfig.item.metadataLimit;
4445

4546
/**
4647
* True when the itemRD has been originated from its workspaceite/workflowitem, false otherwise.
@@ -60,6 +61,7 @@ export class FullItemPageComponent extends ItemPageComponent implements OnInit,
6061
protected signpostingDataService: SignpostingDataService,
6162
protected linkHeadService: LinkHeadService,
6263
@Inject(PLATFORM_ID) protected platformId: string,
64+
@Inject(APP_CONFIG) private appConfig: AppConfig,
6365
) {
6466
super(route, router, items, authService, authorizationService, responseService, signpostingDataService, linkHeadService, platformId);
6567
}

src/config/default-app-config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,12 @@ export class DefaultAppConfig implements AppConfig {
337337
// Rounded to the nearest size in the list of selectable sizes on the
338338
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
339339
pageSize: 5
340-
}
340+
},
341+
// The maximum number of metadata values to add to the metatag list of the item page
342+
metatagLimit: 20,
343+
344+
// The maximum number of values for repeatable metadata to show in the full item
345+
metadataLimit: 20
341346
};
342347

343348
// When the search results are retrieved, for each item type the metadata with a valid authority value are inspected.

src/config/item-config.interface.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@ export interface ItemConfig extends Config {
1212
// Rounded to the nearest size in the list of selectable sizes on the
1313
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
1414
pageSize: number;
15-
}
15+
};
16+
17+
// The maximum number of metadata values to add to the metatag list of the item page
18+
metatagLimit: number;
19+
20+
// The maximum number of values for repeatable metadata to show in the full item
21+
metadataLimit: number;
1622
}

src/environments/environment.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,12 @@ export const environment: BuildConfig = {
281281
// Rounded to the nearest size in the list of selectable sizes on the
282282
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
283283
pageSize: 5
284-
}
284+
},
285+
// The maximum number of metadata values to add to the metatag list of the item page
286+
metatagLimit: 20,
287+
288+
// The maximum number of values for repeatable metadata to show in the full item
289+
metadataLimit: 20
285290
},
286291
collection: {
287292
edit: {

0 commit comments

Comments
 (0)