diff --git a/config/environment.default.js b/config/environment.default.js index 804d80b0f2..84fd7405e2 100644 --- a/config/environment.default.js +++ b/config/environment.default.js @@ -149,7 +149,32 @@ module.exports = { // 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, + // 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: + // 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: [ + { + id: 'title', + type: 'title' + }, + { + id: 'dateissued', + type: 'date', + metadataField: 'dc.date.issued' + }, + { + id: 'author', + type: 'metadata' + }, + { + id: 'subject', + type: 'metadata' + } + ] }, item: { edit: { diff --git a/resources/i18n/en.json b/resources/i18n/en.json index a066ffe9d0..e53ea9f2e8 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -781,7 +781,7 @@ "control_panel": "Control Panel", "browse_global": "All of DSpace", "browse_global_communities_and_collections": "Communities & Collections", - "browse_global_by_issue_date": "By Issue Date", + "browse_global_by_dateissued": "By Issue Date", "browse_global_by_author": "By Author", "browse_global_by_title": "By Title", "browse_global_by_subject": "By Subject", 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 2acd96adb0..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 @@ -13,6 +13,7 @@ import { BrowseService } from '../../core/browse/browse.service'; import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service'; import { GLOBAL_CONFIG, GlobalConfig } from '../../../config'; import { StartsWithType } from '../../shared/starts-with/starts-with-decorator'; +import { BrowseByType, rendersBrowseBy } from '../+browse-by-switcher/browse-by-decorator'; @Component({ selector: 'ds-browse-by-date-page', @@ -21,9 +22,10 @@ import { StartsWithType } from '../../shared/starts-with/starts-with-decorator'; }) /** * 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) export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent { /** @@ -53,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); })); } @@ -78,8 +80,9 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent { let lowerLimit = this.config.browseBy.defaultLowerLimit; if (hasValue(firstItemRD.payload)) { const date = firstItemRD.payload.firstMetadataValue(metadataField); - if (hasValue(date) && hasValue(+date.split('-')[0])) { - lowerLimit = +date.split('-')[0]; + if (hasValue(date)) { + const dateObj = new Date(date); + lowerLimit = dateObj.getFullYear(); } } const options = []; 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 @@