From d18f251f76afce9b4efd4b4815c3a50d04b7ebf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20G=C3=B3mez?= Date: Wed, 3 Jul 2024 23:13:13 +0200 Subject: [PATCH] Make the default tab for browsing communities and collections configurable --- config/config.example.yml | 6 ++++++ .../collection-page/collection-page-routes.ts | 6 +++++- src/app/community-page/community-page-routes.ts | 6 +++++- .../comcol-page-browse-by.component.ts | 16 ++++++++++++++-- src/assets/i18n/en.json5 | 4 ++++ src/assets/i18n/es.json5 | 6 ++++++ src/config/collection-page-config.interface.ts | 1 + src/config/community-page-config.interface.ts | 1 + src/config/default-app-config.ts | 2 ++ src/environments/environment.test.ts | 2 ++ 10 files changed, 46 insertions(+), 4 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index 93386274e63..1afad91d3da 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -325,12 +325,18 @@ item: # Community Page Config community: + # Default tab to be shown when browsing a Community. Valid values are: comcols, search, or browse_ + # must be any of the configured "browse by" fields, e.g., dateissued, author, title, or subject + defaultBrowseTab: search # Search tab config searchSection: showSidebar: true # Collection Page Config collection: + # Default tab to be shown when browsing a Collection. Valid values are: search, or browse_ + # must be any of the configured "browse by" fields, e.g., dateissued, author, title, or subject + defaultBrowseTab: search # Search tab config searchSection: showSidebar: true diff --git a/src/app/collection-page/collection-page-routes.ts b/src/app/collection-page/collection-page-routes.ts index f2dadc3fbe0..2e8f9e3f222 100644 --- a/src/app/collection-page/collection-page-routes.ts +++ b/src/app/collection-page/collection-page-routes.ts @@ -85,9 +85,13 @@ export const ROUTES: Route[] = [ component: ThemedCollectionPageComponent, children: [ { - path: '', + path: 'search', pathMatch: 'full', component: ComcolSearchSectionComponent, + resolve: { + breadcrumb: browseByI18nBreadcrumbResolver, + }, + data: { breadcrumbKey: 'collection.search' }, }, { path: 'browse/:id', diff --git a/src/app/community-page/community-page-routes.ts b/src/app/community-page/community-page-routes.ts index d9505c53b13..5ad9c3526e0 100644 --- a/src/app/community-page/community-page-routes.ts +++ b/src/app/community-page/community-page-routes.ts @@ -72,9 +72,13 @@ export const ROUTES: Route[] = [ component: ThemedCommunityPageComponent, children: [ { - path: '', + path: 'search', pathMatch: 'full', component: ComcolSearchSectionComponent, + resolve: { + breadcrumb: i18nBreadcrumbResolver, + }, + data: { breadcrumbKey: 'community.search' }, }, { path: 'subcoms-cols', diff --git a/src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts b/src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts index a7730ee7dda..6275a5ac388 100644 --- a/src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts +++ b/src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts @@ -5,6 +5,7 @@ import { } from '@angular/common'; import { Component, + Inject, Input, OnDestroy, OnInit, @@ -33,6 +34,7 @@ import { take, } from 'rxjs/operators'; +import { APP_CONFIG, AppConfig } from '../../../../config/app-config.interface'; import { getCollectionPageRoute } from '../../../collection-page/collection-page-routing-paths'; import { getCommunityPageRoute } from '../../../community-page/community-page-routing-paths'; import { BrowseService } from '../../../core/browse/browse.service'; @@ -82,6 +84,7 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit { subs: Subscription[] = []; constructor( + @Inject(APP_CONFIG) public appConfig: AppConfig, public router: Router, private browseService: BrowseService, ) { @@ -99,14 +102,14 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit { allOptions.push({ id: 'search', label: 'collection.page.browse.search.head', - routerLink: comColRoute, + routerLink: `${comColRoute}/search`, }); } else if (this.contentType === 'community') { comColRoute = getCommunityPageRoute(this.id); allOptions.push({ id: 'search', label: 'collection.page.browse.search.head', - routerLink: comColRoute, + routerLink: `${comColRoute}/search`, }); allOptions.push({ id: 'comcols', @@ -140,6 +143,15 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit { } } })); + + this.allOptions$.pipe( + take(1), + ).subscribe((allOptions: ComColPageNavOption[]) => { + if (!allOptions.find(o => o.routerLink === this.router.url?.split('?')[0])) { + var option = allOptions.find(o => o.id === this.appConfig[this.contentType].defaultBrowseTab); + void this.router.navigate([option.routerLink], { queryParams: option.params }); + } + }); } ngOnDestroy(): void { diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 8f20c657f94..78be56caa1a 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -1324,6 +1324,8 @@ "collection.page.news": "News", + "collection.search.breadcrumbs": "Search", + "collection.search.results.head": "Search Results", "collection.select.confirm": "Confirm selected", @@ -1562,6 +1564,8 @@ "community.all-lists.head": "Subcommunities and Collections", + "community.search.breadcrumbs": "Search", + "community.search.results.head": "Search Results", "community.sub-collection-list.head": "Collections in this Community", diff --git a/src/assets/i18n/es.json5 b/src/assets/i18n/es.json5 index 55962d25b5f..e359d605230 100644 --- a/src/assets/i18n/es.json5 +++ b/src/assets/i18n/es.json5 @@ -1929,6 +1929,9 @@ // "collection.page.news": "News", "collection.page.news": "Noticias", + // "collection.search.breadcrumbs": "Search", + "collection.search.breadcrumbs": "Buscar", + // "collection.select.confirm": "Confirm selected", "collection.select.confirm": "Confirmar seleccionado", @@ -2250,6 +2253,9 @@ // "community.all-lists.head": "Subcommunities and Collections", "community.all-lists.head": "Subcomunidades y colecciones", + // "community.search.breadcrumbs": "Search", + "community.search.breadcrumbs": "Buscar", + // "community.sub-collection-list.head": "Collections in this Community", "community.sub-collection-list.head": "Colecciones de esta comunidad", diff --git a/src/config/collection-page-config.interface.ts b/src/config/collection-page-config.interface.ts index 6b8352e686f..5aec06daea2 100644 --- a/src/config/collection-page-config.interface.ts +++ b/src/config/collection-page-config.interface.ts @@ -4,6 +4,7 @@ import { Config } from './config.interface'; * Collection Page Config */ export interface CollectionPageConfig extends Config { + defaultBrowseTab: string; searchSection: CollectionSearchSectionConfig; edit: { undoTimeout: number; diff --git a/src/config/community-page-config.interface.ts b/src/config/community-page-config.interface.ts index 268f4d6a5e3..72b859bffc8 100644 --- a/src/config/community-page-config.interface.ts +++ b/src/config/community-page-config.interface.ts @@ -4,6 +4,7 @@ import { Config } from './config.interface'; * Community Page Config */ export interface CommunityPageConfig extends Config { + defaultBrowseTab: string; searchSection: CommunitySearchSectionConfig; } diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index 2290955c8c7..0586a20009a 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -337,6 +337,7 @@ export class DefaultAppConfig implements AppConfig { // Community Page Config community: CommunityPageConfig = { + defaultBrowseTab: 'search', searchSection: { showSidebar: true, }, @@ -344,6 +345,7 @@ export class DefaultAppConfig implements AppConfig { // Collection Page Config collection: CollectionPageConfig = { + defaultBrowseTab: 'search', searchSection: { showSidebar: true, }, diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index c0de82e29af..3c24572e4de 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -267,11 +267,13 @@ export const environment: BuildConfig = { }, }, community: { + defaultBrowseTab: 'search', searchSection: { showSidebar: true, }, }, collection: { + defaultBrowseTab: 'search', searchSection: { showSidebar: true, },