druxt-entity 0.24.3 → 0.26.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.
@@ -135,7 +135,7 @@ export default {
135
135
  *
136
136
  * @return {object}
137
137
  */
138
- fields: ({ errors, isEmpty, model, schema, schemaType }) => {
138
+ fields: ({ errors, isEmpty, lang, model, schema, schemaType }) => {
139
139
  if (!schema) return false
140
140
 
141
141
  const fields = {}
@@ -152,6 +152,7 @@ export default {
152
152
  // @todo - Remove deprecated 'data'.
153
153
  data: value,
154
154
  errors: (errors || []).filter((o) => ((o.source || {}).pointer || '').startsWith(`/data/attributes/${field.id}`)),
155
+ langcode: lang,
155
156
  relationship,
156
157
  schema: {
157
158
  config: schema.config,
@@ -170,6 +171,10 @@ export default {
170
171
  this.$fetch()
171
172
  },
172
173
 
174
+ settings() {
175
+ this.$fetch()
176
+ },
177
+
173
178
  schemaType() {
174
179
  this.$fetch()
175
180
  },
@@ -315,7 +320,12 @@ export default {
315
320
 
316
321
  if (this.uuid && !this.value) {
317
322
  const query = this.getQuery(settings)
318
- const resource = await this.getResource({ type: this.type, id: this.uuid, query })
323
+ const resource = await this.getResource({
324
+ id: this.uuid,
325
+ prefix: this.lang,
326
+ type: this.type,
327
+ query
328
+ })
319
329
  const entity = { ...(resource.data || {}) }
320
330
  entity.included = resource.included
321
331
  this.model = JSON.parse(JSON.stringify(entity || {}))
@@ -409,23 +419,37 @@ export default {
409
419
  *
410
420
  * @example @lang js
411
421
  * [
422
+ * 'DruxtEntity[ResourceType][DisplayMode][SchemaType][Langcode]',
412
423
  * 'DruxtEntity[ResourceType][DisplayMode][SchemaType]',
424
+ * 'DruxtEntity[EntityType][DisplayMode][SchemaType][Langcode]',
413
425
  * 'DruxtEntity[EntityType][DisplayMode][SchemaType]',
426
+ * 'DruxtEntity[ResourceType][DisplayMode][Langcode]',
414
427
  * 'DruxtEntity[ResourceType][DisplayMode]',
428
+ * 'DruxtEntity[EntityType][DisplayMode][Langcode]',
415
429
  * 'DruxtEntity[EntityType][DisplayMode]',
430
+ * 'DruxtEntity[ResourceType][Langcode]',
416
431
  * 'DruxtEntity[ResourceType]',
432
+ * 'DruxtEntity[EntityType][Langcode]',
417
433
  * 'DruxtEntity[EntityType]',
434
+ * 'DruxtEntity[DisplayMode][Langcode]',
418
435
  * 'DruxtEntity[DisplayMode]',
419
436
  * ]
420
437
  *
421
438
  * @example <caption>Article Node (default)</caption> @lang js
422
439
  * [
440
+ * 'DruxtEntityNodeArticleDefaultViewEn',
423
441
  * 'DruxtEntityNodeArticleDefaultView',
442
+ * 'DruxtEntityNodeDefaultViewEn',
424
443
  * 'DruxtEntityNodeDefaultView',
444
+ * 'DruxtEntityNodeArticleDefaultEn',
425
445
  * 'DruxtEntityNodeArticleDefault',
446
+ * 'DruxtEntityNodeDefaultEn',
426
447
  * 'DruxtEntityNodeDefault',
448
+ * 'DruxtEntityNodeArticleEn',
427
449
  * 'DruxtEntityNodeArticle',
450
+ * 'DruxtEntityNodeEn',
428
451
  * 'DruxtEntityNode',
452
+ * 'DruxtEntityDefaultEn',
429
453
  * 'DruxtEntityDefault',
430
454
  * ]
431
455
  */
@@ -282,7 +282,11 @@ export default {
282
282
  if (this.isFile && schemaType === 'view') {
283
283
  return h('DruxtEntity', {
284
284
  attrs,
285
- props: { type: item.type, uuid: item.id },
285
+ props: {
286
+ langcode: this.lang,
287
+ type: item.type,
288
+ uuid: item.id
289
+ },
286
290
  scopedSlots: { default: ({ entity }) => h('a', {
287
291
  domProps: {
288
292
  href: (entity.attributes.uri || {}).url,
@@ -296,7 +300,11 @@ export default {
296
300
  if (this.isImage && schemaType === 'view') {
297
301
  return h('DruxtEntity', {
298
302
  attrs,
299
- props: { type: item.type, uuid: item.id },
303
+ props: {
304
+ langcode: this.lang,
305
+ type: item.type,
306
+ uuid: item.id
307
+ },
300
308
  scopedSlots: { default: ({ entity }) => h('img', {
301
309
  domProps: {
302
310
  src: (entity.attributes.uri || {}).url
@@ -335,6 +343,7 @@ export default {
335
343
  return h('DruxtEntity', {
336
344
  attrs,
337
345
  props: {
346
+ langcode: this.lang,
338
347
  mode: this.schema.settings.display.view_mode || 'default',
339
348
  type: item.type,
340
349
  uuid: item.id,
@@ -347,6 +356,7 @@ export default {
347
356
  return h('details', [h('DruxtEntityForm', {
348
357
  attrs,
349
358
  props: {
359
+ langcode: this.lang,
350
360
  mode: this.schema.settings.display.view_mode || 'default',
351
361
  type: item.type,
352
362
  uuid: item.id,
@@ -434,21 +444,33 @@ export default {
434
444
  *
435
445
  * @example @lang js
436
446
  * [
447
+ * 'DruxtField[Type][Id][SchemaType][Langcode]',
437
448
  * 'DruxtField[Type][Id][SchemaType]',
449
+ * 'DruxtField[Type][Id][Langcode]',
438
450
  * 'DruxtField[Type][Id]',
451
+ * 'DruxtField[Type][SchemaType][Langcode]',
439
452
  * 'DruxtField[Type][SchemaType]',
453
+ * 'DruxtField[Default][SchemaType][Langcode]',
440
454
  * 'DruxtField[Default][SchemaType]',
455
+ * 'DruxtField[Type][Langcode]',
441
456
  * 'DruxtField[Type]',
457
+ * 'DruxtField[Default][Langcode]',
442
458
  * 'DruxtField[Default]',
443
459
  * ]
444
460
  *
445
461
  * @example <caption>Media field</caption> @lang js
446
462
  * [
463
+ * 'DruxtFieldEntityReferenceEntityViewFieldMediaImageViewEn',
447
464
  * 'DruxtFieldEntityReferenceEntityViewFieldMediaImageView',
465
+ * 'DruxtFieldEntityReferenceEntityViewFieldMediaImageEn',
448
466
  * 'DruxtFieldEntityReferenceEntityViewFieldMediaImage',
467
+ * 'DruxtFieldEntityReferenceEntityViewViewEn',
449
468
  * 'DruxtFieldEntityReferenceEntityViewView',
469
+ * 'DruxtFieldDefaultViewEn',
450
470
  * 'DruxtFieldDefaultView',
471
+ * 'DruxtFieldEntityReferenceEntityViewEn',
451
472
  * 'DruxtFieldEntityReferenceEntityView',
473
+ * 'DruxtFieldDefaultEn',
452
474
  * 'DruxtFieldDefault',
453
475
  * ]
454
476
  */
@@ -21,7 +21,7 @@ async function DruxtEntityStorybook({ stories }) {
21
21
  try {
22
22
  return {
23
23
  resourceType: `${entity}--${bundle}`,
24
- entities: (await druxt.getCollection(`${entity}--${bundle}`, new DrupalJsonApiParams().addFields(`${entity}--${bundle}`, ["id", "title", "name", "info"]))).data.map((o) => ({
24
+ entities: (await druxt.getCollection(`${entity}--${bundle}`, new DrupalJsonApiParams().addFilter("status", 1).addFields(`${entity}--${bundle}`, ["id", "title", "name", "info"]))).data.map((o) => ({
25
25
  id: o.id,
26
26
  title: (o.attributes || {}).title || (o.attributes || {}).name || (o.attributes || {}).info || o.id
27
27
  }))
@@ -68,7 +68,7 @@ async function DruxtEntityStorybook({ stories }) {
68
68
  }));
69
69
  }
70
70
 
71
- const DruxtEntityNuxtModule = function(moduleOptions = {}) {
71
+ const DruxtEntityNuxtModule = async function(moduleOptions = {}) {
72
72
  const options = {
73
73
  baseUrl: moduleOptions.baseUrl,
74
74
  ...(this.options || {}).druxt || {},
@@ -83,8 +83,8 @@ const DruxtEntityNuxtModule = function(moduleOptions = {}) {
83
83
  }
84
84
  }
85
85
  };
86
- this.addModule(["druxt", options]);
87
- this.addModule(["druxt-schema", { baseUrl: options.baseUrl }]);
86
+ await this.addModule(["druxt", options]);
87
+ await this.addModule(["druxt-schema", { baseUrl: options.baseUrl }]);
88
88
  this.nuxt.hook("components:dirs", (dirs) => {
89
89
  dirs.push({
90
90
  path: join(__dirname, "components"),
@@ -180,6 +180,10 @@ const DruxtEntityMixin = {
180
180
  type: Object,
181
181
  required: true
182
182
  },
183
+ langcode: {
184
+ type: String,
185
+ default: void 0
186
+ },
183
187
  schema: {
184
188
  type: Object,
185
189
  required: true
@@ -213,6 +217,10 @@ const DruxtFieldMixin = {
213
217
  type: Array,
214
218
  default: () => []
215
219
  },
220
+ langcode: {
221
+ type: String,
222
+ default: void 0
223
+ },
216
224
  inner: {
217
225
  type: Object,
218
226
  default: () => ({
@@ -272,5 +280,4 @@ const DruxtFieldMixin = {
272
280
  }
273
281
  };
274
282
 
275
- export default DruxtEntityNuxtModule;
276
- export { DruxtEntityComponentSuggestionMixin, DruxtEntityContextMixin, DruxtEntityMixin, DruxtFieldMixin };
283
+ export { DruxtEntityComponentSuggestionMixin, DruxtEntityContextMixin, DruxtEntityMixin, DruxtFieldMixin, DruxtEntityNuxtModule as default };
@@ -25,7 +25,7 @@ async function DruxtEntityStorybook({ stories }) {
25
25
  try {
26
26
  return {
27
27
  resourceType: `${entity}--${bundle}`,
28
- entities: (await druxt$1.getCollection(`${entity}--${bundle}`, new drupalJsonapiParams.DrupalJsonApiParams().addFields(`${entity}--${bundle}`, ["id", "title", "name", "info"]))).data.map((o) => ({
28
+ entities: (await druxt$1.getCollection(`${entity}--${bundle}`, new drupalJsonapiParams.DrupalJsonApiParams().addFilter("status", 1).addFields(`${entity}--${bundle}`, ["id", "title", "name", "info"]))).data.map((o) => ({
29
29
  id: o.id,
30
30
  title: (o.attributes || {}).title || (o.attributes || {}).name || (o.attributes || {}).info || o.id
31
31
  }))
@@ -72,7 +72,7 @@ async function DruxtEntityStorybook({ stories }) {
72
72
  }));
73
73
  }
74
74
 
75
- const DruxtEntityNuxtModule = function(moduleOptions = {}) {
75
+ const DruxtEntityNuxtModule = async function(moduleOptions = {}) {
76
76
  const options = {
77
77
  baseUrl: moduleOptions.baseUrl,
78
78
  ...(this.options || {}).druxt || {},
@@ -87,8 +87,8 @@ const DruxtEntityNuxtModule = function(moduleOptions = {}) {
87
87
  }
88
88
  }
89
89
  };
90
- this.addModule(["druxt", options]);
91
- this.addModule(["druxt-schema", { baseUrl: options.baseUrl }]);
90
+ await this.addModule(["druxt", options]);
91
+ await this.addModule(["druxt-schema", { baseUrl: options.baseUrl }]);
92
92
  this.nuxt.hook("components:dirs", (dirs) => {
93
93
  dirs.push({
94
94
  path: path.join(__dirname, "components"),
@@ -184,6 +184,10 @@ const DruxtEntityMixin = {
184
184
  type: Object,
185
185
  required: true
186
186
  },
187
+ langcode: {
188
+ type: String,
189
+ default: void 0
190
+ },
187
191
  schema: {
188
192
  type: Object,
189
193
  required: true
@@ -217,6 +221,10 @@ const DruxtFieldMixin = {
217
221
  type: Array,
218
222
  default: () => []
219
223
  },
224
+ langcode: {
225
+ type: String,
226
+ default: void 0
227
+ },
220
228
  inner: {
221
229
  type: Object,
222
230
  default: () => ({
@@ -280,4 +288,4 @@ exports.DruxtEntityComponentSuggestionMixin = DruxtEntityComponentSuggestionMixi
280
288
  exports.DruxtEntityContextMixin = DruxtEntityContextMixin;
281
289
  exports.DruxtEntityMixin = DruxtEntityMixin;
282
290
  exports.DruxtFieldMixin = DruxtFieldMixin;
283
- exports.default = DruxtEntityNuxtModule;
291
+ exports["default"] = DruxtEntityNuxtModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt-entity",
3
- "version": "0.24.3",
3
+ "version": "0.26.0",
4
4
  "description": "Drupal Display Mode powered Entity, Form and Field Druxt components.",
5
5
  "keywords": [
6
6
  "cms",
@@ -46,9 +46,9 @@
46
46
  "dependencies": {
47
47
  "deepmerge": "^4.2.2",
48
48
  "drupal-jsonapi-params": "^2.0.0",
49
- "druxt": "^0.18.2",
50
- "druxt-router": "^0.26.1",
51
- "druxt-schema": "^0.10.3"
49
+ "druxt": "^0.20.0",
50
+ "druxt-router": "^0.28.0",
51
+ "druxt-schema": "^0.11.0"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
@@ -76,7 +76,9 @@ export const <%= mode.charAt(0).toUpperCase() + mode.slice(1) %> = Template.bind
76
76
  }
77
77
  <%= mode.charAt(0).toUpperCase() + mode.slice(1) %>.parameters = {
78
78
  docs: {
79
- storyDescription: 'Render the content entity form using the **<%= mode %>** display mode.',
79
+ description: {
80
+ story: 'Render the content entity form using the **<%= mode %>** display mode.',
81
+ },
80
82
  source: {
81
83
  code: '<DruxtEntityForm\n mode="<%= mode %>"\n type="<%= options.resourceType %>"\n uuid=<%= devalue(((options.entities || [])[0] || {}).id || false) %>\n/>'
82
84
  }
@@ -51,7 +51,9 @@ export const Wrapper = (args, { argTypes }) => ({
51
51
  })
52
52
  Wrapper.parameters = {
53
53
  docs: {
54
- storyDescription: 'The DruxtEntityForm 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```',
54
+ description: {
55
+ story: 'The DruxtEntityForm 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```',
56
+ },
55
57
  source: { code }
56
58
  }
57
59
  }
@@ -70,7 +72,9 @@ export const TemplateInjection = (args, { argTypes }) => ({
70
72
  })
71
73
  TemplateInjection.parameters = {
72
74
  docs: {
73
- storyDescription: 'The DruxtEntityForm component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
75
+ description: {
76
+ story: 'The DruxtEntityForm component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
77
+ },
74
78
  source: { code }
75
79
  }
76
80
  }
@@ -75,7 +75,9 @@ export const <%= mode.charAt(0).toUpperCase() + mode.slice(1) %> = Template.bind
75
75
  }
76
76
  <%= mode.charAt(0).toUpperCase() + mode.slice(1) %>.parameters = {
77
77
  docs: {
78
- storyDescription: 'Render the content entity using the **<%= mode %>** display mode.',
78
+ description: {
79
+ story: 'Render the content entity using the **<%= mode %>** display mode.',
80
+ },
79
81
  source: {
80
82
  code: '<DruxtEntity\n mode="<%= mode %>"\n type="<%= options.resourceType %>"\n uuid=<%= devalue(((options.entities || [])[0] || {}).id || false) %>\n/>'
81
83
  }
@@ -1,4 +1,10 @@
1
1
  import DruxtEntity from 'druxt-entity/dist/components/DruxtEntity.vue'
2
+ import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
3
+
4
+ DruxtEntity.__docgenInfo.props = [
5
+ ...DruxtModule.__docgenInfo.props,
6
+ ...DruxtEntity.__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/Entity/DruxtEntity',
@@ -52,7 +58,9 @@ export const Wrapper = (args, { argTypes }) => ({
52
58
  })
53
59
  Wrapper.parameters = {
54
60
  docs: {
55
- storyDescription: 'The DruxtEntity 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```',
61
+ description: {
62
+ story: 'The DruxtEntity 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```',
63
+ },
56
64
  source: { code }
57
65
  }
58
66
  }
@@ -71,7 +79,9 @@ export const TemplateInjection = (args, { argTypes }) => ({
71
79
  })
72
80
  TemplateInjection.parameters = {
73
81
  docs: {
74
- storyDescription: 'The DruxtEntity component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
82
+ description: {
83
+ story: 'The DruxtEntity component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
84
+ },
75
85
  source: { code }
76
86
  }
77
87
  }