druxt-entity 0.26.0 → 0.27.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.
@@ -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
@@ -396,7 +402,12 @@ export default {
396
402
  on: {
397
403
  input: (value) => {
398
404
  const type = !field.relationship ? 'attributes' : 'relationships'
399
- this.model[type][id] = value
405
+ if (value) {
406
+ this.model[type][id] = value
407
+ }
408
+ else if (this.model[type][id]) {
409
+ delete this.model[type][id]
410
+ }
400
411
  this.$emit('input', this.model)
401
412
  }
402
413
  },
@@ -409,7 +420,22 @@ export default {
409
420
 
410
421
  return scopedSlots
411
422
  },
412
- },
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
+ }
413
439
  }
414
440
 
415
441
  /**
@@ -2,6 +2,10 @@
2
2
 
3
3
  import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
4
4
 
5
+ // Extract the DruxtModule model watch.
6
+ const modelWatch = DruxtModule.watch.model
7
+ delete DruxtModule.watch.model
8
+
5
9
  /**
6
10
  * Renders a Drupal Field using Drupals by field type and formatter settings.
7
11
  *
@@ -166,6 +170,14 @@ export default {
166
170
  this.component.props.errors = this.errors
167
171
  this.component.propsData.errors = this.errors
168
172
  },
173
+
174
+ model() {
175
+ // Sanitize empty string based fields.
176
+ if (this.model === '') { this.model = undefined }
177
+
178
+ // Invoke the DruxtModule model watch callback.
179
+ modelWatch.call(this)
180
+ },
169
181
  },
170
182
 
171
183
  /** DruxtModule settings */
@@ -404,12 +416,17 @@ export default {
404
416
 
405
417
  // Fallback: Provide debug data.
406
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
+ ]
407
423
  return h('DruxtDebug',
408
- { props: { summary: `Missing wrapper component for '${this.schema.id} (${this.schema.type}')`} },
424
+ { props: { summary } },
409
425
  [
410
- h('label', ['Component options:', h('ul', this.component.options.map((s) => h('li', [s])))]),
411
- h('label', ['Data:', h('pre', [JSON.stringify(item, null, ' ')])]),
412
- 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, ' ')])])])
413
430
  ]
414
431
  )
415
432
  }
@@ -434,6 +451,15 @@ export default {
434
451
 
435
452
  return scopedSlots
436
453
  },
454
+
455
+ /**
456
+ * Druxt development template tool configuration.
457
+ */
458
+ template: {
459
+ mixins: {
460
+ 'DruxtFieldMixin': 'druxt-entity'
461
+ }
462
+ }
437
463
  },
438
464
  }
439
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.0",
3
+ "version": "0.27.0",
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"