Extending the navigation bar
The navigation bar in the IBM® Sterling Store Engagement application currently has the global search and alerts menu options. You can extend the navigation bar to display other menu options according to your business requirements.
About this task
To develop the menu for the navigation bar, you must configure the menu and create a service to implement the menu actions.
Procedure
-
Configure the navigation bar menu.The
INavbarMenusConfiginterface is implemented by menu configuration. Place theINavbarMenusConfigconfiguration in thestore-customization-impl.tsfile to configure the navigation bar. You can place the service class in a shared module and configure it inshared-extension.module.ts.Note: Changes inshared-extension.module.tsmust be made only for adding new components or services.Configure the following fields to extend the navigation bar.
menuSequenceNumberThe
menuSequenceNumberfield specifies the order in which menu options are displayed. The menu options are displayed in ascending order. It is recommended that you give sequence number with a difference of five. You can add out-of-the-box icons without any overlaps.menuServiceThe
menuServiceservice implements the action that is to be performed when you click the menu. It must be of typeInjectionToken<INavbarMenu>.menuTIDThe
menuTIDis a unique identifier for a menu. You can add it to anHTMLtag to automate test cases.menuTitleBundleKeyThe
menuTitleBundleKeyis a bundle key of the text that is displayed along with the icon of the menu.resourceIdThe
resourceIdfield is a resource permission that is checked before the menu is displayed.menuIconClassThe
menuIconClassfield is the name of the menu icon class.
The following example shows how you can configure the fields.
export class StoreCustomizationImpl extends StoreCustomizationBase { static extensionNavbarMenusConfigList: INavbarMenusConfig[] = [ { menuSequenceNumber: 20, menuService: GLOBAL_SEARCH_MENU_SERVICE, menuTID: 'NavBarGlobalSearchAction', menuIconClass: 'app-icon-alert_16', menuTitleBundleKey: 'topNavBar.TITLE_AlertMenu', resourceId: 'ISF000001' } ]; } - Create a service to implement service actions.
The service class implements the
INavbarMenuinterface that has only one function,handleMenuAction. This service implements the actions that are to be performed when you click the menu. The service must be of typeInjectionToken<INavbarMenu>.The following example shows how you can implement service action.
@Injectable() export class GlobalSearchMenuService implements INavbarMenu { constructor(private modalService: NgbModal, private router: Router, private activeRoute: ActivatedRoute ) { } handleMenuAction(route) { console.log('global search menu called'); } } export const GLOBAL_SEARCH_MENU_SERVICE = new InjectionToken<INavbarMenu>('GlobalSearchMenuService');You can configure the token in Multidimensional in the following manner.
@NgModule({ imports: [], entryComponents: [], declarations: [], exports: [], providers: [ { provide: GLOBAL_SEARCH_MENU_SERVICE, // Previously defined token useClass: GlobalSearchMenuService, // The actual service } ] }) export class SharedExtensionModule { }