Skip to content

Commit

Permalink
Make the default tab for browsing communities and collections configu…
Browse files Browse the repository at this point in the history
…rable
  • Loading branch information
abelgomez committed Jul 3, 2024
1 parent f99a336 commit d18f251
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 4 deletions.
6 changes: 6 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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_<field>
# <field> 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_<field>
# <field> must be any of the configured "browse by" fields, e.g., dateissued, author, title, or subject
defaultBrowseTab: search
# Search tab config
searchSection:
showSidebar: true
Expand Down
6 changes: 5 additions & 1 deletion src/app/collection-page/collection-page-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 5 additions & 1 deletion src/app/community-page/community-page-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@angular/common';
import {
Component,
Inject,
Input,
OnDestroy,
OnInit,
Expand Down Expand Up @@ -33,6 +34,7 @@ import {
take,
} from 'rxjs/operators';

import { APP_CONFIG, AppConfig } from '../../../../config/app-config.interface';

Check failure on line 37 in src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Imports must be broken into multiple lines if there are more than 1 elements

Check failure on line 37 in src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Imports must be broken into multiple lines if there are more than 1 elements
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';
Expand Down Expand Up @@ -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,
) {
Expand All @@ -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',
Expand Down Expand Up @@ -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);

Check failure on line 151 in src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Unexpected var, use let or const instead

Check failure on line 151 in src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Unexpected var, use let or const instead
void this.router.navigate([option.routerLink], { queryParams: option.params });
}
});
}

ngOnDestroy(): void {
Expand Down
4 changes: 4 additions & 0 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,8 @@

"collection.page.news": "News",

"collection.search.breadcrumbs": "Search",

"collection.search.results.head": "Search Results",

"collection.select.confirm": "Confirm selected",
Expand Down Expand Up @@ -1562,6 +1564,8 @@

"community.all-lists.head": "Subcommunities and Collections",

"community.search.breadcrumbs": "Search",

Check failure on line 1568 in src/assets/i18n/en.json5

View workflow job for this annotation

GitHub Actions / tests (18.x)

Trailing spaces not allowed

Check failure on line 1568 in src/assets/i18n/en.json5

View workflow job for this annotation

GitHub Actions / tests (20.x)

Trailing spaces not allowed
"community.search.results.head": "Search Results",

"community.sub-collection-list.head": "Collections in this Community",
Expand Down
6 changes: 6 additions & 0 deletions src/assets/i18n/es.json5
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down Expand Up @@ -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",

Expand Down
1 change: 1 addition & 0 deletions src/config/collection-page-config.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Config } from './config.interface';
* Collection Page Config
*/
export interface CollectionPageConfig extends Config {
defaultBrowseTab: string;
searchSection: CollectionSearchSectionConfig;
edit: {
undoTimeout: number;
Expand Down
1 change: 1 addition & 0 deletions src/config/community-page-config.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Config } from './config.interface';
* Community Page Config
*/
export interface CommunityPageConfig extends Config {
defaultBrowseTab: string;
searchSection: CommunitySearchSectionConfig;
}

Expand Down
2 changes: 2 additions & 0 deletions src/config/default-app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,15 @@ export class DefaultAppConfig implements AppConfig {

// Community Page Config
community: CommunityPageConfig = {
defaultBrowseTab: 'search',
searchSection: {
showSidebar: true,
},
};

// Collection Page Config
collection: CollectionPageConfig = {
defaultBrowseTab: 'search',
searchSection: {
showSidebar: true,
},
Expand Down
2 changes: 2 additions & 0 deletions src/environments/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,13 @@ export const environment: BuildConfig = {
},
},
community: {
defaultBrowseTab: 'search',
searchSection: {
showSidebar: true,
},
},
collection: {
defaultBrowseTab: 'search',
searchSection: {
showSidebar: true,
},
Expand Down

0 comments on commit d18f251

Please sign in to comment.