diff --git a/config/environment.default.js b/config/environment.default.js index 5f60335652..84fd7405e2 100644 --- a/config/environment.default.js +++ b/config/environment.default.js @@ -153,25 +153,25 @@ module.exports = { // List of all the active Browse-By types // Adding a type will activate their Browse-By page and add them to the global navigation menu, as well as community and collection pages // Allowed fields and their purpose: - // metadata: The browse id to use for fetching info from the rest api + // id: The browse id to use for fetching info from the rest api // type: The type of Browse-By page to display // metadataField: The metadata-field used to create starts-with options (only necessary when the type is set to 'date') types: [ { - metadata: 'title', + id: 'title', type: 'title' }, { - metadata: 'dateissued', + id: 'dateissued', type: 'date', metadataField: 'dc.date.issued' }, { - metadata: 'author', + id: 'author', type: 'metadata' }, { - metadata: 'subject', + id: 'subject', type: 'metadata' } ] 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 ab22216afa..98d0cc9cd1 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 @@ -22,7 +22,7 @@ import { BrowseByType, rendersBrowseBy } from '../+browse-by-switcher/browse-by- }) /** * Component for browsing items by metadata definition of type 'date' - * A metadata definition is a short term used to describe one or multiple metadata fields. + * A metadata definition (a.k.a. browse id) is a short term used to describe one or multiple metadata fields. * An example would be 'dateissued' for 'dc.date.issued' */ @rendersBrowseBy(BrowseByType.Date) @@ -55,12 +55,12 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent { }) .subscribe((params) => { const metadataField = params.metadataField || this.defaultMetadataField; - this.metadata = params.metadata || this.defaultMetadata; + this.browseId = params.id || this.defaultBrowseId; this.startsWith = +params.startsWith || params.startsWith; - const searchOptions = browseParamsToOptions(params, Object.assign({}), this.sortConfig, this.metadata); + const searchOptions = browseParamsToOptions(params, Object.assign({}), this.sortConfig, this.browseId); this.updatePageWithItems(searchOptions, this.value); this.updateParent(params.scope); - this.updateStartsWithOptions(this.metadata, metadataField, params.scope); + this.updateStartsWithOptions(this.browseId, metadataField, params.scope); })); } diff --git a/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.html b/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.html index cf43f74eb0..c589c543d4 100644 --- a/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.html +++ b/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.html @@ -1,7 +1,7 @@
{ - this.metadata = params.metadata || this.defaultMetadata; + this.browseId = params.id || this.defaultBrowseId; this.value = +params.value || params.value || ''; this.startsWith = +params.startsWith || params.startsWith; - const searchOptions = browseParamsToOptions(params, this.paginationConfig, this.sortConfig, this.metadata); + const searchOptions = browseParamsToOptions(params, this.paginationConfig, this.sortConfig, this.browseId); if (isNotEmpty(this.value)) { this.updatePageWithItems(searchOptions, this.value); } else { diff --git a/src/app/+browse-by/+browse-by-switcher/browse-by-switcher.component.spec.ts b/src/app/+browse-by/+browse-by-switcher/browse-by-switcher.component.spec.ts index 35e8961e65..85805debe0 100644 --- a/src/app/+browse-by/+browse-by-switcher/browse-by-switcher.component.spec.ts +++ b/src/app/+browse-by/+browse-by-switcher/browse-by-switcher.component.spec.ts @@ -13,7 +13,7 @@ describe('BrowseBySwitcherComponent', () => { const types = ENV_CONFIG.browseBy.types; - const params = new BehaviorSubject(createParamsWithMetadata('initialValue')); + const params = new BehaviorSubject(createParamsWithId('initialValue')); const activatedRouteStub = { params: params @@ -37,9 +37,9 @@ describe('BrowseBySwitcherComponent', () => { })); types.forEach((type) => { - describe(`when switching to a browse-by page for "${type.metadata}"`, () => { + describe(`when switching to a browse-by page for "${type.id}"`, () => { beforeEach(() => { - params.next(createParamsWithMetadata(type.metadata)); + params.next(createParamsWithId(type.id)); fixture.detectChanges(); }); @@ -50,6 +50,6 @@ describe('BrowseBySwitcherComponent', () => { }); }); -export function createParamsWithMetadata(metadata) { - return { metadata: metadata }; +export function createParamsWithId(id) { + return { id: id }; } diff --git a/src/app/+browse-by/+browse-by-switcher/browse-by-switcher.component.ts b/src/app/+browse-by/+browse-by-switcher/browse-by-switcher.component.ts index 30a436d2d5..1ae8927f0a 100644 --- a/src/app/+browse-by/+browse-by-switcher/browse-by-switcher.component.ts +++ b/src/app/+browse-by/+browse-by-switcher/browse-by-switcher.component.ts @@ -30,8 +30,8 @@ export class BrowseBySwitcherComponent implements OnInit { ngOnInit(): void { this.browseByComponent = this.route.params.pipe( map((params) => { - const metadata = params.metadata; - return this.config.browseBy.types.find((config: BrowseByTypeConfig) => config.metadata === metadata); + const id = params.id; + return this.config.browseBy.types.find((config: BrowseByTypeConfig) => config.id === id); }), map((config: BrowseByTypeConfig) => getComponentByBrowseByType(config.type)) ); 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 92f9569d38..91713cd219 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 @@ -42,8 +42,8 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent { return Object.assign({}, params, queryParams, data); }) .subscribe((params) => { - this.metadata = params.metadata || this.defaultMetadata; - this.updatePageWithItems(browseParamsToOptions(params, this.paginationConfig, this.sortConfig, this.metadata), undefined); + this.browseId = params.id || this.defaultBrowseId; + this.updatePageWithItems(browseParamsToOptions(params, this.paginationConfig, this.sortConfig, this.browseId), undefined); this.updateParent(params.scope) })); this.updateStartsWithTextOptions(); diff --git a/src/app/+browse-by/browse-by-guard.spec.ts b/src/app/+browse-by/browse-by-guard.spec.ts index 30dd7b7e0a..da45437a78 100644 --- a/src/app/+browse-by/browse-by-guard.spec.ts +++ b/src/app/+browse-by/browse-by-guard.spec.ts @@ -12,14 +12,14 @@ describe('BrowseByGuard', () => { const name = 'An interesting DSO'; const title = 'Author'; const field = 'Author'; - const metadata = 'author'; + const id = 'author'; const metadataField = 'dc.contributor'; const scope = '1234-65487-12354-1235'; const value = 'Filter'; beforeEach(() => { dsoService = { - findById: (id: string) => observableOf({ payload: { name: name }, hasSucceeded: true }) + findById: (dsoId: string) => observableOf({ payload: { name: name }, hasSucceeded: true }) }; translateService = { @@ -35,7 +35,7 @@ describe('BrowseByGuard', () => { metadataField, }, params: { - metadata, + id, }, queryParams: { scope, @@ -48,7 +48,7 @@ describe('BrowseByGuard', () => { (canActivate) => { const result = { title, - metadata, + id, metadataField, collection: name, field, @@ -67,7 +67,7 @@ describe('BrowseByGuard', () => { metadataField, }, params: { - metadata, + id, }, queryParams: { scope @@ -80,7 +80,7 @@ describe('BrowseByGuard', () => { (canActivate) => { const result = { title, - metadata, + id, metadataField, collection: name, field, @@ -99,7 +99,7 @@ describe('BrowseByGuard', () => { metadataField, }, params: { - metadata, + id, }, queryParams: { value @@ -111,7 +111,7 @@ describe('BrowseByGuard', () => { (canActivate) => { const result = { title, - metadata, + id, metadataField, collection: '', field, diff --git a/src/app/+browse-by/browse-by-guard.ts b/src/app/+browse-by/browse-by-guard.ts index 520d23c772..3813f7e656 100644 --- a/src/app/+browse-by/browse-by-guard.ts +++ b/src/app/+browse-by/browse-by-guard.ts @@ -21,36 +21,36 @@ export class BrowseByGuard implements CanActivate { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { const title = route.data.title; - const metadata = route.params.metadata || route.queryParams.metadata || route.data.metadata; + const id = route.params.id || route.queryParams.id || route.data.id; let metadataField = route.data.metadataField; - if (hasNoValue(metadataField) && hasValue(metadata)) { - const config = this.config.browseBy.types.find((conf) => conf.metadata === metadata); + if (hasNoValue(metadataField) && hasValue(id)) { + const config = this.config.browseBy.types.find((conf) => conf.id === id); if (hasValue(config) && hasValue(config.metadataField)) { metadataField = config.metadataField; } } const scope = route.queryParams.scope; const value = route.queryParams.value; - const metadataTranslated = this.translate.instant('browse.metadata.' + metadata); + const metadataTranslated = this.translate.instant('browse.metadata.' + id); if (hasValue(scope)) { const dsoAndMetadata$ = this.dsoService.findById(scope).pipe(getSucceededRemoteData()); return dsoAndMetadata$.pipe( map((dsoRD) => { const name = dsoRD.payload.name; - route.data = this.createData(title, metadata, metadataField, name, metadataTranslated, value); + route.data = this.createData(title, id, metadataField, name, metadataTranslated, value); return true; }) ); } else { - route.data = this.createData(title, metadata, metadataField, '', metadataTranslated, value); + route.data = this.createData(title, id, metadataField, '', metadataTranslated, value); return observableOf(true); } } - private createData(title, metadata, metadataField, collection, field, value) { + private createData(title, id, metadataField, collection, field, value) { return { title: title, - metadata: metadata, + id: id, metadataField: metadataField, collection: collection, field: field, diff --git a/src/app/+browse-by/browse-by-routing.module.ts b/src/app/+browse-by/browse-by-routing.module.ts index 0b20cd4466..e549c0f4e6 100644 --- a/src/app/+browse-by/browse-by-routing.module.ts +++ b/src/app/+browse-by/browse-by-routing.module.ts @@ -6,7 +6,7 @@ import { BrowseBySwitcherComponent } from './+browse-by-switcher/browse-by-switc @NgModule({ imports: [ RouterModule.forChild([ - { path: ':metadata', component: BrowseBySwitcherComponent, canActivate: [BrowseByGuard], data: { title: 'browse.title' } } + { path: ':id', component: BrowseBySwitcherComponent, canActivate: [BrowseByGuard], data: { title: 'browse.title' } } ]) ] }) diff --git a/src/app/navbar/navbar.component.ts b/src/app/navbar/navbar.component.ts index fc22529cab..1a20a6b12f 100644 --- a/src/app/navbar/navbar.component.ts +++ b/src/app/navbar/navbar.component.ts @@ -82,14 +82,14 @@ export class NavbarComponent extends MenuComponent implements OnInit { const types = this.config.browseBy.types; types.forEach((typeConfig) => { menuList.push({ - id: `browse_global_by_${typeConfig.metadata}`, + id: `browse_global_by_${typeConfig.id}`, parentID: 'browse_global', active: false, visible: true, model: { type: MenuItemType.LINK, - text: `menu.section.browse_global_by_${typeConfig.metadata}`, - link: `/browse/${typeConfig.metadata}` + text: `menu.section.browse_global_by_${typeConfig.id}`, + link: `/browse/${typeConfig.id}` } as LinkMenuItemModel }); }); diff --git a/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.html b/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.html index 9165471843..1c73fbb3df 100644 --- a/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.html +++ b/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.html @@ -1,6 +1,6 @@

{{'browse.comcol.head' | translate}}

diff --git a/src/config/browse-by-type-config.interface.ts b/src/config/browse-by-type-config.interface.ts index 92e3af20c0..97d3acbe25 100644 --- a/src/config/browse-by-type-config.interface.ts +++ b/src/config/browse-by-type-config.interface.ts @@ -9,7 +9,7 @@ export interface BrowseByTypeConfig extends Config { * The browse id used for fetching browse data from the rest api * e.g. author */ - metadata: string; + id: string; /** * The type of Browse-By page to render