Skip to content

Drupal Menu and Menu item Druxt components, with support for the JSON:API Menu Items module.

DruxtMenuStore

View source on GitHub

DruxtMenuStore

Vuex module, registered under the druxtMenu namespace. The druxtMenu Vuex module.

Provides a Vuex state object, mutations, actions and getters for interacting Drupal JSON:API Menu Items.

See: The DruxtStore


get(vuexContext, context)

Get menu by name.

  • Fetches the menu items from the JSON:API endpoint.
  • Commits the menu items to the Vuex state object.
    Vuex Action => Mutates state propertyentities

Kind: action method of druxtMenu

ParamTypeDescription
vuexContextobjectThe Vuex action context.
vuexContext.commitfunctionCommits mutations to the store.
contextstring | objectThe menu name, or an object containing the menu name and optional settings and prefix properties.

Example

await this.$store.dispatch('druxtMenu/get', { name: 'main' })

addEntities

Adds specified Drupal JSON:API Menu Items data to the Vuex state object.

Kind: mutation method of druxtMenu

ParamTypeDescription
stateStateThe Vuex State object.
payloadaddEntitiesPayloadThe mutation payload.

Example

this.$store.commit('druxtMenu/addEntities', { entities, prefix })

flushEntities

Removes JSON:API menu item entities from the Vuex state object.

Kind: mutation method of druxtMenu

ParamTypeDescription
stateobjectThe Vuex state object.
payloadflushEntitiesPayloadThe mutation payload.

Example

// Flush all menu entities.
this.$store.commit('druxtMenu/flushEntities', {})

getEntitiesByFilter ⇒ function

Get entities by filter.

Returns: function - Filter function; takes { filter, prefix } where filter is a filter() method compatible function.

ParamTypeDescription
stateobjectThe Vuex state object.

Example

const items = this.$store.getters.getEntitiesByFilter(key => {
  return this.entities[key].attributes.menu_name === 'main'
})

State : object

The Vuex State object.

Kind: global typedef
Properties

NameTypeDescription
entitiesobjectThe Drupal JSON:API Menu Item entities.

addEntitiesPayload : object

Parameters for the addEntities mutation.

Kind: global typedef

ParamTypeDescription
entitiesArray.<object>The Drupal JSON:API Menu Item entities.
[prefix]string(Optional) The JSON:API endpoint prefix or langcode.

Example

{
  entities: [{}],
  prefix: 'en'
}

flushEntitiesPayload : object

Parameters for the flushEntities mutation.

Kind: global typedef

ParamTypeDescription
[prefix]string(Optional) The JSON:API endpoint prefix or langcode.

Example

{
  prefix: 'en'
}