@@ -7,10 +7,8 @@ import { MenuItemType } from './shared/menu/menu-item-type.model';
77import { LinkMenuItemModel } from './shared/menu/menu-item/models/link.model' ;
88import { getFirstCompletedRemoteData } from './core/shared/operators' ;
99import { PaginatedList } from './core/data/paginated-list.model' ;
10- import { BrowseDefinition } from './core/shared/browse-definition.model' ;
1110import { RemoteData } from './core/data/remote-data' ;
1211import { TextMenuItemModel } from './shared/menu/menu-item/models/text.model' ;
13- import { BrowseService } from './core/browse/browse.service' ;
1412import { MenuService } from './shared/menu/menu.service' ;
1513import { filter , find , map , switchMap , take } from 'rxjs/operators' ;
1614import { hasValue } from './shared/empty.util' ;
@@ -45,6 +43,8 @@ import {
4543 ScriptDataService
4644} from './core/data/processes/script-data.service' ;
4745import { environment } from '../environments/environment' ;
46+ import { SectionDataService } from './core/layout/section-data.service' ;
47+ import { Section } from './core/layout/models/section.model' ;
4848
4949/**
5050 * Creates all of the app's menus
@@ -59,10 +59,10 @@ export class MenuResolver implements Resolve<boolean> {
5959 constructor (
6060 protected route : ActivatedRoute ,
6161 protected menuService : MenuService ,
62- protected browseService : BrowseService ,
6362 protected authorizationService : AuthorizationDataService ,
6463 protected modalService : NgbModal ,
6564 protected scriptDataService : ScriptDataService ,
65+ protected sectionDataService : SectionDataService ,
6666 ) {
6767 }
6868
@@ -114,41 +114,28 @@ export class MenuResolver implements Resolve<boolean> {
114114 }
115115
116116 // Read the different Browse-By types from config and add them to the browse menu
117- this . browseService . getBrowseDefinitions ( )
118- . pipe ( getFirstCompletedRemoteData < PaginatedList < BrowseDefinition > > ( ) )
119- . subscribe ( ( browseDefListRD : RemoteData < PaginatedList < BrowseDefinition > > ) => {
120- if ( browseDefListRD . hasSucceeded ) {
121- browseDefListRD . payload . page . forEach ( ( browseDef : BrowseDefinition ) => {
122- menuList . push ( {
123- id : `browse_global_by_${ browseDef . id } ` ,
124- parentID : 'browse_global' ,
125- active : false ,
126- visible : true ,
127- model : {
128- type : MenuItemType . LINK ,
129- text : `menu.section.browse_global_by_${ browseDef . id } ` ,
130- link : `/browse/${ browseDef . id } `
131- } as LinkMenuItemModel
132- } ) ;
117+ this . sectionDataService . findVisibleSections ( ) . pipe (
118+ getFirstCompletedRemoteData ( )
119+ ) . subscribe ( ( sectionDefListRD : RemoteData < PaginatedList < Section > > ) => {
120+ if ( sectionDefListRD . hasSucceeded ) {
121+ sectionDefListRD . payload . page . forEach ( ( section ) => {
122+ menuList . push ( {
123+ id : `explore_${ section . id } ` ,
124+ active : false ,
125+ visible : true ,
126+ model : {
127+ type : MenuItemType . LINK ,
128+ text : `menu.section.explore_${ section . id } ` ,
129+ link : `/explore/${ section . id } `
130+ } as LinkMenuItemModel
133131 } ) ;
134- menuList . push (
135- /* Browse */
136- {
137- id : 'browse_global' ,
138- active : false ,
139- visible : true ,
140- index : 1 ,
141- model : {
142- type : MenuItemType . TEXT ,
143- text : 'menu.section.browse_global'
144- } as TextMenuItemModel ,
145- }
146- ) ;
147- }
148- menuList . forEach ( ( menuSection ) => this . menuService . addSection ( MenuID . PUBLIC , Object . assign ( menuSection , {
149- shouldPersistOnRouteChange : true
150- } ) ) ) ;
151- } ) ;
132+
133+ } ) ;
134+ }
135+ menuList . forEach ( ( menuSection ) => this . menuService . addSection ( MenuID . PUBLIC , Object . assign ( menuSection , {
136+ shouldPersistOnRouteChange : true
137+ } ) ) ) ;
138+ } ) ;
152139
153140 this . createStatisticsMenu ( ) ;
154141 return this . waitForMenu$ ( MenuID . PUBLIC ) ;
0 commit comments