DruxtMenuStore
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
- druxtMenu
- action
- mutation
- getEntitiesByFilter ⇒
function
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
| Param | Type | Description |
|---|---|---|
| vuexContext | object | The Vuex action context. |
| vuexContext.commit | function | Commits mutations to the store. |
| context | string | object | The 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
| Param | Type | Description |
|---|---|---|
| state | State | The Vuex State object. |
| payload | addEntitiesPayload | The 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
| Param | Type | Description |
|---|---|---|
| state | object | The Vuex state object. |
| payload | flushEntitiesPayload | The 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.
| Param | Type | Description |
|---|---|---|
| state | object | The 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
| Name | Type | Description |
|---|---|---|
| entities | object | The Drupal JSON:API Menu Item entities. |
addEntitiesPayload : object
Parameters for the addEntities mutation.
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| entities | Array.<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
| Param | Type | Description |
|---|---|---|
| [prefix] | string | (Optional) The JSON:API endpoint prefix or langcode. |
Example
{
prefix: 'en'
}