Options
All
  • Public
  • Public/Protected
  • All
Menu

An abstract base class for nav menu. A nav menu may consist of one or more nav items (AbstractNavItem). The only difference between stadard menu (AbstractMenu) and nav menu is that the nav menu has a main purpose on navigation. It also automatically publishes an event to the ObservableManager on the topic "nav-menu.[sub-topic-name].navigate" when a navigation is performed. Furthermore, to remotely control the navigation on this nav menu instance at runtime without having direct object reference, you can use ObservableManager's topic "nav-menu.[sub-topic-name].cmd.navigate" to publish a navigation command to this nav menu.

author

shiorin, tee4cute

see

AbstractNavItem

see

INavigator

see

ObservableManager

Type parameters

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected bypass

bypass: boolean

Protected i18nKey

i18nKey: string

Protected i18nValue

i18nValue: any

Protected items

items: T[]

Protected navigateSubjects

navigateSubjects: Subject<any>[]

Protected observableMgr

observableMgr: ObservableManager

Protected options

options: any

Protected subTopicName

subTopicName: string

Static NAVIGATE_CMD_TOPIC_NAME

NAVIGATE_CMD_TOPIC_NAME: string = NAVIGATE_CMD_TOPIC_NAME

Static NAVIGATE_TOPIC_NAME

NAVIGATE_TOPIC_NAME: string = NAVIGATE_TOPIC_NAME

Methods

addItem

  • addItem(item: T): boolean
  • Add a new nav item into this nav menu. If there already is the given item in this nav menu, this method will do nothing and return false.

    Parameters

    • item: T

      A new nav item to be added into this nav menu.

    Returns boolean

    Returns true if the given item is added into this nav menu. Otherwise, returns false.

applyI18N

  • applyI18N(value: any): void

containsItem

  • containsItem(item: T): boolean
  • To check that the given item is in this nav menu or not.

    Parameters

    • item: T

      A nav item to check that it is in this nav menu or not.

    Returns boolean

    Returns true if the given item is in this nav menu.

Abstract doNavigate

  • doNavigate(item: T): Promise<boolean>
  • A method to perform the actual navigation, for example, changing a router's path, etc.

    Parameters

    • item: T

      A nav item to navigate to.

    Returns Promise<boolean>

    Returns a Promise which will be resolved when the navigation is done. The Promise's result will be a boolean value which its value will be true if the navigation is successful.

getActiveIndex

  • getActiveIndex(): number
  • Get an active nav item index of this nav menu.

    Returns number

    Returns -1 if there is no current active item. Otherwise, return the array index of current active item.

getActiveItem

  • getActiveItem(): T
  • Get an active nav item of this nav menu.

    Returns T

    Returns null if there is no current active item.

getI18NKey

  • getI18NKey(): string

getI18NValue

  • getI18NValue(): any

getItemByIndex

  • getItemByIndex(idx: number): T
  • Get a nav item (AbstractNavItem) from the given index (idx).

    Parameters

    • idx: number

      The index of nav item to get.

    Returns T

    Returns an instance of nav item (AbstractNavItem) at the specified index (idx). Returns null if the given index is out of range.

getItemByName

  • getItemByName(name: string): T
  • Get a nav item (AbstractNavItem) by the given name.

    Parameters

    • name: string

      The name of a nav item to get.

    Returns T

    Returns an instance of nav item (AbstractNavItem) with the given name. Returns null if not found.

getItemCount

  • getItemCount(): number
  • Get nav items count in this nav menu.

    Returns number

getItemIndex

  • getItemIndex(item: T): number
  • Get the index of the given nav item (item).

    Parameters

    • item: T

      The nav item to find index.

    Returns number

    Returns an index of the specified item. Returns -1 if not found.

getItemIndexByName

  • getItemIndexByName(name: string): number
  • Get the index of the given item name.

    Parameters

    • name: string

      The item name to find index.

    Returns number

    Returns an index of nav item having the specified name. Returns -1 if not found.

getItems

  • getItems(): T[]

getOptions

  • getOptions(): any

getSubTopicName

  • getSubTopicName(): string
  • Get ObservableManager's sub topic name associated with this nav menu.

    Returns string

Private initNavMenuEventTopics

  • initNavMenuEventTopics(navigate: string, navigateCmd: string): void
  • Parameters

    • navigate: string
    • navigateCmd: string

    Returns void

isBypassKey

  • isBypassKey(): boolean

navigateTo

  • navigateTo(item: T): Promise<boolean>
  • Navigate this nav menu to the specified nav item. This method returns Promise to support asynchronous execution. The result value of returned Promise is a boolean indicating the navigation result. The result value must be true if the navigation is successful. Otherwise, for example, if the given item does not exist, the result value will be false.

    Parameters

    • item: T

      The nav item to navigate to.

    Returns Promise<boolean>

    Returns a Promise which will be resolved when the navigation is done. The Promise's result will be a boolean value which its value will be true if the navigation is successful.

navigateToIndex

  • navigateToIndex(idx: number): Promise<boolean>
  • Navigate this nav menu to the specified index (idx). This method returns Promise to support asynchronous execution. The result value of returned Promise is a boolean indicating the navigation result. The result value must be true if the navigation is successful. Otherwise, the result value will be false.

    Parameters

    • idx: number

      The item index to navigate to.

    Returns Promise<boolean>

    Returns a Promise which will be resolved when the navigation is done. The Promise's result will be a boolean value which its value will be true if the navigation is successful.

navigateToName

  • navigateToName(name: string): Promise<boolean>
  • Navigate this nav menu to a nav item having the specified name. This method returns Promise to support asynchronous execution. The result value of returned Promise is a boolean indicating the navigation result. The result value must be true if the navigation is successful. Otherwise, for example, if the given item does not exist, the result value will be false.

    Parameters

    • name: string

      The name of a nav item to navigate to.

    Returns Promise<boolean>

    Returns a Promise which will be resolved when the navigation is done. The Promise's result will be a boolean value which its value will be true if the navigation is successful.

ngOnInit

  • ngOnInit(): void
  • Returns void

removeItem

  • removeItem(item: T): boolean
  • Remove the given item from this nav menu. If the given item is not in this nav menu, this method will do nothing and return false. If the item being removed is a current active item, this nav menu will be navigated to the first nav item.

    Parameters

    • item: T

      A nav item to be removed from this nav menu.

    Returns boolean

    Returns true if the given item is found and removed from this nav menu. Otherwise, returns false.

reset

  • reset(): void
  • Reset this nav menu. This method simply navigates back to the item at index 0.

    Returns void

setBypassKey

  • setBypassKey(bypass: boolean): void

setI18NKey

  • setI18NKey(i18nKey: string): void

setItems

  • setItems(items: T[]): void
  • Set nav items of this nav menu.

    Parameters

    • items: T[]

    Returns void

setOptions

  • setOptions(options: any): void

Static getNavigateCmdTopicName

  • getNavigateCmdTopicName(subTopicName: string): string
  • Get the navigation cmd topic name with the given subTopicName. The returning topic name will be prefixed by NAVIGATE_CMD_TOPIC_NAME.

    Parameters

    • subTopicName: string

    Returns string

Static getNavigateTopicName

  • getNavigateTopicName(subTopicName: string): string
  • Get the navigation event topic name with the given subTopicName. The returning topic name will be prefixed by NAVIGATE_TOPIC_NAME.

    Parameters

    • subTopicName: string

    Returns string

Generated using TypeDoc