druxt-views 0.15.0 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # druxt-views
2
2
 
3
+ ## 0.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7709ece: Fixed DruxtViewsFilter render method
8
+
9
+ ⚠ Potential breaking change
10
+
11
+ _**Note:** This may change the markup of a Druxt View filter component._
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [2ae1d6d]
16
+ - druxt@0.15.0
17
+ - druxt-blocks@0.14.3
18
+ - druxt-entity@0.21.4
19
+ - druxt-router@0.24.2
20
+
21
+ ## 0.16.2
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [45bc0b9]
26
+ - druxt@0.14.0
27
+ - druxt-blocks@0.14.2
28
+ - druxt-entity@0.21.3
29
+ - druxt-router@0.24.1
30
+
31
+ ## 0.16.1
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [9161b38]
36
+ - druxt-router@0.24.0
37
+ - druxt-blocks@0.14.1
38
+ - druxt-entity@0.21.2
39
+
40
+ ## 0.16.0
41
+
42
+ ### Minor Changes
43
+
44
+ - e7b1533: Refactored DruxtModule fetch hooks
45
+
46
+ ### Patch Changes
47
+
48
+ - d80f5d4: Fixed issue with undefined wrapper in DruxtViewsFilter
49
+ - Updated dependencies [025315a]
50
+ - druxt-entity@0.21.0
51
+ - druxt-blocks@0.14.0
52
+ - druxt@0.13.0
53
+ - druxt-router@0.23.0
54
+
3
55
  ## 0.15.0
4
56
 
5
57
  ### Minor Changes
@@ -113,55 +113,6 @@ export default {
113
113
  }
114
114
  },
115
115
 
116
- /** */
117
- async fetch() {
118
- let component = { ...this.component }
119
-
120
- // Fetch View.
121
- if (!this.view && (this.uuid || this.viewId)) {
122
- if (this.uuid) {
123
- this.view = await this.getResource({
124
- type: this.type,
125
- id: this.uuid,
126
- })
127
- } else {
128
- const collection = await this.getCollection({ type: this.type, query: new DrupalJsonApiParams().addFilter('drupal_internal__id', this.viewId) })
129
- this.view = { data: collection.data[0] }
130
- }
131
-
132
- // Build wrapper component object.
133
- const options = this.getModuleComponents()
134
- component = {
135
- is: (((options.filter(o => o.global) || [])[0] || {}).name || 'DruxtWrapper'),
136
- options: options.map(o => o.name) || [],
137
- }
138
- }
139
-
140
- // Get scoped slots.
141
- component.slots = Object.keys(this.getScopedSlots())
142
-
143
- // Get wrapper component data to merge with module settings.
144
- const wrapperData = await this.getWrapperData(component.is)
145
- component.settings = merge(this.$druxt.settings.views, wrapperData.druxt || {}, { arrayMerge: (dest, src) => src })
146
-
147
- // Fetch JSON:API Views resource.
148
- const viewId = this.viewId || (((this.view || {}).data || {}).attributes || {}).drupal_internal__id
149
- if (viewId) {
150
- const query = this.getQuery(component.settings)
151
- this.resource = await this.getResults({
152
- viewId,
153
- displayId: this.displayId,
154
- query: stringify(query)
155
- })
156
- }
157
-
158
- // Build wrapper component propsData.
159
- component = { ...component, ...this.getModulePropsData(wrapperData.props) }
160
-
161
- // Set component data.
162
- this.component = component
163
- },
164
-
165
116
  fetchKey(getCounter) {
166
117
  const parts = ['DruxtView', this.viewId || this.uuid, this.displayId].filter((o) => o)
167
118
  return [...parts, getCounter(parts.join(':'))].join(':')
@@ -440,6 +391,38 @@ export default {
440
391
  */
441
392
  componentOptions: ({ displayId, uuid, viewId }) => ([[viewId || uuid, displayId]]),
442
393
 
394
+ /**
395
+ * Fetch View configuration resource.
396
+ */
397
+ async fetchConfig() {
398
+ if (!this.view && (this.uuid || this.viewId)) {
399
+ if (this.uuid) {
400
+ this.view = await this.getResource({
401
+ type: this.type,
402
+ id: this.uuid,
403
+ })
404
+ } else {
405
+ const collection = await this.getCollection({ type: this.type, query: new DrupalJsonApiParams().addFilter('drupal_internal__id', this.viewId) })
406
+ this.view = { data: collection.data[0] }
407
+ }
408
+ }
409
+ },
410
+
411
+ /**
412
+ * Fetch JSON:API Views results.
413
+ */
414
+ async fetchData(settings) {
415
+ const viewId = this.viewId || (((this.view || {}).data || {}).attributes || {}).drupal_internal__id
416
+ if (viewId) {
417
+ const query = this.getQuery(settings)
418
+ this.resource = await this.getResults({
419
+ viewId,
420
+ displayId: this.displayId,
421
+ query: stringify(query)
422
+ })
423
+ }
424
+ },
425
+
443
426
  /**
444
427
  * Provides propsData for the DruxtWrapper.
445
428
  *
@@ -455,6 +438,16 @@ export default {
455
438
  view: vm.view
456
439
  }),
457
440
 
441
+ /**
442
+ * Component settings.
443
+ */
444
+ settings: ({ $druxt }, wrapperSettings) => {
445
+ const settings = merge($druxt.settings.views || {}, wrapperSettings, { arrayMerge: (dest, src) => src })
446
+ return {
447
+ query: settings.query || {},
448
+ }
449
+ },
450
+
458
451
  /**
459
452
  * Provides the scoped slots object for the Module render function.
460
453
  *
@@ -1,17 +1,3 @@
1
- <template>
2
- <component
3
- :is="wrapper.component"
4
- v-if="!$fetchState.pending"
5
- v-bind="wrapper.propsData"
6
- >
7
- <component
8
- :is="component.is"
9
- v-model="model"
10
- v-bind="component.propsData"
11
- />
12
- </component>
13
- </template>
14
-
15
1
  <script>
16
2
 
17
3
  import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
@@ -38,14 +24,6 @@ export default {
38
24
  },
39
25
  },
40
26
 
41
- watch: {
42
- model(to, from) {
43
- if (to !== from) {
44
- this.$emit('input', this.model)
45
- }
46
- }
47
- },
48
-
49
27
  /** DruxtModule settings */
50
28
  druxt: {
51
29
  /**
@@ -7,7 +7,7 @@ import { DruxtEntityContextMixin } from 'druxt-entity';
7
7
 
8
8
  async function DruxtViewsStorybook({ stories }) {
9
9
  const { addTemplate, options } = this;
10
- const druxt = new DruxtClient(options.druxt.baseUrl, options.druxt);
10
+ const druxt = new DruxtClient(options.druxt.baseUrl, { ...options.druxt, proxy: { api: false } });
11
11
  const resourceType = "view--view";
12
12
  const query = new DrupalJsonApiParams().addFilter("status", 1).addFields(resourceType, ["display", "description", "drupal_internal__id", "label"]);
13
13
  const collections = await druxt.getCollectionAll(resourceType, query);
@@ -71,7 +71,6 @@ const DruxtViewsNuxtModule = function(moduleOptions = {}) {
71
71
  await DruxtViewsStorybook.call(this, { stories });
72
72
  });
73
73
  };
74
- DruxtViewsNuxtModule.meta = require("../package.json");
75
74
 
76
75
  const DruxtViewsStore = ({ store }) => {
77
76
  if (typeof store === "undefined") {
@@ -278,5 +277,7 @@ const DruxtViewsViewMixin = {
278
277
  }
279
278
  };
280
279
 
280
+ DruxtViewsNuxtModule.meta = require("../package.json");
281
+
281
282
  export default DruxtViewsNuxtModule;
282
283
  export { DruxtViewsFilterMixin, DruxtViewsFiltersMixin, DruxtViewsPagerMixin, DruxtViewsSortsMixin, DruxtViewsStore, DruxtViewsViewMixin };
@@ -16,7 +16,7 @@ const md5__default = /*#__PURE__*/_interopDefaultLegacy(md5);
16
16
 
17
17
  async function DruxtViewsStorybook({ stories }) {
18
18
  const { addTemplate, options } = this;
19
- const druxt$1 = new druxt.DruxtClient(options.druxt.baseUrl, options.druxt);
19
+ const druxt$1 = new druxt.DruxtClient(options.druxt.baseUrl, { ...options.druxt, proxy: { api: false } });
20
20
  const resourceType = "view--view";
21
21
  const query = new drupalJsonapiParams.DrupalJsonApiParams().addFilter("status", 1).addFields(resourceType, ["display", "description", "drupal_internal__id", "label"]);
22
22
  const collections = await druxt$1.getCollectionAll(resourceType, query);
@@ -80,7 +80,6 @@ const DruxtViewsNuxtModule = function(moduleOptions = {}) {
80
80
  await DruxtViewsStorybook.call(this, { stories });
81
81
  });
82
82
  };
83
- DruxtViewsNuxtModule.meta = require("../package.json");
84
83
 
85
84
  const DruxtViewsStore = ({ store }) => {
86
85
  if (typeof store === "undefined") {
@@ -287,6 +286,8 @@ const DruxtViewsViewMixin = {
287
286
  }
288
287
  };
289
288
 
289
+ DruxtViewsNuxtModule.meta = require("../package.json");
290
+
290
291
  exports.DruxtViewsFilterMixin = DruxtViewsFilterMixin;
291
292
  exports.DruxtViewsFiltersMixin = DruxtViewsFiltersMixin;
292
293
  exports.DruxtViewsPagerMixin = DruxtViewsPagerMixin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt-views",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "Drupal Views components for Druxt with support for filters, pagination and sorting.",
5
5
  "keywords": [
6
6
  "cms",
@@ -38,17 +38,16 @@
38
38
  "module": "dist/druxt-views.esm.js",
39
39
  "files": [
40
40
  "dist",
41
- "nuxt",
42
41
  "templates"
43
42
  ],
44
43
  "dependencies": {
45
44
  "axios": "^0.21.1",
46
45
  "deepmerge": "^4.2.2",
47
46
  "drupal-jsonapi-params": "^1.1.12",
48
- "druxt": "^0.12.0",
49
- "druxt-blocks": "^0.13.1",
50
- "druxt-entity": "^0.20.0",
51
- "druxt-router": "^0.22.0",
47
+ "druxt": "^0.15.0",
48
+ "druxt-blocks": "^0.14.3",
49
+ "druxt-entity": "^0.21.4",
50
+ "druxt-router": "^0.24.2",
52
51
  "md5": "^2.3.0"
53
52
  },
54
53
  "optionalDependencies": {