druxt-blocks 0.13.0 → 0.14.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # druxt-blocks
2
2
 
3
+ ## 0.14.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [45bc0b9]
8
+ - druxt@0.14.0
9
+ - druxt-entity@0.21.3
10
+ - druxt-router@0.24.1
11
+
12
+ ## 0.14.1
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [9161b38]
17
+ - druxt-router@0.24.0
18
+ - druxt-entity@0.21.2
19
+
20
+ ## 0.14.0
21
+
22
+ ### Minor Changes
23
+
24
+ - e7b1533: Refactored DruxtModule fetch hooks
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [025315a]
29
+ - druxt-entity@0.21.0
30
+ - druxt@0.13.0
31
+ - druxt-router@0.23.0
32
+
33
+ ## 0.13.1
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [4504a2f]
38
+ - druxt@0.12.0
39
+ - druxt-router@0.22.0
40
+ - druxt-entity@0.20.0
41
+
3
42
  ## 0.13.0
4
43
 
5
44
  ### Minor Changes
@@ -56,43 +56,6 @@ export default {
56
56
  resource: {},
57
57
  }),
58
58
 
59
- /**
60
- * The Nuxt Fetch hook.
61
- *
62
- * Fetches the Block JSON:API resource by either UUID or ID.
63
- */
64
- async fetch() {
65
- // Build query.
66
- const type = 'block--block'
67
- const query = new DrupalJsonApiParams()
68
-
69
- const fields = ((this.$druxt.settings.blocks || {}).query || {}).fields
70
- if (Array.isArray(fields)) {
71
- query.addFields(type, [
72
- ...fields,
73
- 'plugin',
74
- 'region',
75
- 'settings',
76
- 'theme',
77
- ])
78
- }
79
-
80
- // Fetch Block by UUID.
81
- if (this.uuid) {
82
- const id = this.uuid
83
- this.resource = await this.getResource({ type, id, query })
84
- }
85
-
86
- // Fetch Block by Drupal internal ID.
87
- else if (this.id) {
88
- query.addFilter('drupal_internal__id', this.id)
89
- const collection = await this.getCollection({ type, query })
90
- this.resource = { data: collection.data[0] }
91
- }
92
-
93
- await DruxtModule.fetch.call(this)
94
- },
95
-
96
59
  fetchKey(getCounter) {
97
60
  const parts = ['DruxtBlock', this.uuid || this.id].filter((o) => o)
98
61
  return [...parts, getCounter(parts.join(':'))].join(':')
@@ -148,6 +111,39 @@ export default {
148
111
  return componentOptions
149
112
  },
150
113
 
114
+ /**
115
+ * Fetches the Block JSON:API resource by either UUID or ID.
116
+ */
117
+ async fetchConfig() {
118
+ // Build query.
119
+ const type = 'block--block'
120
+ const query = new DrupalJsonApiParams()
121
+
122
+ const fields = ((this.$druxt.settings.blocks || {}).query || {}).fields
123
+ if (Array.isArray(fields)) {
124
+ query.addFields(type, [
125
+ ...fields,
126
+ 'plugin',
127
+ 'region',
128
+ 'settings',
129
+ 'theme',
130
+ ])
131
+ }
132
+
133
+ // Fetch Block by UUID.
134
+ if (this.uuid) {
135
+ const id = this.uuid
136
+ this.resource = await this.getResource({ type, id, query })
137
+ }
138
+
139
+ // Fetch Block by Drupal internal ID.
140
+ else if (this.id) {
141
+ query.addFilter('drupal_internal__id', this.id)
142
+ const collection = await this.getCollection({ type, query })
143
+ this.resource = { data: collection.data[0] }
144
+ }
145
+ },
146
+
151
147
  /**
152
148
  * Provides propsData for the DruxtWrapper.
153
149
  *
@@ -58,27 +58,6 @@ export default {
58
58
  blocks: []
59
59
  }),
60
60
 
61
- /**
62
- * The Nuxt Fetch hook.
63
- *
64
- * Fetches all blocks by region and theme.
65
- */
66
- async fetch() {
67
- const type = 'block--block'
68
- const query = new DrupalJsonApiParams()
69
- query
70
- .addFilter('region', this.name)
71
- .addFilter('status', '1')
72
- .addFilter('theme', this.theme)
73
- .addSort('weight')
74
- .addFields(type, ['drupal_internal__id', 'visibility', 'weight'])
75
-
76
- const collection = await this.getCollection({ type, query })
77
- this.blocks = collection.data
78
-
79
- await DruxtModule.fetch.call(this)
80
- },
81
-
82
61
  fetchKey(getCounter) {
83
62
  const parts = ['DruxtBlockRegion', this.name].filter((o) => o)
84
63
  return [...parts, getCounter(parts.join(':'))].join(':')
@@ -146,6 +125,23 @@ export default {
146
125
  */
147
126
  componentOptions: ({ name, theme }) => [[name, theme], ['default']],
148
127
 
128
+ /**
129
+ * Fetches all blocks by region and theme.
130
+ */
131
+ async fetchConfig() {
132
+ const type = 'block--block'
133
+ const query = new DrupalJsonApiParams()
134
+ query
135
+ .addFilter('region', this.name)
136
+ .addFilter('status', '1')
137
+ .addFilter('theme', this.theme)
138
+ .addSort('weight')
139
+ .addFields(type, ['drupal_internal__id', 'visibility', 'weight'])
140
+
141
+ const collection = await this.getCollection({ type, query })
142
+ this.blocks = collection.data
143
+ },
144
+
149
145
  /**
150
146
  * Provides propsData for the DruxtWrapper.
151
147
  *
@@ -5,7 +5,7 @@ import { DruxtClient } from 'druxt';
5
5
  const titleFn = (parts) => parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1).replace(/_/g, " ")).join("/");
6
6
  async function DruxtBlocksStorybook({ stories }) {
7
7
  const { addTemplate, options } = this;
8
- const druxt = new DruxtClient(options.druxt.baseUrl, options.druxt);
8
+ const druxt = new DruxtClient(options.druxt.baseUrl, { ...options.druxt, proxy: { api: false } });
9
9
  const query = new DrupalJsonApiParams().addFilter("status", true);
10
10
  const blocks = (await druxt.getCollectionAll("block--block", query)).map((collection) => collection.data).flat();
11
11
  const blockStories = blocks.map((block) => {
@@ -9,7 +9,7 @@ const druxt = require('druxt');
9
9
  const titleFn = (parts) => parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1).replace(/_/g, " ")).join("/");
10
10
  async function DruxtBlocksStorybook({ stories }) {
11
11
  const { addTemplate, options } = this;
12
- const druxt$1 = new druxt.DruxtClient(options.druxt.baseUrl, options.druxt);
12
+ const druxt$1 = new druxt.DruxtClient(options.druxt.baseUrl, { ...options.druxt, proxy: { api: false } });
13
13
  const query = new drupalJsonapiParams.DrupalJsonApiParams().addFilter("status", true);
14
14
  const blocks = (await druxt$1.getCollectionAll("block--block", query)).map((collection) => collection.data).flat();
15
15
  const blockStories = blocks.map((block) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt-blocks",
3
- "version": "0.13.0",
3
+ "version": "0.14.2",
4
4
  "description": "Drupal Block and Block Region Druxt components.",
5
5
  "keywords": [
6
6
  "block",
@@ -44,9 +44,9 @@
44
44
  "dependencies": {
45
45
  "axios": "^0.21.1",
46
46
  "drupal-jsonapi-params": "^1.1.12",
47
- "druxt": "^0.11.0",
48
- "druxt-entity": "^0.19.0",
49
- "druxt-router": "^0.21.0"
47
+ "druxt": "^0.14.0",
48
+ "druxt-entity": "^0.21.3",
49
+ "druxt-router": "^0.24.1"
50
50
  },
51
51
  "optionalDependencies": {
52
52
  "vue": "^2.6.14",