druxt-entity 0.26.1 → 0.27.1

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.
@@ -377,11 +377,17 @@ export default {
377
377
  const scopedSlots = {}
378
378
 
379
379
  if (!this.schema) {
380
+ const summary = `Missing display settings for resource type: '${this.type}--${this.mode}'`
381
+ const description = [
382
+ h('p', 'Create a Druxt theme component to render the entity.'),
383
+ ]
384
+
380
385
  scopedSlots.debug = () => h('DruxtDebug',
381
- { props: { summary: `Missing schema for '${this.type}--${this.mode}'`} },
386
+ { props: { summary } },
382
387
  [
383
- h('label', ['Component options:', h('ul', this.component.options.map((s) => h('li', [s])))]),
384
- h('label', ['Entity:', h('pre', [JSON.stringify(this.entity, null, ' ')])]),
388
+ h('div', description),
389
+ !!this.component.options.length && h('DruxtDevelTemplate', { props: { options: this.component.options }}),
390
+ h('details', [h('summary', 'JSON:API resource'), h('pre', [h('code', [JSON.stringify(this.model, null, ' ')])])])
385
391
  ]
386
392
  )
387
393
  return scopedSlots
@@ -414,7 +420,22 @@ export default {
414
420
 
415
421
  return scopedSlots
416
422
  },
417
- },
423
+
424
+ /**
425
+ * Druxt development template tool configuration.
426
+ */
427
+ template: {
428
+ debug: '{ entity, schema }',
429
+ mixins: {
430
+ 'DruxtEntityMixin': 'druxt-entity'
431
+ },
432
+ druxt: {
433
+ 'query.//fields': ['name', 'path', 'title'],
434
+ 'query.//include': [],
435
+ 'query.//schema': true
436
+ }
437
+ }
438
+ }
418
439
  }
419
440
 
420
441
  /**
@@ -293,7 +293,7 @@ export default {
293
293
  // File: View.
294
294
  if (this.isFile && schemaType === 'view') {
295
295
  return h('DruxtEntity', {
296
- attrs,
296
+ attrs: { ...attrs, ...self.$attrs },
297
297
  props: {
298
298
  langcode: this.lang,
299
299
  type: item.type,
@@ -311,7 +311,7 @@ export default {
311
311
  // Image: View
312
312
  if (this.isImage && schemaType === 'view') {
313
313
  return h('DruxtEntity', {
314
- attrs,
314
+ attrs: { ...attrs, ...self.$attrs },
315
315
  props: {
316
316
  langcode: this.lang,
317
317
  type: item.type,
@@ -353,7 +353,7 @@ export default {
353
353
  // Relationship: View.
354
354
  if (this.relationship && (item || {}).id && schemaType === 'view') {
355
355
  return h('DruxtEntity', {
356
- attrs,
356
+ attrs: { ...attrs, ...self.$attrs },
357
357
  props: {
358
358
  langcode: this.lang,
359
359
  mode: this.schema.settings.display.view_mode || 'default',
@@ -366,7 +366,7 @@ export default {
366
366
  // Relationship: Form.
367
367
  if (this.relationship && (item || {}).id && schemaType === 'form') {
368
368
  return h('details', [h('DruxtEntityForm', {
369
- attrs,
369
+ attrs: { ...attrs, ...self.$attrs },
370
370
  props: {
371
371
  langcode: this.lang,
372
372
  mode: this.schema.settings.display.view_mode || 'default',
@@ -416,12 +416,17 @@ export default {
416
416
 
417
417
  // Fallback: Provide debug data.
418
418
  if (this.$nuxt.context.isDev) {
419
+ const summary = `Missing Vue template for '${this.schema.id} (${this.schema.type}')`
420
+ const description = [
421
+ h('p', 'Create a Druxt theme component to render the field.'),
422
+ ]
419
423
  return h('DruxtDebug',
420
- { props: { summary: `Missing wrapper component for '${this.schema.id} (${this.schema.type}')`} },
424
+ { props: { summary } },
421
425
  [
422
- h('label', ['Component options:', h('ul', this.component.options.map((s) => h('li', [s])))]),
423
- h('label', ['Data:', h('pre', [JSON.stringify(item, null, ' ')])]),
424
- h('label', ['Schema:', h('pre', [JSON.stringify(this.schema, null, ' ')])])
426
+ h('div', description),
427
+ !!this.component.options.length && h('DruxtDevelTemplate', { props: { options: this.component.options }}),
428
+ h('details', [h('summary', 'Data'), h('pre', [h('code', [JSON.stringify(item, null, ' ')])])]),
429
+ !!this.schema && h('details', [h('summary', 'Schema'), h('pre', [h('code', [JSON.stringify(this.schema, null, ' ')])])])
425
430
  ]
426
431
  )
427
432
  }
@@ -446,6 +451,15 @@ export default {
446
451
 
447
452
  return scopedSlots
448
453
  },
454
+
455
+ /**
456
+ * Druxt development template tool configuration.
457
+ */
458
+ template: {
459
+ mixins: {
460
+ 'DruxtFieldMixin': 'druxt-entity'
461
+ }
462
+ }
449
463
  },
450
464
  }
451
465
 
@@ -177,8 +177,8 @@ const DruxtEntityMixin = {
177
177
  require: true
178
178
  },
179
179
  fields: {
180
- type: Object,
181
- required: true
180
+ type: [Object, Boolean],
181
+ default: void 0
182
182
  },
183
183
  langcode: {
184
184
  type: String,
@@ -186,7 +186,7 @@ const DruxtEntityMixin = {
186
186
  },
187
187
  schema: {
188
188
  type: Object,
189
- required: true
189
+ default: void 0
190
190
  },
191
191
  value: {
192
192
  type: Object,
@@ -197,7 +197,7 @@ const DruxtEntityMixin = {
197
197
  model: value
198
198
  }),
199
199
  computed: {
200
- classes: ({ schema }) => [
200
+ classes: ({ schema }) => schema && [
201
201
  schema.id,
202
202
  schema.resourceType,
203
203
  schema.config.entityType,
@@ -181,8 +181,8 @@ const DruxtEntityMixin = {
181
181
  require: true
182
182
  },
183
183
  fields: {
184
- type: Object,
185
- required: true
184
+ type: [Object, Boolean],
185
+ default: void 0
186
186
  },
187
187
  langcode: {
188
188
  type: String,
@@ -190,7 +190,7 @@ const DruxtEntityMixin = {
190
190
  },
191
191
  schema: {
192
192
  type: Object,
193
- required: true
193
+ default: void 0
194
194
  },
195
195
  value: {
196
196
  type: Object,
@@ -201,7 +201,7 @@ const DruxtEntityMixin = {
201
201
  model: value
202
202
  }),
203
203
  computed: {
204
- classes: ({ schema }) => [
204
+ classes: ({ schema }) => schema && [
205
205
  schema.id,
206
206
  schema.resourceType,
207
207
  schema.config.entityType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt-entity",
3
- "version": "0.26.1",
3
+ "version": "0.27.1",
4
4
  "description": "Drupal Display Mode powered Entity, Form and Field Druxt components.",
5
5
  "keywords": [
6
6
  "cms",
@@ -45,10 +45,10 @@
45
45
  ],
46
46
  "dependencies": {
47
47
  "deepmerge": "^4.2.2",
48
- "drupal-jsonapi-params": "^2.0.0",
49
- "druxt": "^0.20.0",
50
- "druxt-router": "^0.28.0",
51
- "druxt-schema": "^0.11.0"
48
+ "drupal-jsonapi-params": "^2.1.0",
49
+ "druxt": "^0.21.0",
50
+ "druxt-router": "^0.29.0",
51
+ "druxt-schema": "^0.11.1"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"