Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,20 @@ 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
# When the default tab is not the 'search' tab, the search tab is moved to the last position
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
# When the default tab is not the 'search' tab, the search tab is moved to the last position
defaultBrowseTab: search
# Search tab config
searchSection:
showSidebar: true
Expand Down
9 changes: 9 additions & 0 deletions src/app/collection-page/collection-page-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ export const ROUTES: Route[] = [
pathMatch: 'full',
component: ComcolSearchSectionComponent,
},
{
path: 'search',
pathMatch: 'full',
component: ComcolSearchSectionComponent,
resolve: {
breadcrumb: i18nBreadcrumbResolver,
},
data: { breadcrumbKey: 'collection.search' },
},
{
path: 'browse/:id',
pathMatch: 'full',
Expand Down
9 changes: 9 additions & 0 deletions src/app/community-page/community-page-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ export const ROUTES: Route[] = [
pathMatch: 'full',
component: ComcolSearchSectionComponent,
},
{
path: 'search',
pathMatch: 'full',
component: ComcolSearchSectionComponent,
resolve: {
breadcrumb: i18nBreadcrumbResolver,
},
data: { breadcrumbKey: 'community.search' },
},
{
path: 'subcoms-cols',
pathMatch: 'full',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AsyncPipe } from '@angular/common';
import {
Component,
Inject,
Input,
OnDestroy,
OnInit,
Expand Down Expand Up @@ -29,6 +30,10 @@
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';
Expand Down Expand Up @@ -76,6 +81,7 @@
subs: Subscription[] = [];

constructor(
@Inject(APP_CONFIG) public appConfig: AppConfig,

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L84 was not covered by tests
public router: Router,
private browseService: BrowseService,
) {
Expand All @@ -93,14 +99,14 @@
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 All @@ -114,11 +120,24 @@
label: `browse.comcol.by.${config.id}`,
routerLink: `${comColRoute}/browse/${config.id}`,
})));

// When the default tab is not the "search" tab, the "search" tab is moved
// at the end of the tabs ribbon for aesthetics purposes.
if (this.appConfig[this.contentType].defaultBrowseTab !== 'search') {
allOptions.push(allOptions.shift());

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L127 was not covered by tests
}
}
return allOptions;
}),
);

let comColRoute: string;
if (this.contentType === 'collection') {
comColRoute = getCollectionPageRoute(this.id);

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L136 was not covered by tests
} else if (this.contentType === 'community') {
comColRoute = getCommunityPageRoute(this.id);

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L138 was not covered by tests
}

this.subs.push(combineLatest([
this.allOptions$,
this.router.events.pipe(
Expand All @@ -129,11 +148,29 @@
),
]).subscribe(([navOptions, url]: [ComColPageNavOption[], string]) => {
for (const option of navOptions) {
if (option.routerLink === url?.split('?')[0]) {
if (url?.split('?')[0] === comColRoute && option.id === this.appConfig[this.contentType].defaultBrowseTab) {
void this.router.navigate([option.routerLink], { queryParams: option.params });
break;

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L152 - L153 were not covered by tests
} else if (option.routerLink === url?.split('?')[0]) {
this.currentOption$.next(option);
break;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L156 was not covered by tests
}
}
}));

if (this.router.url?.split('?')[0] === comColRoute) {
this.allOptions$.pipe(

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L162 was not covered by tests
take(1),
).subscribe((allOptions: ComColPageNavOption[]) => {
for (const option of allOptions) {

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L165 was not covered by tests
if (option.id === this.appConfig[this.contentType].defaultBrowseTab) {
this.currentOption$.next(option[0]);
void this.router.navigate([option.routerLink], { queryParams: option.params });
break;

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L167 - L169 were not covered by tests
}
}
});
}
}

ngOnDestroy(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('ComcolSearchSectionComponent', () => {

beforeEach(async () => {
route = new ActivatedRouteStub();
route.parent = new ActivatedRouteStub();

await TestBed.configureTestingModule({
imports: [ComcolSearchSectionComponent],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class ComcolSearchSectionComponent implements OnInit {
}

ngOnInit(): void {
this.comcol$ = this.route.data.pipe(
this.comcol$ = this.route.parent.data.pipe(
map((data: Data) => (data.dso as RemoteData<Community | Collection>).payload),
);
this.showSidebar$ = this.comcol$.pipe(
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 @@ -1326,6 +1326,8 @@

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

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

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

"collection.select.confirm": "Confirm selected",
Expand Down Expand Up @@ -1564,6 +1566,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",
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 @@ -334,13 +334,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 @@ -272,11 +272,13 @@ export const environment: BuildConfig = {
},
},
community: {
defaultBrowseTab: 'search',
searchSection: {
showSidebar: true,
},
},
collection: {
defaultBrowseTab: 'search',
searchSection: {
showSidebar: true,
},
Expand Down
Loading