druxt-blocks 0.15.1 → 0.16.1

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.
@@ -171,13 +171,22 @@ export default {
171
171
  // Fetch Block by UUID.
172
172
  if (this.uuid) {
173
173
  const id = this.uuid
174
- this.resource = await this.getResource({ type, id, query })
174
+ this.resource = await this.getResource({
175
+ id,
176
+ prefix: this.lang,
177
+ type,
178
+ query
179
+ })
175
180
  }
176
181
 
177
182
  // Fetch Block by Drupal internal ID.
178
183
  else if (this.id) {
179
184
  query.addFilter('drupal_internal__id', this.id)
180
- const collection = await this.getCollection({ type, query })
185
+ const collection = await this.getCollection({
186
+ prefix: this.lang,
187
+ type,
188
+ query
189
+ })
181
190
  this.resource = { data: collection.data[0] }
182
191
  }
183
192
  },
@@ -238,19 +247,29 @@ export default {
238
247
  *
239
248
  * @example @lang js
240
249
  * [
250
+ * 'DruxtBlock[Plugin][PluginId][Region][Theme][Langcode]',
241
251
  * 'DruxtBlock[Plugin][PluginId][Region][Theme]',
252
+ * 'DruxtBlock[Plugin][PluginId][Theme][Langcode]',
242
253
  * 'DruxtBlock[Plugin][PluginId][Theme]',
254
+ * 'DruxtBlock[Plugin][Region][Theme][Langcode]',
243
255
  * 'DruxtBlock[Plugin][Region][Theme]',
256
+ * 'DruxtBlock[Plugin][Theme][Langcode]',
244
257
  * 'DruxtBlock[Plugin][Theme]',
258
+ * 'DruxtBlock[Default][Langcode]',
245
259
  * 'DruxtBlock[Default]',
246
260
  * ]
247
261
  *
248
262
  * @example <caption>Umami Branding block</caption> @lang js
249
263
  * [
264
+ * 'DruxtBlockSystemBrandingBlockHeaderUmamiEn',
250
265
  * 'DruxtBlockSystemBrandingBlockHeaderUmami',
266
+ * 'DruxtBlockSystemBrandingBlockHeaderEn',
251
267
  * 'DruxtBlockSystemBrandingBlockHeader',
268
+ * 'DruxtBlockSystemBrandingBlockUmamiEn',
252
269
  * 'DruxtBlockSystemBrandingBlockUmami',
270
+ * 'DruxtBlockSystemBrandingBlockEn',
253
271
  * 'DruxtBlockSystemBrandingBlock',
272
+ * 'DruxtBlockDefaultEn',
254
273
  * 'DruxtBlockDefault',
255
274
  * ]
256
275
  */
@@ -121,7 +121,9 @@ export default {
121
121
  visible = true
122
122
  }
123
123
 
124
- if (pages.includes(this.route.resolvedPath) || (!pages.includes(this.route.resolvedPath) && negate)) {
124
+ // Remove langcode prefix from the resolved path before comparing.
125
+ const resolvedPath = (this.route.resolvedPath || '').replace(new RegExp(`^/${this.lang}`), '')
126
+ if (pages.includes(resolvedPath) || (!pages.includes(resolvedPath) && negate)) {
125
127
  visible = true
126
128
  }
127
129
 
@@ -166,7 +168,11 @@ export default {
166
168
  .addSort('weight')
167
169
  .addFields(type, ['drupal_internal__id', 'visibility', 'weight'])
168
170
 
169
- const collection = await this.getCollection({ type, query })
171
+ const collection = await this.getCollection({
172
+ prefix: this.lang,
173
+ type,
174
+ query
175
+ })
170
176
  this.blocks = collection.data
171
177
  },
172
178
 
@@ -209,6 +215,7 @@ export default {
209
215
  attrs,
210
216
  key: block.attributes.drupal_internal__id,
211
217
  props: {
218
+ langcode: this.langcode,
212
219
  uuid: block.id,
213
220
  },
214
221
  ref: block.attributes.drupal_internal__id,
@@ -235,15 +242,21 @@ export default {
235
242
  *
236
243
  * @example @lang js
237
244
  * [
245
+ * 'DruxtBlockRegion[Name][Theme][Langcode]',
238
246
  * 'DruxtBlockRegion[Name][Theme]',
247
+ * 'DruxtBlockRegion[Name][Langcode]',
239
248
  * 'DruxtBlockRegion[Name]',
249
+ * 'DruxtBlockRegion[Default][Langcode]',
240
250
  * 'DruxtBlockRegion[Default]',
241
251
  * ]
242
252
  *
243
253
  * @example <caption>Banner top - Umami</caption> @lang js
244
254
  * [
255
+ * 'DruxtBlockRegionBannerTopUmamiEn',
245
256
  * 'DruxtBlockRegionBannerTopUmami',
257
+ * 'DruxtBlockRegionBannerTopEn',
246
258
  * 'DruxtBlockRegionBannerTop',
259
+ * 'DruxtBlockRegionDefaultEn',
247
260
  * 'DruxtBlockRegionDefault',
248
261
  * ]
249
262
  */
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div>
3
3
  <DruxtEntity
4
- v-if="!$fetchState.pending"
4
+ v-if="!$fetchState.pending && propsData"
5
5
  v-bind="propsData"
6
6
  />
7
7
  </div>
@@ -38,6 +38,7 @@ export default {
38
38
 
39
39
  async fetch() {
40
40
  await this.$store.dispatch('druxt/getResource', {
41
+ prefix: this.langcode,
41
42
  type: this.block.type,
42
43
  id: this.block.id,
43
44
  query: new DrupalJsonApiParams().addFields(this.block.type, ['dependencies']),
@@ -53,18 +54,19 @@ export default {
53
54
  *
54
55
  * @type {object}
55
56
  *
56
- * @see {@link https://druxt.github.io/druxt-entity/api/components/DruxtEntity.html|DruxtEntity}
57
+ * @see {@link https://druxt.github.io/druxt-entity/api/components/DruxtEntity|DruxtEntity}
57
58
  */
58
- propsData: ({ $fetchState, $store, block }) => {
59
+ propsData: ({ $fetchState, $store, block, langcode }) => {
59
60
  if ($fetchState.pending) return false
60
61
 
61
- const resource = $store.state.druxt.resources[block.type][block.id]
62
- if (!resource.data.attributes.dependencies) return false
62
+ const { data } = $store.state.druxt.resources[block.type][block.id][langcode]
63
+ if (!((data || {}).attributes || {}).dependencies) return false
63
64
 
64
- const parts = resource.data.attributes.dependencies.content[0].split(':')
65
+ const parts = data.attributes.dependencies.content[0].split(':')
65
66
 
66
67
  return {
67
- key: resource.data.attributes.dependencies.content[0],
68
+ key: data.attributes.dependencies.content[0],
69
+ langcode,
68
70
  type: `${parts[0]}--${parts[1]}`,
69
71
  uuid: parts[2]
70
72
  }
@@ -52,7 +52,7 @@ async function DruxtBlocksStorybook({ stories }) {
52
52
  stories.push(resolve(options.buildDir, `./stories/druxt-block-region.*.stories.js`));
53
53
  }
54
54
 
55
- const DruxtBlocksNuxtModule = function(moduleOptions = {}) {
55
+ const DruxtBlocksNuxtModule = async function(moduleOptions = {}) {
56
56
  const options = {
57
57
  baseUrl: moduleOptions.baseUrl,
58
58
  ...(this.options || {}).druxt || {},
@@ -62,7 +62,7 @@ const DruxtBlocksNuxtModule = function(moduleOptions = {}) {
62
62
  ...moduleOptions
63
63
  }
64
64
  };
65
- this.addModule(["druxt", options]);
65
+ await this.addModule(["druxt", options]);
66
66
  this.nuxt.hook("components:dirs", (dirs) => {
67
67
  dirs.push({ path: join(__dirname, "components") });
68
68
  dirs.push({ path: join(__dirname, "components/blocks") });
@@ -78,6 +78,10 @@ const DruxtBlocksBlockMixin = {
78
78
  block: {
79
79
  type: Object,
80
80
  require: true
81
+ },
82
+ langcode: {
83
+ type: String,
84
+ default: void 0
81
85
  }
82
86
  },
83
87
  computed: {
@@ -93,6 +97,10 @@ const DruxtBlocksRegionMixin = {
93
97
  type: Array,
94
98
  required: true
95
99
  },
100
+ langcode: {
101
+ type: String,
102
+ default: void 0
103
+ },
96
104
  name: {
97
105
  type: String,
98
106
  default: "content"
@@ -104,5 +112,4 @@ const DruxtBlocksRegionMixin = {
104
112
  }
105
113
  };
106
114
 
107
- export default DruxtBlocksNuxtModule;
108
- export { DruxtBlocksBlockMixin, DruxtBlocksRegionMixin };
115
+ export { DruxtBlocksBlockMixin, DruxtBlocksRegionMixin, DruxtBlocksNuxtModule as default };
@@ -56,7 +56,7 @@ async function DruxtBlocksStorybook({ stories }) {
56
56
  stories.push(path.resolve(options.buildDir, `./stories/druxt-block-region.*.stories.js`));
57
57
  }
58
58
 
59
- const DruxtBlocksNuxtModule = function(moduleOptions = {}) {
59
+ const DruxtBlocksNuxtModule = async function(moduleOptions = {}) {
60
60
  const options = {
61
61
  baseUrl: moduleOptions.baseUrl,
62
62
  ...(this.options || {}).druxt || {},
@@ -66,7 +66,7 @@ const DruxtBlocksNuxtModule = function(moduleOptions = {}) {
66
66
  ...moduleOptions
67
67
  }
68
68
  };
69
- this.addModule(["druxt", options]);
69
+ await this.addModule(["druxt", options]);
70
70
  this.nuxt.hook("components:dirs", (dirs) => {
71
71
  dirs.push({ path: path.join(__dirname, "components") });
72
72
  dirs.push({ path: path.join(__dirname, "components/blocks") });
@@ -82,6 +82,10 @@ const DruxtBlocksBlockMixin = {
82
82
  block: {
83
83
  type: Object,
84
84
  require: true
85
+ },
86
+ langcode: {
87
+ type: String,
88
+ default: void 0
85
89
  }
86
90
  },
87
91
  computed: {
@@ -97,6 +101,10 @@ const DruxtBlocksRegionMixin = {
97
101
  type: Array,
98
102
  required: true
99
103
  },
104
+ langcode: {
105
+ type: String,
106
+ default: void 0
107
+ },
100
108
  name: {
101
109
  type: String,
102
110
  default: "content"
@@ -110,4 +118,4 @@ const DruxtBlocksRegionMixin = {
110
118
 
111
119
  exports.DruxtBlocksBlockMixin = DruxtBlocksBlockMixin;
112
120
  exports.DruxtBlocksRegionMixin = DruxtBlocksRegionMixin;
113
- exports.default = DruxtBlocksNuxtModule;
121
+ exports["default"] = DruxtBlocksNuxtModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt-blocks",
3
- "version": "0.15.1",
3
+ "version": "0.16.1",
4
4
  "description": "Drupal Block and Block Region Druxt components.",
5
5
  "keywords": [
6
6
  "block",
@@ -42,11 +42,11 @@
42
42
  "templates"
43
43
  ],
44
44
  "dependencies": {
45
- "axios": "^0.21.1",
46
- "drupal-jsonapi-params": "^1.1.12",
47
- "druxt": "^0.18.0",
48
- "druxt-entity": "^0.24.2",
49
- "druxt-router": "^0.26.1"
45
+ "axios": "^0.27.2",
46
+ "drupal-jsonapi-params": "^2.0.0",
47
+ "druxt": "^0.19.0",
48
+ "druxt-entity": "^0.25.0",
49
+ "druxt-router": "^0.27.0"
50
50
  },
51
51
  "optionalDependencies": {
52
52
  "vue": "^2.6.14",