druxt-views 0.18.2 → 0.20.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.
@@ -281,8 +281,8 @@ export default {
281
281
  },
282
282
 
283
283
  watch: {
284
- async '$route.query'(to) {
285
- if (!Object.entries(to).length) {
284
+ '$route.query'(to) {
285
+ if (!Object.entries(to || {}).length) {
286
286
  this.model = {
287
287
  filter: {},
288
288
  page: null,
@@ -291,42 +291,42 @@ export default {
291
291
  }
292
292
  },
293
293
 
294
- async displayId() {
295
- await this.$fetch()
294
+ arguments() {
295
+ this.$fetch()
296
+ },
297
+
298
+ displayId() {
299
+ this.$fetch()
296
300
  },
297
301
 
298
302
  'model.filter': {
299
303
  deep: true,
300
- async handler(to, from) {
301
- if (!Object.entries(to).length && !Object.entries(from).length) {
304
+ handler(to, from) {
305
+ if (!Object.entries(to || {}).length && !Object.entries(from || {}).length) {
302
306
  return
303
307
  }
304
- await this.$fetch()
308
+ this.$fetch()
305
309
  },
306
310
  },
307
311
 
308
- async 'model.page'(to, from) {
312
+ 'model.page'(to, from) {
309
313
  if (to !== from) {
310
- await this.$fetch()
314
+ this.$fetch()
311
315
  }
312
316
  },
313
317
 
314
- async 'model.sort'(to, from) {
318
+ 'model.sort'(to, from) {
315
319
  if (to !== from) {
316
- await this.$fetch()
320
+ this.$fetch()
317
321
  }
318
322
  },
319
323
 
320
- async query() {
321
- await this.$fetch()
322
- },
323
-
324
- async uuid() {
325
- await this.$fetch()
324
+ uuid() {
325
+ this.$fetch()
326
326
  },
327
327
 
328
- async viewId() {
329
- await this.$fetch()
328
+ viewId() {
329
+ this.$fetch()
330
330
  },
331
331
  },
332
332
 
@@ -426,11 +426,16 @@ export default {
426
426
  if (!this.view && (this.uuid || this.viewId)) {
427
427
  if (this.uuid) {
428
428
  this.view = await this.getResource({
429
+ prefix: this.lang,
429
430
  type: this.type,
430
431
  id: this.uuid,
431
432
  })
432
433
  } else {
433
- 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
+ })
434
439
  this.view = { data: collection.data[0] }
435
440
  }
436
441
  }
@@ -444,9 +449,10 @@ export default {
444
449
  if (viewId) {
445
450
  const query = this.getQuery(settings)
446
451
  this.resource = await this.getResults({
447
- viewId,
448
452
  displayId: this.displayId,
449
- query: stringify(query)
453
+ prefix: this.lang,
454
+ query: stringify(query),
455
+ viewId
450
456
  })
451
457
  }
452
458
  },
@@ -563,6 +569,7 @@ export default {
563
569
  ref: 'attachements_before',
564
570
  props: {
565
571
  displayId,
572
+ langcode: this.lang,
566
573
  type: this.type,
567
574
  uuid: this.uuid,
568
575
  viewId: this.viewId,
@@ -584,6 +591,7 @@ export default {
584
591
  attrs: { ...attrs },
585
592
  key: result.id,
586
593
  props: {
594
+ langcode: this.lang,
587
595
  mode: this.mode,
588
596
  type: result.type,
589
597
  uuid: result.id
@@ -618,6 +626,7 @@ export default {
618
626
  ref: 'attachements_after',
619
627
  props: {
620
628
  displayId,
629
+ langcode: this.lang,
621
630
  type: this.type,
622
631
  uuid: this.uuid,
623
632
  viewId: this.viewId,
@@ -642,19 +651,29 @@ export default {
642
651
  *
643
652
  * @example @lang js
644
653
  * [
654
+ * 'DruxtView[ViewId][DisplayId][Langcode]',
645
655
  * 'DruxtView[ViewId][DisplayId]',
656
+ * 'DruxtView[ViewId][Langcode]',
646
657
  * 'DruxtView[ViewId]',
658
+ * 'DruxtView[UUID][DisplayId][Langcode]',
647
659
  * 'DruxtView[UUID][DisplayId]',
660
+ * 'DruxtView[UUID][Langcode]',
648
661
  * 'DruxtView[UUID]',
662
+ * 'DruxtView[DisplayId][Langcode]',
649
663
  * 'DruxtView[DisplayId]',
650
664
  * ]
651
665
  *
652
666
  * @example <caption>featured_articles (default)</caption> @lang js
653
667
  * [
668
+ * 'DruxtViewFeaturedArticlesDefaultEn',
654
669
  * 'DruxtViewFeaturedArticlesDefault',
670
+ * 'DruxtViewFeaturedArticlesEn',
655
671
  * 'DruxtViewFeaturedArticles',
672
+ * 'DruxtView16f5d68e5bae4d7aa61c6b2bc3b6d3b6DefaultEn',
656
673
  * 'DruxtView16f5d68e5bae4d7aa61c6b2bc3b6d3b6Default',
674
+ * 'DruxtView16f5d68e5bae4d7aa61c6b2bc3b6d3b6En',
657
675
  * 'DruxtView16f5d68e5bae4d7aa61c6b2bc3b6d3b6',
676
+ * 'DruxtViewDefaultEn',
658
677
  * 'DruxtViewDefault',
659
678
  * ]
660
679
  */
@@ -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
  */
@@ -28,8 +28,6 @@ export default {
28
28
  name: 'DruxtBlockViewsBlock',
29
29
 
30
30
  /**
31
- * Vue.js Mixins.
32
- *
33
31
  * @see {@link https://blocks.druxtjs.org/api/mixins/block|DruxtBlocksBlockMixin}
34
32
  */
35
33
  mixins: [DruxtBlocksBlockMixin],
@@ -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.2",
3
+ "version": "0.20.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
46
  "drupal-jsonapi-params": "^2.0.0",
47
- "druxt": "^0.18.2",
48
- "druxt-blocks": "^0.15.2",
49
- "druxt-entity": "^0.24.3",
50
- "druxt-router": "^0.26.1",
47
+ "druxt": "^0.20.0",
48
+ "druxt-blocks": "^0.16.3",
49
+ "druxt-entity": "^0.26.0",
50
+ "druxt-router": "^0.28.0",
51
51
  "md5": "^2.3.0"
52
52
  },
53
53
  "optionalDependencies": {
@@ -1,4 +1,10 @@
1
1
  import DruxtView from 'druxt-views/dist/components/DruxtView.vue'
2
+ import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
3
+
4
+ DruxtView.__docgenInfo.props = [
5
+ ...DruxtModule.__docgenInfo.props,
6
+ ...DruxtView.__docgenInfo.props,
7
+ ].sort((a, b) => a.name < b.name ? -1 : 1).filter((o) => o.name !== 'v-model')
2
8
 
3
9
  export default {
4
10
  title: 'Druxt/Views/DruxtView',
@@ -57,7 +63,9 @@ export const Wrapper = (args, { argTypes }) => ({
57
63
  })
58
64
  Wrapper.parameters = {
59
65
  docs: {
60
- storyDescription: 'The DruxtView component can be themed by using a Druxt Wrapper component.\n\nCreate an appropriately named component, using the relevant component option, with the following boilerplate:\n\n```jsx\n' + code + '\n```',
66
+ description: {
67
+ story: 'The DruxtView component can be themed by using a Druxt Wrapper component.\n\nCreate an appropriately named component, using the relevant component option, with the following boilerplate:\n\n```jsx\n' + code + '\n```',
68
+ },
61
69
  source: { code }
62
70
  }
63
71
  }
@@ -76,7 +84,9 @@ export const TemplateInjection = (args, { argTypes }) => ({
76
84
  })
77
85
  TemplateInjection.parameters = {
78
86
  docs: {
79
- storyDescription: 'The DruxtView component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
87
+ description: {
88
+ story: 'The DruxtView component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
89
+ },
80
90
  source: { code }
81
91
  }
82
92
  }