druxt-menu 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -217,7 +217,7 @@ export default {
|
|
|
217
217
|
*/
|
|
218
218
|
entities() {
|
|
219
219
|
this.$forceUpdate()
|
|
220
|
-
}
|
|
220
|
+
},
|
|
221
221
|
},
|
|
222
222
|
|
|
223
223
|
methods: {
|
|
@@ -242,8 +242,11 @@ export default {
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
const entities = this.getEntitiesByFilter(
|
|
246
|
-
|
|
245
|
+
const entities = this.getEntitiesByFilter({
|
|
246
|
+
filter: (key) => {
|
|
247
|
+
return this.entities[this.lang][key].attributes.menu_name === this.name && this.entities[this.lang][key].attributes.parent === parent
|
|
248
|
+
},
|
|
249
|
+
prefix: this.lang
|
|
247
250
|
})
|
|
248
251
|
|
|
249
252
|
for (const key in entities) {
|
|
@@ -281,7 +284,11 @@ export default {
|
|
|
281
284
|
*/
|
|
282
285
|
async fetchData(settings) {
|
|
283
286
|
if (!this.value) {
|
|
284
|
-
await this.getMenu({
|
|
287
|
+
await this.getMenu({
|
|
288
|
+
name: this.name,
|
|
289
|
+
settings: settings.query,
|
|
290
|
+
prefix: this.lang
|
|
291
|
+
})
|
|
285
292
|
this.model = this.getMenuItems()
|
|
286
293
|
}
|
|
287
294
|
},
|
|
@@ -326,11 +333,12 @@ export default {
|
|
|
326
333
|
*/
|
|
327
334
|
slots(h) {
|
|
328
335
|
return {
|
|
329
|
-
default: (attrs) => this.items.map((item) => h('DruxtMenuItem', {
|
|
336
|
+
default: (attrs) => (this.items || []).map((item) => h('DruxtMenuItem', {
|
|
330
337
|
attrs,
|
|
331
338
|
key: item.entity.id,
|
|
332
339
|
props: {
|
|
333
340
|
item,
|
|
341
|
+
langcode: this.lang
|
|
334
342
|
},
|
|
335
343
|
})),
|
|
336
344
|
}
|
|
@@ -345,13 +353,17 @@ export default {
|
|
|
345
353
|
*
|
|
346
354
|
* @example @lang js
|
|
347
355
|
* [
|
|
356
|
+
* 'DruxtMenu[Name][Langcode]',
|
|
348
357
|
* 'DruxtMenu[Name]',
|
|
349
|
-
* '
|
|
358
|
+
* 'DruxtMenu[Default][Langcode]',
|
|
359
|
+
* 'DruxtMenu[Default]',
|
|
350
360
|
* ]
|
|
351
361
|
*
|
|
352
362
|
* @example <caption>Main menu (default)</caption> @lang js
|
|
353
363
|
* [
|
|
364
|
+
* 'DruxtMenuMainEn',
|
|
354
365
|
* 'DruxtMenuMain',
|
|
366
|
+
* 'DruxtMenuDefaultEn',
|
|
355
367
|
* 'DruxtMenuDefault',
|
|
356
368
|
* ]
|
|
357
369
|
*/
|
|
@@ -7,11 +7,7 @@
|
|
|
7
7
|
export default {
|
|
8
8
|
name: 'DruxtMenuItem',
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* Vue.js Properties.
|
|
12
|
-
*
|
|
13
|
-
* @see {@link https://vuejs.org/v2/guide/components-props.html}
|
|
14
|
-
*/
|
|
10
|
+
/** */
|
|
15
11
|
props: {
|
|
16
12
|
/**
|
|
17
13
|
* The menu item.
|
|
@@ -25,63 +21,37 @@ export default {
|
|
|
25
21
|
}
|
|
26
22
|
},
|
|
27
23
|
|
|
28
|
-
/**
|
|
29
|
-
* Vue.js Computed properties.
|
|
30
|
-
*/
|
|
24
|
+
/** */
|
|
31
25
|
computed: {
|
|
32
26
|
/**
|
|
33
27
|
* Current items Active state.
|
|
34
28
|
*
|
|
35
29
|
* @type {boolean}
|
|
36
30
|
*/
|
|
37
|
-
active()
|
|
38
|
-
return this.menu.trail.includes(this.item.entity.attributes.url)
|
|
39
|
-
},
|
|
31
|
+
active: ({ item, menu }) => menu.trail.includes(item.entity.attributes.url),
|
|
40
32
|
|
|
41
33
|
/**
|
|
42
34
|
* Class(es) for the menu item.
|
|
43
35
|
*
|
|
44
36
|
* @type {string}
|
|
45
37
|
*/
|
|
46
|
-
classes() {
|
|
47
|
-
const classes = [
|
|
38
|
+
classes: ({ active, menu, template }) => {
|
|
39
|
+
const classes = [menu[`${template}Class`]]
|
|
48
40
|
|
|
49
|
-
if (
|
|
41
|
+
if (active) classes.push('active-trail')
|
|
50
42
|
|
|
51
43
|
return classes.join(' ')
|
|
52
44
|
},
|
|
53
45
|
|
|
54
|
-
/**
|
|
55
|
-
* The menu item template type.
|
|
56
|
-
*
|
|
57
|
-
* @type {string}
|
|
58
|
-
*/
|
|
59
|
-
template() {
|
|
60
|
-
return this.item.children.length ? 'parent' : 'item'
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The `to` attribute for the menu item.
|
|
65
|
-
*
|
|
66
|
-
* @type {object}
|
|
67
|
-
*/
|
|
68
|
-
to() {
|
|
69
|
-
const parts = this.item.entity.attributes.link.uri.split(':')
|
|
70
|
-
const type = parts[0]
|
|
71
|
-
const path = parts[1]
|
|
72
|
-
|
|
73
|
-
return { path, type }
|
|
74
|
-
},
|
|
75
|
-
|
|
76
46
|
/**
|
|
77
47
|
* The parent DruxtMenu component, if present.
|
|
78
48
|
*
|
|
79
49
|
* @type {@object}
|
|
80
50
|
*/
|
|
81
|
-
menu() {
|
|
51
|
+
menu: ({ $parent }) => {
|
|
82
52
|
let menu = false
|
|
83
53
|
|
|
84
|
-
let item =
|
|
54
|
+
let item = $parent
|
|
85
55
|
while (item && !menu) {
|
|
86
56
|
if (item.$options.name === 'DruxtMenu') menu = item
|
|
87
57
|
if (item.$options.extends && item.$options.extends.name === 'DruxtMenu') menu = item
|
|
@@ -90,22 +60,58 @@ export default {
|
|
|
90
60
|
}
|
|
91
61
|
|
|
92
62
|
return menu
|
|
93
|
-
}
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The menu item template type.
|
|
67
|
+
*
|
|
68
|
+
* @type {string}
|
|
69
|
+
*/
|
|
70
|
+
template: ({ item }) => (item.children || []).length ? 'parent' : 'item',
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The `to` attribute for the menu item.
|
|
74
|
+
*
|
|
75
|
+
* @type {object}
|
|
76
|
+
*/
|
|
77
|
+
to: ({ item }) =>
|
|
78
|
+
((item.entity.attributes.link || {}).uri || '').startsWith('internal:')
|
|
79
|
+
&& (!item.entity.attributes.route || item.entity.attributes.route.name)
|
|
80
|
+
? { path: item.entity.attributes.link.uri.split(':')[1] }
|
|
81
|
+
: false
|
|
94
82
|
},
|
|
95
83
|
|
|
96
84
|
methods: {
|
|
85
|
+
/**
|
|
86
|
+
* Returns a menu link components.
|
|
87
|
+
*/
|
|
88
|
+
getLink(h, entity = {}) {
|
|
89
|
+
if (!entity.attributes) return false
|
|
90
|
+
|
|
91
|
+
// Render external links.
|
|
92
|
+
if (!this.to) {
|
|
93
|
+
return h('a',
|
|
94
|
+
{ domProps: { href: entity.attributes.url || (entity.attributes.link || {}).uri }},
|
|
95
|
+
entity.attributes.title
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Render internal links.
|
|
100
|
+
return h('nuxt-link',
|
|
101
|
+
{ props: { to: this.to } },
|
|
102
|
+
entity.attributes.title
|
|
103
|
+
)
|
|
104
|
+
},
|
|
105
|
+
|
|
97
106
|
/**
|
|
98
107
|
* The menu item template functions.
|
|
99
108
|
*/
|
|
100
|
-
templates
|
|
109
|
+
templates(h) {
|
|
101
110
|
return {
|
|
102
111
|
// Default template for Item slot.
|
|
103
|
-
item: ({ item: { entity } }) =>
|
|
104
|
-
this.menu.itemComponent,
|
|
112
|
+
item: ({ item: { entity } }) => h(this.menu.itemComponent,
|
|
105
113
|
{ class: this.classes },
|
|
106
|
-
[
|
|
107
|
-
createElement('nuxt-link', { props: { to: this.to } }, entity.attributes.title)
|
|
108
|
-
]
|
|
114
|
+
[this.getLink(h, entity)]
|
|
109
115
|
),
|
|
110
116
|
|
|
111
117
|
// Default template for Parent slot.
|
|
@@ -113,14 +119,17 @@ export default {
|
|
|
113
119
|
const childElements = []
|
|
114
120
|
|
|
115
121
|
for (const key in children) {
|
|
116
|
-
childElements.push(
|
|
122
|
+
childElements.push(h('druxt-menu-item', { props: { item: children[key] }}))
|
|
117
123
|
}
|
|
118
124
|
|
|
119
|
-
return
|
|
125
|
+
return h(this.menu.parentComponent,
|
|
120
126
|
{ class: this.classes },
|
|
121
127
|
[
|
|
122
|
-
|
|
123
|
-
|
|
128
|
+
this.getLink(h, entity),
|
|
129
|
+
h(this.menu.parentWrapperComponent,
|
|
130
|
+
{ class: this.menu.parenWrapperClass },
|
|
131
|
+
childElements
|
|
132
|
+
)
|
|
124
133
|
]
|
|
125
134
|
)
|
|
126
135
|
},
|
|
@@ -133,9 +142,9 @@ export default {
|
|
|
133
142
|
/**
|
|
134
143
|
* The Vue.js render function.
|
|
135
144
|
*/
|
|
136
|
-
render
|
|
145
|
+
render(h) {
|
|
137
146
|
if (!this.menu) return false
|
|
138
|
-
return this.templates(
|
|
147
|
+
return this.templates(h)[this.template](this)
|
|
139
148
|
}
|
|
140
149
|
}
|
|
141
150
|
</script>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<DruxtMenu
|
|
3
|
+
<DruxtMenu
|
|
4
|
+
:langcode="langcode"
|
|
5
|
+
:name="name"
|
|
6
|
+
/>
|
|
4
7
|
</div>
|
|
5
8
|
</template>
|
|
6
9
|
|
|
@@ -20,7 +23,7 @@ import { DruxtBlocksBlockMixin } from 'druxt-blocks'
|
|
|
20
23
|
* uuid="d4efd803-94af-4742-bc94-ea4360085b74"
|
|
21
24
|
* />
|
|
22
25
|
*
|
|
23
|
-
* @see {@link https://blocks.druxtjs.org/api/components/DruxtBlock
|
|
26
|
+
* @see {@link https://blocks.druxtjs.org/api/components/DruxtBlock|DruxtBlock}
|
|
24
27
|
*/
|
|
25
28
|
export default {
|
|
26
29
|
name: 'DruxtBlockSystemMenuBlock',
|
|
@@ -28,7 +31,7 @@ export default {
|
|
|
28
31
|
/**
|
|
29
32
|
* Vue.js Mixins.
|
|
30
33
|
*
|
|
31
|
-
* @see {@link https://blocks.druxtjs.org/api/mixins/block
|
|
34
|
+
* @see {@link https://blocks.druxtjs.org/api/mixins/block|DruxtBlocksBlockMixin}
|
|
32
35
|
*/
|
|
33
36
|
mixins: [DruxtBlocksBlockMixin],
|
|
34
37
|
|
package/dist/druxt-menu.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolve, join } from 'path';
|
|
2
2
|
import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
|
|
3
3
|
import { DruxtClient } from 'druxt';
|
|
4
|
+
import Vue from 'vue';
|
|
4
5
|
|
|
5
6
|
const titleFn = (parts) => parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1).replace(/_/g, " ")).join("/");
|
|
6
7
|
async function DruxtMenuStorybook({ stories }) {
|
|
@@ -85,18 +86,18 @@ class DruxtMenu {
|
|
|
85
86
|
}
|
|
86
87
|
return query;
|
|
87
88
|
}
|
|
88
|
-
async get(menuName, settings) {
|
|
89
|
+
async get(menuName, settings, prefix) {
|
|
89
90
|
if (this.options.menu.jsonApiMenuItems) {
|
|
90
|
-
return this.getJsonApiMenuItems(menuName, settings);
|
|
91
|
+
return this.getJsonApiMenuItems(menuName, settings, prefix);
|
|
91
92
|
}
|
|
92
|
-
return this.getMenuLinkContent(menuName, settings);
|
|
93
|
+
return this.getMenuLinkContent(menuName, settings, prefix);
|
|
93
94
|
}
|
|
94
|
-
async getMenuLinkContent(menuName, settings) {
|
|
95
|
+
async getMenuLinkContent(menuName, settings, prefix) {
|
|
95
96
|
const resource = "menu_link_content--menu_link_content";
|
|
96
97
|
const requiredFields = ["bundle", "link", "menu_name", "parent", "title", "weight"];
|
|
97
98
|
const query = this.buildQuery(resource, menuName, requiredFields, settings);
|
|
98
99
|
const entities = [];
|
|
99
|
-
const collections = await this.druxt.getCollectionAll(resource, query);
|
|
100
|
+
const collections = await this.druxt.getCollectionAll(resource, query, prefix);
|
|
100
101
|
for (const collection of collections) {
|
|
101
102
|
for (const entity of collection.data) {
|
|
102
103
|
entities.push(entity);
|
|
@@ -104,12 +105,14 @@ class DruxtMenu {
|
|
|
104
105
|
}
|
|
105
106
|
return { entities };
|
|
106
107
|
}
|
|
107
|
-
async getJsonApiMenuItems(menuName, settings) {
|
|
108
|
+
async getJsonApiMenuItems(menuName, settings, prefix) {
|
|
108
109
|
const menuItemsResource = `menu_items--${menuName}`;
|
|
109
110
|
const resource = "menu_link_content--menu_link_content";
|
|
110
111
|
const requiredFields = ["menu_name", "parent", "title", "url", "weight"];
|
|
111
|
-
await this.druxt.getIndex();
|
|
112
|
-
this.druxt.index[menuItemsResource]
|
|
112
|
+
await this.druxt.getIndex(void 0, prefix);
|
|
113
|
+
if (!(this.druxt.index[prefix][menuItemsResource] || {}).href) {
|
|
114
|
+
this.druxt.index[prefix][menuItemsResource] = { href: `${prefix || ""}${this.druxt.options.endpoint}/menu_items/${menuName}` };
|
|
115
|
+
}
|
|
113
116
|
const query = this.buildQuery(resource, menuName, requiredFields, settings);
|
|
114
117
|
if ((settings || {}).max_depth) {
|
|
115
118
|
query.addFilter("max_depth", parseInt(settings.max_depth));
|
|
@@ -123,7 +126,7 @@ class DruxtMenu {
|
|
|
123
126
|
const entities = [];
|
|
124
127
|
let collections = [];
|
|
125
128
|
try {
|
|
126
|
-
collections = await this.druxt.getCollectionAll(menuItemsResource, query);
|
|
129
|
+
collections = await this.druxt.getCollectionAll(menuItemsResource, query, prefix);
|
|
127
130
|
} catch (e) {
|
|
128
131
|
return { entities };
|
|
129
132
|
}
|
|
@@ -156,26 +159,28 @@ const DruxtMenuStore = ({ store }) => {
|
|
|
156
159
|
entities: {}
|
|
157
160
|
}),
|
|
158
161
|
mutations: {
|
|
159
|
-
addEntities(state, entities) {
|
|
162
|
+
addEntities(state, { entities, prefix }) {
|
|
163
|
+
if (!state.entities[prefix])
|
|
164
|
+
Vue.set(state.entities, prefix, {});
|
|
160
165
|
for (const index in entities) {
|
|
161
166
|
const entity = entities[index];
|
|
162
|
-
state.entities[entity.id
|
|
167
|
+
Vue.set(state.entities[prefix], entity.id, entity);
|
|
163
168
|
}
|
|
164
169
|
}
|
|
165
170
|
},
|
|
166
171
|
actions: {
|
|
167
172
|
async get({ commit }, context) {
|
|
168
|
-
const { name, settings } = typeof context === "object" ? context : { name: context };
|
|
169
|
-
const { entities } = await this.$druxtMenu.get(name, settings) || {};
|
|
170
|
-
commit("addEntities", entities);
|
|
173
|
+
const { name, settings, prefix } = typeof context === "object" ? context : { name: context };
|
|
174
|
+
const { entities } = await this.$druxtMenu.get(name, settings, prefix) || {};
|
|
175
|
+
commit("addEntities", { entities, prefix });
|
|
171
176
|
}
|
|
172
177
|
},
|
|
173
178
|
getters: {
|
|
174
|
-
getEntitiesByFilter: (state) => (filter) => {
|
|
175
|
-
const keys = Object.keys(state.entities).filter((key) => filter(key));
|
|
179
|
+
getEntitiesByFilter: (state) => ({ filter, prefix }) => {
|
|
180
|
+
const keys = Object.keys((state.entities || {})[prefix]).filter((key) => filter(key));
|
|
176
181
|
if (!keys.length)
|
|
177
182
|
return {};
|
|
178
|
-
return Object.assign(...keys.map((key) => ({ [key]: state.entities[key] })));
|
|
183
|
+
return Object.assign(...keys.map((key) => ({ [key]: state.entities[prefix][key] })));
|
|
179
184
|
}
|
|
180
185
|
}
|
|
181
186
|
};
|
|
@@ -190,6 +195,10 @@ const DruxtMenuMixin = {
|
|
|
190
195
|
type: Array,
|
|
191
196
|
required: true
|
|
192
197
|
},
|
|
198
|
+
langcode: {
|
|
199
|
+
type: String,
|
|
200
|
+
default: void 0
|
|
201
|
+
},
|
|
193
202
|
parentId: {
|
|
194
203
|
type: String,
|
|
195
204
|
default: null
|
|
@@ -197,5 +206,4 @@ const DruxtMenuMixin = {
|
|
|
197
206
|
}
|
|
198
207
|
};
|
|
199
208
|
|
|
200
|
-
export default
|
|
201
|
-
export { DruxtMenu, DruxtMenuMixin, DruxtMenuStore };
|
|
209
|
+
export { DruxtMenu, DruxtMenuMixin, DruxtMenuStore, DruxtMenuNuxtModule as default };
|
package/dist/druxt-menu.ssr.js
CHANGED
|
@@ -5,6 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const drupalJsonapiParams = require('drupal-jsonapi-params');
|
|
7
7
|
const druxt = require('druxt');
|
|
8
|
+
const Vue = require('vue');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
const Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
|
|
8
13
|
|
|
9
14
|
const titleFn = (parts) => parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1).replace(/_/g, " ")).join("/");
|
|
10
15
|
async function DruxtMenuStorybook({ stories }) {
|
|
@@ -89,18 +94,18 @@ class DruxtMenu {
|
|
|
89
94
|
}
|
|
90
95
|
return query;
|
|
91
96
|
}
|
|
92
|
-
async get(menuName, settings) {
|
|
97
|
+
async get(menuName, settings, prefix) {
|
|
93
98
|
if (this.options.menu.jsonApiMenuItems) {
|
|
94
|
-
return this.getJsonApiMenuItems(menuName, settings);
|
|
99
|
+
return this.getJsonApiMenuItems(menuName, settings, prefix);
|
|
95
100
|
}
|
|
96
|
-
return this.getMenuLinkContent(menuName, settings);
|
|
101
|
+
return this.getMenuLinkContent(menuName, settings, prefix);
|
|
97
102
|
}
|
|
98
|
-
async getMenuLinkContent(menuName, settings) {
|
|
103
|
+
async getMenuLinkContent(menuName, settings, prefix) {
|
|
99
104
|
const resource = "menu_link_content--menu_link_content";
|
|
100
105
|
const requiredFields = ["bundle", "link", "menu_name", "parent", "title", "weight"];
|
|
101
106
|
const query = this.buildQuery(resource, menuName, requiredFields, settings);
|
|
102
107
|
const entities = [];
|
|
103
|
-
const collections = await this.druxt.getCollectionAll(resource, query);
|
|
108
|
+
const collections = await this.druxt.getCollectionAll(resource, query, prefix);
|
|
104
109
|
for (const collection of collections) {
|
|
105
110
|
for (const entity of collection.data) {
|
|
106
111
|
entities.push(entity);
|
|
@@ -108,12 +113,14 @@ class DruxtMenu {
|
|
|
108
113
|
}
|
|
109
114
|
return { entities };
|
|
110
115
|
}
|
|
111
|
-
async getJsonApiMenuItems(menuName, settings) {
|
|
116
|
+
async getJsonApiMenuItems(menuName, settings, prefix) {
|
|
112
117
|
const menuItemsResource = `menu_items--${menuName}`;
|
|
113
118
|
const resource = "menu_link_content--menu_link_content";
|
|
114
119
|
const requiredFields = ["menu_name", "parent", "title", "url", "weight"];
|
|
115
|
-
await this.druxt.getIndex();
|
|
116
|
-
this.druxt.index[menuItemsResource]
|
|
120
|
+
await this.druxt.getIndex(void 0, prefix);
|
|
121
|
+
if (!(this.druxt.index[prefix][menuItemsResource] || {}).href) {
|
|
122
|
+
this.druxt.index[prefix][menuItemsResource] = { href: `${prefix || ""}${this.druxt.options.endpoint}/menu_items/${menuName}` };
|
|
123
|
+
}
|
|
117
124
|
const query = this.buildQuery(resource, menuName, requiredFields, settings);
|
|
118
125
|
if ((settings || {}).max_depth) {
|
|
119
126
|
query.addFilter("max_depth", parseInt(settings.max_depth));
|
|
@@ -127,7 +134,7 @@ class DruxtMenu {
|
|
|
127
134
|
const entities = [];
|
|
128
135
|
let collections = [];
|
|
129
136
|
try {
|
|
130
|
-
collections = await this.druxt.getCollectionAll(menuItemsResource, query);
|
|
137
|
+
collections = await this.druxt.getCollectionAll(menuItemsResource, query, prefix);
|
|
131
138
|
} catch (e) {
|
|
132
139
|
return { entities };
|
|
133
140
|
}
|
|
@@ -160,26 +167,28 @@ const DruxtMenuStore = ({ store }) => {
|
|
|
160
167
|
entities: {}
|
|
161
168
|
}),
|
|
162
169
|
mutations: {
|
|
163
|
-
addEntities(state, entities) {
|
|
170
|
+
addEntities(state, { entities, prefix }) {
|
|
171
|
+
if (!state.entities[prefix])
|
|
172
|
+
Vue__default["default"].set(state.entities, prefix, {});
|
|
164
173
|
for (const index in entities) {
|
|
165
174
|
const entity = entities[index];
|
|
166
|
-
state.entities[entity.id
|
|
175
|
+
Vue__default["default"].set(state.entities[prefix], entity.id, entity);
|
|
167
176
|
}
|
|
168
177
|
}
|
|
169
178
|
},
|
|
170
179
|
actions: {
|
|
171
180
|
async get({ commit }, context) {
|
|
172
|
-
const { name, settings } = typeof context === "object" ? context : { name: context };
|
|
173
|
-
const { entities } = await this.$druxtMenu.get(name, settings) || {};
|
|
174
|
-
commit("addEntities", entities);
|
|
181
|
+
const { name, settings, prefix } = typeof context === "object" ? context : { name: context };
|
|
182
|
+
const { entities } = await this.$druxtMenu.get(name, settings, prefix) || {};
|
|
183
|
+
commit("addEntities", { entities, prefix });
|
|
175
184
|
}
|
|
176
185
|
},
|
|
177
186
|
getters: {
|
|
178
|
-
getEntitiesByFilter: (state) => (filter) => {
|
|
179
|
-
const keys = Object.keys(state.entities).filter((key) => filter(key));
|
|
187
|
+
getEntitiesByFilter: (state) => ({ filter, prefix }) => {
|
|
188
|
+
const keys = Object.keys((state.entities || {})[prefix]).filter((key) => filter(key));
|
|
180
189
|
if (!keys.length)
|
|
181
190
|
return {};
|
|
182
|
-
return Object.assign(...keys.map((key) => ({ [key]: state.entities[key] })));
|
|
191
|
+
return Object.assign(...keys.map((key) => ({ [key]: state.entities[prefix][key] })));
|
|
183
192
|
}
|
|
184
193
|
}
|
|
185
194
|
};
|
|
@@ -194,6 +203,10 @@ const DruxtMenuMixin = {
|
|
|
194
203
|
type: Array,
|
|
195
204
|
required: true
|
|
196
205
|
},
|
|
206
|
+
langcode: {
|
|
207
|
+
type: String,
|
|
208
|
+
default: void 0
|
|
209
|
+
},
|
|
197
210
|
parentId: {
|
|
198
211
|
type: String,
|
|
199
212
|
default: null
|
|
@@ -204,4 +217,4 @@ const DruxtMenuMixin = {
|
|
|
204
217
|
exports.DruxtMenu = DruxtMenu;
|
|
205
218
|
exports.DruxtMenuMixin = DruxtMenuMixin;
|
|
206
219
|
exports.DruxtMenuStore = DruxtMenuStore;
|
|
207
|
-
exports
|
|
220
|
+
exports["default"] = DruxtMenuNuxtModule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "druxt-menu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Drupal Menu and Menu item Druxt components, with support for the JSON:API Menu Items module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"deepmerge": "^4.2.2",
|
|
46
|
-
"drupal-jsonapi-params": "^
|
|
47
|
-
"druxt": "^0.
|
|
48
|
-
"druxt-blocks": "^0.
|
|
46
|
+
"drupal-jsonapi-params": "^2.0.0",
|
|
47
|
+
"druxt": "^0.19.0",
|
|
48
|
+
"druxt-blocks": "^0.16.0"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|
|
51
51
|
"vue": "^2.6.14",
|