druxt-views 0.18.0 → 0.19.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.
@@ -413,7 +413,11 @@ export default {
413
413
  * @param {object} context - The module component ViewModel.
414
414
  * @returns {ComponentOptions}
415
415
  */
416
- componentOptions: ({ displayId, uuid, viewId }) => ([[viewId || uuid, displayId]]),
416
+ componentOptions: ({ displayId, uuid, view, viewId }) => ([
417
+ [viewId || ((view.data || {}).attributes || {}).drupal_internal__id, displayId],
418
+ [uuid || (view.data || {}).id, displayId],
419
+ [displayId]
420
+ ]),
417
421
 
418
422
  /**
419
423
  * Fetch View configuration resource.
@@ -422,11 +426,16 @@ export default {
422
426
  if (!this.view && (this.uuid || this.viewId)) {
423
427
  if (this.uuid) {
424
428
  this.view = await this.getResource({
429
+ prefix: this.lang,
425
430
  type: this.type,
426
431
  id: this.uuid,
427
432
  })
428
433
  } else {
429
- const collection = await this.getCollection({ type: this.type, query: new DrupalJsonApiParams().addFilter('drupal_internal__id', this.viewId) })
434
+ const collection = await this.getCollection({
435
+ prefix: this.lang,
436
+ type: this.type,
437
+ query: new DrupalJsonApiParams().addFilter('drupal_internal__id', this.viewId)
438
+ })
430
439
  this.view = { data: collection.data[0] }
431
440
  }
432
441
  }
@@ -440,9 +449,10 @@ export default {
440
449
  if (viewId) {
441
450
  const query = this.getQuery(settings)
442
451
  this.resource = await this.getResults({
443
- viewId,
444
452
  displayId: this.displayId,
445
- query: stringify(query)
453
+ prefix: this.lang,
454
+ query: stringify(query),
455
+ viewId
446
456
  })
447
457
  }
448
458
  },
@@ -559,6 +569,7 @@ export default {
559
569
  ref: 'attachements_before',
560
570
  props: {
561
571
  displayId,
572
+ langcode: this.lang,
562
573
  type: this.type,
563
574
  uuid: this.uuid,
564
575
  viewId: this.viewId,
@@ -580,6 +591,7 @@ export default {
580
591
  attrs: { ...attrs },
581
592
  key: result.id,
582
593
  props: {
594
+ langcode: this.lang,
583
595
  mode: this.mode,
584
596
  type: result.type,
585
597
  uuid: result.id
@@ -614,6 +626,7 @@ export default {
614
626
  ref: 'attachements_after',
615
627
  props: {
616
628
  displayId,
629
+ langcode: this.lang,
617
630
  type: this.type,
618
631
  uuid: this.uuid,
619
632
  viewId: this.viewId,
@@ -638,14 +651,30 @@ export default {
638
651
  *
639
652
  * @example @lang js
640
653
  * [
654
+ * 'DruxtView[ViewId][DisplayId][Langcode]',
641
655
  * 'DruxtView[ViewId][DisplayId]',
642
- * 'DruxtView[ViewId]'
656
+ * 'DruxtView[ViewId][Langcode]',
657
+ * 'DruxtView[ViewId]',
658
+ * 'DruxtView[UUID][DisplayId][Langcode]',
659
+ * 'DruxtView[UUID][DisplayId]',
660
+ * 'DruxtView[UUID][Langcode]',
661
+ * 'DruxtView[UUID]',
662
+ * 'DruxtView[DisplayId][Langcode]',
663
+ * 'DruxtView[DisplayId]',
643
664
  * ]
644
665
  *
645
666
  * @example <caption>featured_articles (default)</caption> @lang js
646
667
  * [
668
+ * 'DruxtViewFeaturedArticlesDefaultEn',
647
669
  * 'DruxtViewFeaturedArticlesDefault',
648
- * 'DruxtViewFeaturedArticles'
670
+ * 'DruxtViewFeaturedArticlesEn',
671
+ * 'DruxtViewFeaturedArticles',
672
+ * 'DruxtView16f5d68e5bae4d7aa61c6b2bc3b6d3b6DefaultEn',
673
+ * 'DruxtView16f5d68e5bae4d7aa61c6b2bc3b6d3b6Default',
674
+ * 'DruxtView16f5d68e5bae4d7aa61c6b2bc3b6d3b6En',
675
+ * 'DruxtView16f5d68e5bae4d7aa61c6b2bc3b6d3b6',
676
+ * 'DruxtViewDefaultEn',
677
+ * 'DruxtViewDefault',
649
678
  * ]
650
679
  */
651
680
 
@@ -55,16 +55,25 @@ export default {
55
55
  *
56
56
  * @example @lang js
57
57
  * [
58
+ * 'DruxtViewsFilter[FilterId][Langcode]',
58
59
  * 'DruxtViewsFilter[FilterId]',
60
+ * 'DruxtViewsFilter[PluginId][FilterId][Langcode]',
59
61
  * 'DruxtViewsFilter[PluginId][FilterId]',
62
+ * 'DruxtViewsFilter[PluginId][Langcode]',
63
+ * 'DruxtViewsFilter[PluginId]',
64
+ * 'DruxtViewsFilter[Default][Langcode]'
60
65
  * 'DruxtViewsFilter[Default]'
61
66
  * ]
62
67
  *
63
68
  * @example @lang js
64
69
  * [
70
+ * 'DruxtViewsFilterTaxonomyIndexTidTypeTargetIdEn',
65
71
  * 'DruxtViewsFilterTaxonomyIndexTidTypeTargetId',
72
+ * 'DruxtViewsFilterTypeTargetIdEn',
66
73
  * 'DruxtViewsFilterTypeTargetId',
74
+ * 'DruxtViewsFilterTaxonomyIndexTidEn',
67
75
  * 'DruxtViewsFilterTaxonomyIndexTid',
76
+ * 'DruxtViewsFilterDefaultEn',
68
77
  * 'DruxtViewsFilterDefault',
69
78
  * ]
70
79
  */
@@ -125,13 +125,17 @@ export default {
125
125
  *
126
126
  * @example @lang js
127
127
  * [
128
+ * 'DruxtViewsFilters[Type][Langcode]',
128
129
  * 'DruxtViewsFilters[Type]',
130
+ * 'DruxtViewsFilters[Default][Langcode]'
129
131
  * 'DruxtViewsFilters[Default]'
130
132
  * ]
131
133
  *
132
134
  * @example @lang js
133
135
  * [
136
+ * 'DruxtViewsFiltersBasicEn',
134
137
  * 'DruxtViewsFiltersBasic',
138
+ * 'DruxtViewsFiltersDefaultEn'
135
139
  * 'DruxtViewsFiltersDefault'
136
140
  * ]
137
141
  */
@@ -178,13 +178,17 @@ export default {
178
178
  *
179
179
  * @example @lang js
180
180
  * [
181
+ * 'DruxtViewsPager[Type][Langcode]',
181
182
  * 'DruxtViewsPager[Type]',
183
+ * 'DruxtViewsPager[Default][Langcode]',
182
184
  * 'DruxtViewsPager[Default]'
183
185
  * ]
184
186
  *
185
187
  * @example @lang js
186
188
  * [
189
+ * 'DruxtViewsPagerFullEn',
187
190
  * 'DruxtViewsPagerFull',
191
+ * 'DruxtViewsPagerDefaultEn',
188
192
  * 'DruxtViewsPagerDefault'
189
193
  * ]
190
194
  */
@@ -123,13 +123,17 @@ export default {
123
123
  *
124
124
  * @example @lang js
125
125
  * [
126
+ * 'DruxtViewsSorts[Type][Langcode]',
126
127
  * 'DruxtViewsSorts[Type]',
128
+ * 'DruxtViewsSorts[Default][Langcode]',
127
129
  * 'DruxtViewsSorts[Default]'
128
130
  * ]
129
131
  *
130
132
  * @example @lang js
131
133
  * [
134
+ * 'DruxtViewsSortsBasicEn',
132
135
  * 'DruxtViewsSortsBasic',
136
+ * 'DruxtViewsSortsDefaultEn',
133
137
  * 'DruxtViewsSortsDefault'
134
138
  * ]
135
139
  */
@@ -22,15 +22,13 @@ import { DruxtBlocksBlockMixin } from 'druxt-blocks'
22
22
  * uuid="43d613c6-ab66-453d-bce1-e1dfc990b4a1"
23
23
  * />
24
24
  *
25
- * @see {@link https://blocks.druxtjs.org/api/components/DruxtBlock.html|DruxtBlock}
25
+ * @see {@link https://blocks.druxtjs.org/api/components/DruxtBlock|DruxtBlock}
26
26
  */
27
27
  export default {
28
28
  name: 'DruxtBlockViewsBlock',
29
29
 
30
30
  /**
31
- * Vue.js Mixins.
32
- *
33
- * @see {@link https://blocks.druxtjs.org/api/mixins/block.html|DruxtBlocksBlockMixin}
31
+ * @see {@link https://blocks.druxtjs.org/api/mixins/block|DruxtBlocksBlockMixin}
34
32
  */
35
33
  mixins: [DruxtBlocksBlockMixin],
36
34
 
@@ -50,17 +48,16 @@ export default {
50
48
  */
51
49
  async fetch() {
52
50
  const results = await this.getCollection({
53
- type: 'view--view',
51
+ prefix: this.langcode,
54
52
  query: new DrupalJsonApiParams()
55
53
  .addFilter('drupal_internal__id', this.viewId)
56
- .addFields('view--view', ['id'])
54
+ .addFields('view--view', ['id']),
55
+ type: 'view--view',
57
56
  })
58
57
  this.uuid = results.data[0].id
59
58
  },
60
59
 
61
- /**
62
- * Vue.js Computed properties.
63
- */
60
+ /** */
64
61
  computed: {
65
62
  /**
66
63
  * The View Display ID.
@@ -83,6 +80,7 @@ export default {
83
80
 
84
81
  return {
85
82
  displayId: this.displayId,
83
+ langcode: this.langcode,
86
84
  uuid: this.uuid,
87
85
  viewId: this.viewId
88
86
  }
@@ -3,6 +3,7 @@ import merge from 'deepmerge';
3
3
  import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
4
4
  import { DruxtClient } from 'druxt';
5
5
  import md5 from 'md5';
6
+ import Vue from 'vue';
6
7
  import { DruxtEntityContextMixin } from 'druxt-entity';
7
8
 
8
9
  async function DruxtViewsStorybook({ stories }) {
@@ -49,7 +50,7 @@ async function DruxtViewsStorybook({ stories }) {
49
50
  stories.push(resolve(options.buildDir, "./stories/druxt-views.*.stories.js"));
50
51
  }
51
52
 
52
- const DruxtViewsNuxtModule = function(moduleOptions = {}) {
53
+ const DruxtViewsNuxtModule = async function(moduleOptions = {}) {
53
54
  const options = {
54
55
  baseUrl: moduleOptions.baseUrl,
55
56
  ...(this.options || {}).druxt || {},
@@ -63,10 +64,10 @@ const DruxtViewsNuxtModule = function(moduleOptions = {}) {
63
64
  dirs.push({ path: join(__dirname, "components") });
64
65
  dirs.push({ path: join(__dirname, "components/blocks") });
65
66
  });
66
- this.addModule(["druxt", options]);
67
+ await this.addModule(["druxt", options]);
67
68
  const modules = ["druxt-entity", "druxt-schema"];
68
69
  for (const module of modules) {
69
- this.addModule([module, { baseUrl: options.baseUrl }]);
70
+ await this.addModule([module, { baseUrl: options.baseUrl }]);
70
71
  }
71
72
  this.addPlugin({
72
73
  src: resolve(__dirname, "../templates/store.js"),
@@ -90,24 +91,26 @@ const DruxtViewsStore = ({ store }) => {
90
91
  results: {}
91
92
  }),
92
93
  mutations: {
93
- addResults(state, { results, viewId, displayId, hash }) {
94
+ addResults(state, { results, viewId, displayId, prefix, hash }) {
94
95
  if (!results || !viewId || !displayId || !hash)
95
96
  return;
96
97
  if (!state.results[viewId])
97
- state.results[viewId] = {};
98
+ Vue.set(state.results, viewId, {});
98
99
  if (!state.results[viewId][displayId])
99
- state.results[viewId][displayId] = {};
100
- state.results[viewId][displayId][hash] = results;
100
+ Vue.set(state.results[viewId], displayId, {});
101
+ if (!state.results[viewId][displayId][prefix])
102
+ Vue.set(state.results[viewId][displayId], prefix, {});
103
+ Vue.set(state.results[viewId][displayId][prefix], hash, results);
101
104
  }
102
105
  },
103
106
  actions: {
104
- async getResults({ commit, state }, { viewId, displayId, query }) {
107
+ async getResults({ commit, state }, { viewId, displayId, query, prefix }) {
105
108
  const hash = query ? md5(this.$druxt.buildQueryUrl("", query)) : "_default";
106
- if (typeof ((state.results[viewId] || {})[displayId] || {})[hash] !== "undefined") {
107
- return state.results[viewId][displayId][hash];
109
+ if (typeof (((state.results[viewId] || {})[displayId] || {})[prefix] || {})[hash] !== "undefined") {
110
+ return state.results[viewId][displayId][prefix][hash];
108
111
  }
109
- const results = await this.$druxt.getResource(`views--${viewId}`, displayId, query);
110
- commit("addResults", { results, viewId, displayId, hash });
112
+ const results = await this.$druxt.getResource(`views--${viewId}`, displayId, query, prefix);
113
+ commit("addResults", { results, viewId, displayId, prefix, hash });
111
114
  return results;
112
115
  }
113
116
  }
@@ -249,6 +252,10 @@ const DruxtViewsViewMixin = {
249
252
  type: Object,
250
253
  require: true
251
254
  },
255
+ langcode: {
256
+ type: String,
257
+ default: void 0
258
+ },
252
259
  mode: {
253
260
  type: [Boolean, String],
254
261
  default: "default"
@@ -286,5 +293,4 @@ const DruxtViewsViewMixin = {
286
293
 
287
294
  DruxtViewsNuxtModule.meta = require("../package.json");
288
295
 
289
- export default DruxtViewsNuxtModule;
290
- export { DruxtViewsFilterMixin, DruxtViewsFiltersMixin, DruxtViewsPagerMixin, DruxtViewsSortsMixin, DruxtViewsStore, DruxtViewsViewMixin };
296
+ export { DruxtViewsFilterMixin, DruxtViewsFiltersMixin, DruxtViewsPagerMixin, DruxtViewsSortsMixin, DruxtViewsStore, DruxtViewsViewMixin, DruxtViewsNuxtModule as default };
@@ -7,12 +7,14 @@ const merge = require('deepmerge');
7
7
  const drupalJsonapiParams = require('drupal-jsonapi-params');
8
8
  const druxt = require('druxt');
9
9
  const md5 = require('md5');
10
+ const Vue = require('vue');
10
11
  const druxtEntity = require('druxt-entity');
11
12
 
12
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
14
 
14
15
  const merge__default = /*#__PURE__*/_interopDefaultLegacy(merge);
15
16
  const md5__default = /*#__PURE__*/_interopDefaultLegacy(md5);
17
+ const Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
16
18
 
17
19
  async function DruxtViewsStorybook({ stories }) {
18
20
  const { addTemplate, options } = this;
@@ -24,7 +26,7 @@ async function DruxtViewsStorybook({ stories }) {
24
26
  for (const view of collections) {
25
27
  const { description, display, drupal_internal__id, label } = view.attributes;
26
28
  const displays = Object.values(display).filter((item) => {
27
- const options2 = item.id === "default" ? item : merge__default['default'](display.default, item);
29
+ const options2 = item.id === "default" ? item : merge__default["default"](display.default, item);
28
30
  const extenders = options2.display_options.display_extenders;
29
31
  const enabled = !(!Array.isArray(extenders) && !(extenders.jsonapi_views || {}).enabled);
30
32
  return enabled ? options2.display_options.row.type.startsWith("entity:") : false;
@@ -58,7 +60,7 @@ async function DruxtViewsStorybook({ stories }) {
58
60
  stories.push(path.resolve(options.buildDir, "./stories/druxt-views.*.stories.js"));
59
61
  }
60
62
 
61
- const DruxtViewsNuxtModule = function(moduleOptions = {}) {
63
+ const DruxtViewsNuxtModule = async function(moduleOptions = {}) {
62
64
  const options = {
63
65
  baseUrl: moduleOptions.baseUrl,
64
66
  ...(this.options || {}).druxt || {},
@@ -72,10 +74,10 @@ const DruxtViewsNuxtModule = function(moduleOptions = {}) {
72
74
  dirs.push({ path: path.join(__dirname, "components") });
73
75
  dirs.push({ path: path.join(__dirname, "components/blocks") });
74
76
  });
75
- this.addModule(["druxt", options]);
77
+ await this.addModule(["druxt", options]);
76
78
  const modules = ["druxt-entity", "druxt-schema"];
77
79
  for (const module of modules) {
78
- this.addModule([module, { baseUrl: options.baseUrl }]);
80
+ await this.addModule([module, { baseUrl: options.baseUrl }]);
79
81
  }
80
82
  this.addPlugin({
81
83
  src: path.resolve(__dirname, "../templates/store.js"),
@@ -99,24 +101,26 @@ const DruxtViewsStore = ({ store }) => {
99
101
  results: {}
100
102
  }),
101
103
  mutations: {
102
- addResults(state, { results, viewId, displayId, hash }) {
104
+ addResults(state, { results, viewId, displayId, prefix, hash }) {
103
105
  if (!results || !viewId || !displayId || !hash)
104
106
  return;
105
107
  if (!state.results[viewId])
106
- state.results[viewId] = {};
108
+ Vue__default["default"].set(state.results, viewId, {});
107
109
  if (!state.results[viewId][displayId])
108
- state.results[viewId][displayId] = {};
109
- state.results[viewId][displayId][hash] = results;
110
+ Vue__default["default"].set(state.results[viewId], displayId, {});
111
+ if (!state.results[viewId][displayId][prefix])
112
+ Vue__default["default"].set(state.results[viewId][displayId], prefix, {});
113
+ Vue__default["default"].set(state.results[viewId][displayId][prefix], hash, results);
110
114
  }
111
115
  },
112
116
  actions: {
113
- async getResults({ commit, state }, { viewId, displayId, query }) {
114
- const hash = query ? md5__default['default'](this.$druxt.buildQueryUrl("", query)) : "_default";
115
- if (typeof ((state.results[viewId] || {})[displayId] || {})[hash] !== "undefined") {
116
- return state.results[viewId][displayId][hash];
117
+ async getResults({ commit, state }, { viewId, displayId, query, prefix }) {
118
+ const hash = query ? md5__default["default"](this.$druxt.buildQueryUrl("", query)) : "_default";
119
+ if (typeof (((state.results[viewId] || {})[displayId] || {})[prefix] || {})[hash] !== "undefined") {
120
+ return state.results[viewId][displayId][prefix][hash];
117
121
  }
118
- const results = await this.$druxt.getResource(`views--${viewId}`, displayId, query);
119
- commit("addResults", { results, viewId, displayId, hash });
122
+ const results = await this.$druxt.getResource(`views--${viewId}`, displayId, query, prefix);
123
+ commit("addResults", { results, viewId, displayId, prefix, hash });
120
124
  return results;
121
125
  }
122
126
  }
@@ -258,6 +262,10 @@ const DruxtViewsViewMixin = {
258
262
  type: Object,
259
263
  require: true
260
264
  },
265
+ langcode: {
266
+ type: String,
267
+ default: void 0
268
+ },
261
269
  mode: {
262
270
  type: [Boolean, String],
263
271
  default: "default"
@@ -301,4 +309,4 @@ exports.DruxtViewsPagerMixin = DruxtViewsPagerMixin;
301
309
  exports.DruxtViewsSortsMixin = DruxtViewsSortsMixin;
302
310
  exports.DruxtViewsStore = DruxtViewsStore;
303
311
  exports.DruxtViewsViewMixin = DruxtViewsViewMixin;
304
- exports.default = DruxtViewsNuxtModule;
312
+ exports["default"] = DruxtViewsNuxtModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt-views",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Drupal Views components for Druxt with support for filters, pagination and sorting.",
5
5
  "keywords": [
6
6
  "cms",
@@ -41,13 +41,13 @@
41
41
  "templates"
42
42
  ],
43
43
  "dependencies": {
44
- "axios": "^0.21.1",
44
+ "axios": "^0.27.2",
45
45
  "deepmerge": "^4.2.2",
46
- "drupal-jsonapi-params": "^1.1.12",
47
- "druxt": "^0.17.0",
48
- "druxt-blocks": "^0.15.0",
49
- "druxt-entity": "^0.24.0",
50
- "druxt-router": "^0.26.0",
46
+ "drupal-jsonapi-params": "^2.0.0",
47
+ "druxt": "^0.19.0",
48
+ "druxt-blocks": "^0.16.0",
49
+ "druxt-entity": "^0.25.0",
50
+ "druxt-router": "^0.27.0",
51
51
  "md5": "^2.3.0"
52
52
  },
53
53
  "optionalDependencies": {