druxt-entity 0.27.1 → 0.28.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.
|
@@ -188,6 +188,14 @@ export default {
|
|
|
188
188
|
},
|
|
189
189
|
},
|
|
190
190
|
|
|
191
|
+
mounted() {
|
|
192
|
+
// If static, re-fetch data allowing for cache-bypass.
|
|
193
|
+
// @TODO - Don't re-fetch in serverless configuration.
|
|
194
|
+
if (this.$store.app.context.isStatic) {
|
|
195
|
+
this.$fetch()
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
|
|
191
199
|
methods: {
|
|
192
200
|
/**
|
|
193
201
|
* Builds the query for the JSON:API request.
|
|
@@ -319,12 +327,22 @@ export default {
|
|
|
319
327
|
}
|
|
320
328
|
|
|
321
329
|
if (this.uuid && !this.value) {
|
|
330
|
+
// Check if we need to bypass cache.
|
|
331
|
+
let bypassCache = false
|
|
332
|
+
if (typeof (settings.query || {}).bypassCache === 'boolean') {
|
|
333
|
+
bypassCache = settings.query.bypassCache
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Build query.
|
|
322
337
|
const query = this.getQuery(settings)
|
|
338
|
+
|
|
339
|
+
// Execute the resquest.
|
|
323
340
|
const resource = await this.getResource({
|
|
324
341
|
id: this.uuid,
|
|
325
342
|
prefix: this.lang,
|
|
326
343
|
type: this.type,
|
|
327
|
-
query
|
|
344
|
+
query,
|
|
345
|
+
bypassCache
|
|
328
346
|
})
|
|
329
347
|
const entity = { ...(resource.data || {}) }
|
|
330
348
|
entity.included = resource.included
|
|
@@ -343,12 +361,20 @@ export default {
|
|
|
343
361
|
/**
|
|
344
362
|
* Component settings.
|
|
345
363
|
*/
|
|
346
|
-
settings: (
|
|
364
|
+
settings: (context, wrapperSettings) => {
|
|
365
|
+
const { $druxt, settings } = context
|
|
366
|
+
|
|
347
367
|
// Start with the `nuxt.config.js` `druxt.settings.entity` settings and
|
|
348
368
|
// merge the Wrapper component settings on top.
|
|
349
|
-
let mergedSettings = merge($druxt.settings.entity || {}, wrapperSettings, { arrayMerge: (dest, src) => src })
|
|
369
|
+
let mergedSettings = merge(($druxt.settings || {}).entity || {}, wrapperSettings || {}, { arrayMerge: (dest, src) => src })
|
|
350
370
|
// Merge the DruxtEntity component `settings` property on top.
|
|
351
|
-
mergedSettings = merge(mergedSettings || {}, settings, { arrayMerge: (dest, src) => src })
|
|
371
|
+
mergedSettings = merge(mergedSettings || {}, settings || {}, { arrayMerge: (dest, src) => src })
|
|
372
|
+
|
|
373
|
+
// Evaluate the bypass cache function.
|
|
374
|
+
if (typeof (mergedSettings.query || {}).bypassCache === 'function') {
|
|
375
|
+
mergedSettings.query.bypassCache = !!mergedSettings.query.bypassCache(context)
|
|
376
|
+
}
|
|
377
|
+
|
|
352
378
|
// Currently only returning the query settings.
|
|
353
379
|
return {
|
|
354
380
|
query: mergedSettings.query || {},
|
|
@@ -486,7 +512,8 @@ export default {
|
|
|
486
512
|
* property.
|
|
487
513
|
*
|
|
488
514
|
* @typedef {object} ModuleSettings
|
|
489
|
-
* @param {object} query - Entity
|
|
515
|
+
* @param {object} query - Entity query settings:
|
|
516
|
+
* @param {(boolean|function)} query.bypassCache - Whether to pull the data from the Vuex store or from the JSON:API.
|
|
490
517
|
* @param {(string[]|array[])} query.fields - An array or arrays of fields to filter from the JSON:API Resources.
|
|
491
518
|
* @param {string[]} query.include - An array of relationships to include alongside the JSON:API Resource.
|
|
492
519
|
* @param {boolean} query.schema - Whether to automatically detect fields to filter, per the Display mode.
|
|
@@ -496,11 +523,12 @@ export default {
|
|
|
496
523
|
* export default {
|
|
497
524
|
* druxt: {
|
|
498
525
|
* query: {
|
|
526
|
+
* bypassCache: ({ $store }) => $store.$auth.loggedIn,
|
|
499
527
|
* fields: [['title'], ['user--user', ['display_name']]],
|
|
500
528
|
* include: ['uid']
|
|
501
529
|
* schema: true,
|
|
502
530
|
* },
|
|
503
|
-
* }
|
|
531
|
+
* },
|
|
504
532
|
* }
|
|
505
533
|
*
|
|
506
534
|
* @example <caption>DruxtEntity component with settings</caption> @lang vue
|
|
@@ -510,6 +538,7 @@ export default {
|
|
|
510
538
|
* :uuid="uuid"
|
|
511
539
|
* :settings="{
|
|
512
540
|
* query: {
|
|
541
|
+
* bypassCache: true,
|
|
513
542
|
* fields: [['title'], ['user--user', ['display_name']]],
|
|
514
543
|
* include: ['uid']
|
|
515
544
|
* schema: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "druxt-entity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Drupal Display Mode powered Entity, Form and Field Druxt components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"templates"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"deepmerge": "^4.
|
|
48
|
-
"drupal-jsonapi-params": "^2.
|
|
49
|
-
"druxt": "^0.
|
|
50
|
-
"druxt-router": "^0.29.
|
|
51
|
-
"druxt-schema": "^0.11.
|
|
47
|
+
"deepmerge": "^4.3.1",
|
|
48
|
+
"drupal-jsonapi-params": "^2.2.0",
|
|
49
|
+
"druxt": "^0.22.0",
|
|
50
|
+
"druxt-router": "^0.29.1",
|
|
51
|
+
"druxt-schema": "^0.11.2"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|