Skip to content

Commit 961e15f

Browse files
committed
Make the default tab for browsing communities and collections configurable
1 parent 3e6adbb commit 961e15f

10 files changed

Lines changed: 52 additions & 4 deletions

File tree

config/config.example.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,20 @@ item:
325325

326326
# Community Page Config
327327
community:
328+
# Default tab to be shown when browsing a Community. Valid values are: comcols, search, or browse_<field>
329+
# <field> must be any of the configured "browse by" fields, e.g., dateissued, author, title, or subject
330+
# When the default tab is not the 'search' tab, the search tab is moved to the last position
331+
defaultBrowseTab: search
328332
# Search tab config
329333
searchSection:
330334
showSidebar: true
331335

332336
# Collection Page Config
333337
collection:
338+
# Default tab to be shown when browsing a Collection. Valid values are: search, or browse_<field>
339+
# <field> must be any of the configured "browse by" fields, e.g., dateissued, author, title, or subject
340+
# When the default tab is not the 'search' tab, the search tab is moved to the last position
341+
defaultBrowseTab: search
334342
# Search tab config
335343
searchSection:
336344
showSidebar: true

src/app/collection-page/collection-page-routes.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,13 @@ export const ROUTES: Route[] = [
8585
component: ThemedCollectionPageComponent,
8686
children: [
8787
{
88-
path: '',
88+
path: 'search',
8989
pathMatch: 'full',
9090
component: ComcolSearchSectionComponent,
91+
resolve: {
92+
breadcrumb: browseByI18nBreadcrumbResolver,
93+
},
94+
data: { breadcrumbKey: 'collection.search' },
9195
},
9296
{
9397
path: 'browse/:id',

src/app/community-page/community-page-routes.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ export const ROUTES: Route[] = [
7272
component: ThemedCommunityPageComponent,
7373
children: [
7474
{
75-
path: '',
75+
path: 'search',
7676
pathMatch: 'full',
7777
component: ComcolSearchSectionComponent,
78+
resolve: {
79+
breadcrumb: i18nBreadcrumbResolver,
80+
},
81+
data: { breadcrumbKey: 'community.search' },
7882
},
7983
{
8084
path: 'subcoms-cols',

src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from '@angular/common';
66
import {
77
Component,
8+
Inject,
89
Input,
910
OnDestroy,
1011
OnInit,
@@ -33,6 +34,7 @@ import {
3334
take,
3435
} from 'rxjs/operators';
3536

37+
import { APP_CONFIG, AppConfig } from '../../../../config/app-config.interface';
3638
import { getCollectionPageRoute } from '../../../collection-page/collection-page-routing-paths';
3739
import { getCommunityPageRoute } from '../../../community-page/community-page-routing-paths';
3840
import { BrowseService } from '../../../core/browse/browse.service';
@@ -82,6 +84,7 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
8284
subs: Subscription[] = [];
8385

8486
constructor(
87+
@Inject(APP_CONFIG) public appConfig: AppConfig,
8588
public router: Router,
8689
private browseService: BrowseService,
8790
) {
@@ -99,14 +102,14 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
99102
allOptions.push({
100103
id: 'search',
101104
label: 'collection.page.browse.search.head',
102-
routerLink: comColRoute,
105+
routerLink: `${comColRoute}/search`,
103106
});
104107
} else if (this.contentType === 'community') {
105108
comColRoute = getCommunityPageRoute(this.id);
106109
allOptions.push({
107110
id: 'search',
108111
label: 'collection.page.browse.search.head',
109-
routerLink: comColRoute,
112+
routerLink: `${comColRoute}/search`,
110113
});
111114
allOptions.push({
112115
id: 'comcols',
@@ -120,6 +123,10 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
120123
label: `browse.comcol.by.${config.id}`,
121124
routerLink: `${comColRoute}/browse/${config.id}`,
122125
})));
126+
127+
if (this.appConfig[this.contentType].defaultBrowseTab !== 'search') {
128+
allOptions.push(allOptions.shift())
129+
}
123130
}
124131
return allOptions;
125132
}),
@@ -140,6 +147,15 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
140147
}
141148
}
142149
}));
150+
151+
this.allOptions$.pipe(
152+
take(1),
153+
).subscribe((allOptions: ComColPageNavOption[]) => {
154+
if (!allOptions.find(o => o.routerLink === this.router.url?.split('?')[0])) {
155+
var option = allOptions.find(o => o.id === this.appConfig[this.contentType].defaultBrowseTab);
156+
void this.router.navigate([option.routerLink], { queryParams: option.params });
157+
}
158+
});
143159
}
144160

145161
ngOnDestroy(): void {

src/assets/i18n/en.json5

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,8 @@
13241324

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

1327+
"collection.search.breadcrumbs": "Search",
1328+
13271329
"collection.search.results.head": "Search Results",
13281330

13291331
"collection.select.confirm": "Confirm selected",
@@ -1562,6 +1564,8 @@
15621564

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

1567+
"community.search.breadcrumbs": "Search",
1568+
15651569
"community.search.results.head": "Search Results",
15661570

15671571
"community.sub-collection-list.head": "Collections in this Community",

src/assets/i18n/es.json5

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,9 @@
19291929
// "collection.page.news": "News",
19301930
"collection.page.news": "Noticias",
19311931

1932+
// "collection.search.breadcrumbs": "Search",
1933+
"collection.search.breadcrumbs": "Buscar",
1934+
19321935
// "collection.select.confirm": "Confirm selected",
19331936
"collection.select.confirm": "Confirmar seleccionado",
19341937

@@ -2250,6 +2253,9 @@
22502253
// "community.all-lists.head": "Subcommunities and Collections",
22512254
"community.all-lists.head": "Subcomunidades y colecciones",
22522255

2256+
// "community.search.breadcrumbs": "Search",
2257+
"community.search.breadcrumbs": "Buscar",
2258+
22532259
// "community.sub-collection-list.head": "Collections in this Community",
22542260
"community.sub-collection-list.head": "Colecciones de esta comunidad",
22552261

src/config/collection-page-config.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Config } from './config.interface';
44
* Collection Page Config
55
*/
66
export interface CollectionPageConfig extends Config {
7+
defaultBrowseTab: string;
78
searchSection: CollectionSearchSectionConfig;
89
edit: {
910
undoTimeout: number;

src/config/community-page-config.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Config } from './config.interface';
44
* Community Page Config
55
*/
66
export interface CommunityPageConfig extends Config {
7+
defaultBrowseTab: string;
78
searchSection: CommunitySearchSectionConfig;
89
}
910

src/config/default-app-config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,15 @@ export class DefaultAppConfig implements AppConfig {
333333

334334
// Community Page Config
335335
community: CommunityPageConfig = {
336+
defaultBrowseTab: 'search',
336337
searchSection: {
337338
showSidebar: true,
338339
},
339340
};
340341

341342
// Collection Page Config
342343
collection: CollectionPageConfig = {
344+
defaultBrowseTab: 'search',
343345
searchSection: {
344346
showSidebar: true,
345347
},

src/environments/environment.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,13 @@ export const environment: BuildConfig = {
267267
},
268268
},
269269
community: {
270+
defaultBrowseTab: 'search',
270271
searchSection: {
271272
showSidebar: true,
272273
},
273274
},
274275
collection: {
276+
defaultBrowseTab: 'search',
275277
searchSection: {
276278
showSidebar: true,
277279
},

0 commit comments

Comments
 (0)