55} from '@angular/common' ;
66import {
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' ;
3638import { getCollectionPageRoute } from '../../../collection-page/collection-page-routing-paths' ;
3739import { getCommunityPageRoute } from '../../../community-page/community-page-routing-paths' ;
3840import { 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 {
0 commit comments