druxt-entity 0.28.1 → 0.29.0-dev.20260920043715
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.
- package/README.md +143 -61
- package/banner.svg +1 -0
- package/dist/components/DruxtEntity.vue +60 -14
- package/dist/components/DruxtEntityForm.vue +9 -4
- package/dist/components/DruxtEntityFormButtons.vue +8 -1
- package/dist/components/DruxtField.vue +23 -7
- package/dist/components/DruxtRouterEntity.vue +9 -0
- package/dist/components/fields/DruxtFieldBasicString.vue +4 -2
- package/dist/components/fields/DruxtFieldDatetimeDefault.vue +4 -2
- package/dist/components/fields/DruxtFieldEntityReferenceEntityView.vue +4 -2
- package/dist/components/fields/DruxtFieldEntityReferenceLabel.vue +8 -4
- package/dist/components/fields/DruxtFieldEntityReferenceRevisionsEntityView.vue +4 -2
- package/dist/components/fields/DruxtFieldFileDefault.vue +7 -3
- package/dist/components/fields/DruxtFieldImage.vue +4 -2
- package/dist/components/fields/DruxtFieldLink.vue +4 -2
- package/dist/components/fields/DruxtFieldListDefault.vue +4 -2
- package/dist/components/fields/DruxtFieldNumberInteger.vue +16 -2
- package/dist/components/fields/DruxtFieldResponsiveImage.vue +7 -3
- package/dist/components/fields/DruxtFieldString.vue +4 -2
- package/dist/components/fields/DruxtFieldTextDefault.vue +5 -3
- package/dist/components/fields/DruxtFieldTextSummaryOrTrimmed.vue +5 -3
- package/dist/components/fields/DruxtFieldTextTrimmed.vue +5 -3
- package/dist/components/fields/DruxtFieldTimestamp.vue +4 -2
- package/dist/druxt-entity.esm.js +5 -3
- package/dist/druxt-entity.ssr.js +5 -3
- package/icon.svg +5 -0
- package/package.json +13 -6
package/README.md
CHANGED
|
@@ -1,93 +1,169 @@
|
|
|
1
|
+
<img src="./banner.svg" alt="DruxtEntity renders Display Mode powered Entity, Form and Field components">
|
|
2
|
+
|
|
1
3
|
# DruxtEntity
|
|
2
4
|
|
|
3
5
|
[](https://www.npmjs.com/package/druxt-entity)
|
|
4
|
-
[](https://github.com/druxt/druxt.js/actions/workflows/ci.yml)
|
|
7
|
+
[](https://snyk.io/test/github/druxt/druxt.js?targetFile=package.json)
|
|
8
|
+
[](https://codecov.io/gh/druxt/druxt.js)
|
|
7
9
|
|
|
8
|
-
> Drupal Display Mode
|
|
10
|
+
> Drupal Display Mode-powered Entity, Form and Field Druxt components.
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
DruxtEntity renders Drupal content in Vue. Point the `DruxtEntity` component
|
|
13
|
+
at a resource type and UUID and it renders the entity's fields exactly as the
|
|
14
|
+
Drupal display mode configures them. `DruxtEntityForm` does the same for
|
|
15
|
+
forms, with submission and validation handled for you. Drupal keeps deciding
|
|
16
|
+
what shows where. Your Nuxt components decide how it looks.
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
- Documentation: https://druxtjs.org/modules/entity
|
|
14
|
-
- Community Discord server: https://discord.druxtjs.org
|
|
18
|
+

|
|
15
19
|
|
|
20
|
+
## Features
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
- Vue.js components:
|
|
23
|
+
- **DruxtEntity** renders a Drupal Content Entity by UUID
|
|
24
|
+
- **DruxtEntityForm** renders a Drupal Content Entity form
|
|
25
|
+
- **Druxt settings** include and filter resource fields
|
|
26
|
+
- **Druxt Router** integration
|
|
27
|
+
- **@nuxtjs/Storybook** integration
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
---
|
|
20
30
|
|
|
21
|
-
|
|
31
|
+
## Installation
|
|
22
32
|
|
|
23
|
-
|
|
33
|
+
> Included with [`druxt-site`](https://druxtjs.org/modules/site). Install it separately only when composing modules yourself.
|
|
24
34
|
|
|
25
|
-
|
|
26
|
-
module.exports = {
|
|
27
|
-
modules: ['druxt-entity'],
|
|
28
|
-
druxt: {
|
|
29
|
-
baseUrl: 'https://demo-api.druxtjs.org',
|
|
30
|
-
entity: {
|
|
31
|
-
component: {
|
|
32
|
-
fields: false,
|
|
33
|
-
},
|
|
34
|
-
query: {
|
|
35
|
-
schema: true,
|
|
36
|
-
fields: ['path', 'title'],
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
```
|
|
35
|
+
1. Install the package:
|
|
42
36
|
|
|
43
|
-
|
|
37
|
+
```sh
|
|
38
|
+
npm i druxt-entity
|
|
39
|
+
```
|
|
44
40
|
|
|
45
|
-
|
|
41
|
+
2. Add the module to `nuxt.config.js`:
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
```js
|
|
44
|
+
export default {
|
|
45
|
+
modules: ['druxt-entity'],
|
|
46
|
+
};
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Vue.js Components
|
|
52
|
+
|
|
53
|
+
### DruxtEntity
|
|
54
|
+
|
|
55
|
+
Renders a Drupal Content Entity by JSON:API resource type, UUID, view mode and schema type.
|
|
56
|
+
|
|
57
|
+
Fields are rendered as [DruxtField](https://druxtjs.org/api/packages/entity/components/DruxtField) components, based on the Drupal display mode configuration.
|
|
48
58
|
|
|
49
59
|
```vue
|
|
50
60
|
<DruxtEntity :type="resourceType" :uuid="uuid" :mode="displayMode" />
|
|
51
61
|
```
|
|
52
62
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
See the [DruxtEntity API Documentation](https://druxtjs.org/api/packages/entity/components/DruxtEntity) for more information.
|
|
63
|
+
- For more details, refer to the [DruxtEntity component API documentation](https://druxtjs.org/api/packages/entity/components/DruxtEntity).
|
|
56
64
|
|
|
57
|
-
### DruxtEntityForm
|
|
65
|
+
### DruxtEntityForm
|
|
58
66
|
|
|
59
|
-
|
|
67
|
+
Renders a Drupal Content Entity form with submission and validation support.
|
|
60
68
|
|
|
61
69
|
```vue
|
|
62
|
-
<DruxtEntityForm
|
|
70
|
+
<DruxtEntityForm
|
|
71
|
+
:type="resourceType"
|
|
72
|
+
:mode="displayMode"
|
|
73
|
+
@error="onError"
|
|
74
|
+
@submit="onSubmit"
|
|
75
|
+
v-model="entity"
|
|
76
|
+
/>
|
|
63
77
|
```
|
|
64
78
|
|
|
65
79
|

|
|
66
80
|
|
|
67
|
-
|
|
81
|
+
- For more details, refer to the [DruxtEntityForm component API documentation](https://druxtjs.org/api/packages/entity/components/DruxtEntityForm).
|
|
68
82
|
|
|
69
|
-
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Settings
|
|
86
|
+
|
|
87
|
+
### Entity queries
|
|
88
|
+
|
|
89
|
+
Entity query settings can be provided to include related resources and filter the returned fields.
|
|
90
|
+
|
|
91
|
+
- **fields** is an array of strings, or an array of arrays. Formatted for the Drupal JSON:API Params `addFields` method, used to filter the returned resource fields.
|
|
92
|
+
- **include** is an array of relationship id's to include in the returned resources.
|
|
93
|
+
- **schema** is a Boolean. If `true`, fields will be populated by the Drupal Display schema information.
|
|
94
|
+
|
|
95
|
+
_Example: wrapper component with Query settings:_
|
|
70
96
|
|
|
71
|
-
Both components can be themed by providing a default template:
|
|
72
97
|
```vue
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
98
|
+
<script>
|
|
99
|
+
export default {
|
|
100
|
+
druxt: {
|
|
101
|
+
query: {
|
|
102
|
+
fields: ['title', 'path'],
|
|
103
|
+
schema: true,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
</script>
|
|
78
108
|
```
|
|
79
109
|
|
|
80
|
-
|
|
110
|
+
_Example: DruxtEntity with settings property:_
|
|
111
|
+
|
|
81
112
|
```vue
|
|
82
113
|
<template>
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
114
|
+
<DruxtEntity
|
|
115
|
+
:settings="{
|
|
116
|
+
query: {
|
|
117
|
+
include: ['field_media_image', 'field_media_image.field_media_image'],
|
|
118
|
+
fields: [
|
|
119
|
+
['file--file', ['uri']],
|
|
120
|
+
['media--image', []],
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
}"
|
|
124
|
+
type="node--recipe"
|
|
125
|
+
:uuid="uuid"
|
|
126
|
+
/>
|
|
87
127
|
</template>
|
|
88
128
|
```
|
|
89
129
|
|
|
90
|
-
|
|
130
|
+
The default behaviour can be set via `nuxt.config.js`:
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
druxt: {
|
|
134
|
+
entity: {
|
|
135
|
+
query: {
|
|
136
|
+
fields: ['path', 'title'], // Apply filter to all Entity queries.
|
|
137
|
+
schema: true, // Filter by display mode field settings.
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Router support
|
|
146
|
+
|
|
147
|
+
The DruxtEntity module provides a **DruxtRouterEntity** component that is used by the Druxt Router module to render a Content Entity route.
|
|
148
|
+
|
|
149
|
+
- For more details, see the [Druxt Router module](https://druxtjs.org/modules/router).
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Storybook
|
|
154
|
+
|
|
155
|
+
DruxtEntity provides zero-config, auto-generated Storybook integration with a live data connection to your Druxt backend.
|
|
156
|
+
|
|
157
|
+
- For more details, see the [Storybook guide](https://druxtjs.org/how-to/storybook).
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Deprecations
|
|
162
|
+
|
|
163
|
+
The default DruxtField components are deprecated. See the
|
|
164
|
+
[deprecations page](https://druxtjs.org/modules/entity/deprecations) for what replaces them.
|
|
165
|
+
|
|
166
|
+
---
|
|
91
167
|
|
|
92
168
|
## Options
|
|
93
169
|
|
|
@@ -95,17 +171,23 @@ See the [Druxt Theming guide](https://druxtjs.org/guide/theming) for more inform
|
|
|
95
171
|
|
|
96
172
|
These options are specific to this module.
|
|
97
173
|
|
|
98
|
-
| Option
|
|
99
|
-
|
|
|
100
|
-
| `entity.components.fields` | `boolean`
|
|
101
|
-
| `entity.query.fields`
|
|
102
|
-
| `entity.query.schema`
|
|
174
|
+
| Option | Type | Required | Default | Description |
|
|
175
|
+
| -------------------------- | ------------------------ | -------- | ------- | ------------------------------------------------------------------------------ |
|
|
176
|
+
| `entity.components.fields` | `boolean` | No | `false` | Whether to import deprecated default Field components. |
|
|
177
|
+
| `entity.query.fields` | `string[] \| string[][]` | No | `[]` | An array of fields, or of field arrays, to filter all Entity JSON:API queries. |
|
|
178
|
+
| `entity.query.schema` | `boolean` | No | `false` | Whether to automatically filter fields based on Display schema. |
|
|
103
179
|
|
|
104
180
|
### Base Druxt options
|
|
105
181
|
|
|
106
182
|
These options are available to all Druxt modules.
|
|
107
183
|
|
|
108
|
-
| Option
|
|
109
|
-
|
|
|
110
|
-
| `axios`
|
|
111
|
-
| `baseUrl` | `string` | Yes
|
|
184
|
+
| Option | Type | Required | Default | Description |
|
|
185
|
+
| --------- | -------- | -------- | ------- | ---------------------------------------------------------------------------- |
|
|
186
|
+
| `axios` | `object` | No | `{}` | [Axios instance settings](https://github.com/axios/axios#axioscreateconfig). |
|
|
187
|
+
| `baseUrl` | `string` | Yes | `null` | Base URL for the Drupal installation. |
|
|
188
|
+
|
|
189
|
+
## Links
|
|
190
|
+
|
|
191
|
+
- DruxtJS: https://druxtjs.org
|
|
192
|
+
- Documentation: https://druxtjs.org/modules/entity
|
|
193
|
+
- Community Discord server: https://discord.druxtjs.org
|
package/banner.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 320" width="1280" height="320" role="img" aria-label="druxt-entity: Display Mode powered Entity, Form and Field components."><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#1f2937"/><stop offset="0.7" stop-color="#2f495e"/><stop offset="1" stop-color="#36566e"/></linearGradient></defs><rect width="1280" height="320" rx="16" fill="url(#g)"/><rect x="250" y="85" width="150" height="150" rx="32" fill="rgba(229,236,241,0.07)"/><g transform="translate(277,112) scale(4)" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5.5 5h13a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-13a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2z" stroke="#7cc5f1"/><path d="M6.5 10.75a1.75 1.75 0 1 0 3.5 0a1.75 1.75 0 1 0 -3.5 0" stroke="#7cc5f1"/><path d="M12.75 9.75H17M12.75 13.25H17M7 16.25h10" stroke="#68cb9f"/></g><text x="440" y="150" style="font-family:ui-sans-serif,system-ui,sans-serif" font-size="64" font-weight="700" letter-spacing="-1" fill="#eef2f6">Entity</text><text x="688" y="150" style="font-family:ui-monospace,Menlo,Consolas,monospace" font-size="26" fill="#7cc5f1">druxt-entity</text><text x="440" y="196" style="font-family:ui-sans-serif,system-ui,sans-serif" font-size="25" fill="rgba(229,236,241,0.75)">Display Mode powered Entity, Form and Field components.</text><g transform="translate(440,236) scale(0.0994)"><path d="M139 330l-1-2c-2-4-2-8-1-13H29L189 31l67 121 22-16-67-121c-1-2-9-14-22-14-6 0-15 2-22 15L5 303c-1 3-8 16-2 27 4 6 10 12 24 12h136c-14 0-21-6-24-12z" fill="#3498DB"/><path d="M447 304L317 70c-2-2-9-15-22-15-6 0-15 3-22 15l-17 28v54l39-67 129 230h-49a23 23 0 0 1-2 14l-1 1c-6 11-21 12-23 12h76c3 0 17-1 24-12 3-5 5-14-2-26z" fill="#108775"/><path d="M376 330v-1l1-2c1-4 2-8 1-12l-4-12-102-178-15-27h-1l-15 27-102 178-4 12a24 24 0 0 0 2 15c4 6 10 12 24 12h190c3 0 18-1 25-12zM256 152l93 163H163l93-163z" fill="#E5ECF1"/></g><text x="492" y="260" style="font-family:ui-sans-serif,system-ui,sans-serif" font-size="17" font-weight="600" fill="rgba(229,236,241,0.85)">druxtjs.org</text></svg>
|
|
@@ -13,6 +13,8 @@ import { mapActions } from 'vuex'
|
|
|
13
13
|
* Fields are rendered as DruxtField components, based on the Drupal display
|
|
14
14
|
* mode configuration.
|
|
15
15
|
*
|
|
16
|
+
* @see https://druxtjs.org/modules/entity
|
|
17
|
+
*
|
|
16
18
|
* @example @lang vue
|
|
17
19
|
* <DruxtEntity
|
|
18
20
|
* type="node--article"
|
|
@@ -20,6 +22,16 @@ import { mapActions } from 'vuex'
|
|
|
20
22
|
* mode="teaser"
|
|
21
23
|
* />
|
|
22
24
|
*
|
|
25
|
+
* @example <caption>DruxtEntity with v-model</caption> @lang vue
|
|
26
|
+
* <template>
|
|
27
|
+
* <DruxtEntity v-model="model" type="node--article" :uuid="uuid" />
|
|
28
|
+
* </template>
|
|
29
|
+
*
|
|
30
|
+
* <script>
|
|
31
|
+
* export default {
|
|
32
|
+
* data: () => ({ model: undefined }),
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
23
35
|
* @example <caption>DruxtEntity Wrapper component boilerplate</caption> @lang vue
|
|
24
36
|
* <template>
|
|
25
37
|
* <DruxtDebug :json="entity" />
|
|
@@ -31,7 +43,9 @@ import { mapActions } from 'vuex'
|
|
|
31
43
|
* mixins: [DruxtEntityMixin]
|
|
32
44
|
* }
|
|
33
45
|
*
|
|
34
|
-
* @
|
|
46
|
+
* @see {@link https://druxtjs.org/explanation/component-resolution|Component resolution}
|
|
47
|
+
*
|
|
48
|
+
* @example <caption>DruxtEntity default slot (template injection)</caption> @lang vue
|
|
35
49
|
* <DruxtEntity type="" uuid="">
|
|
36
50
|
* <template #default="{ entity }">
|
|
37
51
|
* <!-- Do whatever you want here -->
|
|
@@ -93,7 +107,8 @@ export default {
|
|
|
93
107
|
/**
|
|
94
108
|
* Entity UUID.
|
|
95
109
|
*
|
|
96
|
-
* @type {string}
|
|
110
|
+
* @type {(boolean|string)}
|
|
111
|
+
* @default false
|
|
97
112
|
*/
|
|
98
113
|
uuid: {
|
|
99
114
|
type: [Boolean, String],
|
|
@@ -102,6 +117,11 @@ export default {
|
|
|
102
117
|
},
|
|
103
118
|
|
|
104
119
|
/**
|
|
120
|
+
* Provides the reactive entity model and display schema state.
|
|
121
|
+
*
|
|
122
|
+
* @param {object} vm - The component ViewModel.
|
|
123
|
+
* @param {string} vm.type - The JSON:API resource type.
|
|
124
|
+
* @param {object} vm.value - The Vue.js v-model value. If set, it provides the entity data directly and the JSON:API fetch is skipped.
|
|
105
125
|
* @property {object} model - The model object.
|
|
106
126
|
* @property {object} schema - The DruxtSchema object.
|
|
107
127
|
*/
|
|
@@ -126,14 +146,23 @@ export default {
|
|
|
126
146
|
/**
|
|
127
147
|
* The Entity object.
|
|
128
148
|
*
|
|
129
|
-
* @
|
|
149
|
+
* @param {object} vm - The component ViewModel.
|
|
150
|
+
* @param {object} vm.model - The model object.
|
|
151
|
+
* @return {object} A copy of the entity model, containing the JSON:API attributes, relationships and included resource data.
|
|
130
152
|
*/
|
|
131
153
|
entity: ({ model }) => ({ ...model }),
|
|
132
154
|
|
|
133
155
|
/**
|
|
134
156
|
* Entity fields based on Display mode.
|
|
135
157
|
*
|
|
136
|
-
* @
|
|
158
|
+
* @param {object} vm - The component ViewModel.
|
|
159
|
+
* @param {object[]} vm.errors - Form submission response errors, if any.
|
|
160
|
+
* @param {Function} vm.isEmpty - Checks if an Entity field is empty.
|
|
161
|
+
* @param {string} vm.lang - The current language code.
|
|
162
|
+
* @param {object} vm.model - The model object.
|
|
163
|
+
* @param {object} vm.schema - The DruxtSchema object.
|
|
164
|
+
* @param {('view'|'form')} vm.schemaType - Drupal display schema type, 'view' or 'form'.
|
|
165
|
+
* @return {object} Field objects keyed by field ID, each containing the field's schema, value, errors and relationship status.
|
|
137
166
|
*/
|
|
138
167
|
fields: ({ errors, isEmpty, lang, model, schema, schemaType }) => {
|
|
139
168
|
if (!schema) return false
|
|
@@ -202,7 +231,7 @@ export default {
|
|
|
202
231
|
*
|
|
203
232
|
* @param {ModuleSettings} settings - The merged module and component settings object.
|
|
204
233
|
*
|
|
205
|
-
* @return {boolean|object}
|
|
234
|
+
* @return {boolean|object} The DrupalJsonApiParams query object.
|
|
206
235
|
*/
|
|
207
236
|
getQuery(settings) {
|
|
208
237
|
const query = new DrupalJsonApiParams()
|
|
@@ -249,7 +278,7 @@ export default {
|
|
|
249
278
|
* Checks if an Entity field is empty.
|
|
250
279
|
*
|
|
251
280
|
* @param {*} value - Field value.
|
|
252
|
-
* @return {boolean}
|
|
281
|
+
* @return {boolean} `true` if the field value is empty.
|
|
253
282
|
*/
|
|
254
283
|
isEmpty(value) {
|
|
255
284
|
if (typeof value === 'undefined') return true
|
|
@@ -278,6 +307,10 @@ export default {
|
|
|
278
307
|
* Provides the available component naming options for the Druxt Wrapper.
|
|
279
308
|
*
|
|
280
309
|
* @param {object} context - The module component ViewModel.
|
|
310
|
+
* @param {string} context.mode - The Drupal display mode.
|
|
311
|
+
* @param {object} context.schema - The DruxtSchema object.
|
|
312
|
+
* @param {('view'|'form')} context.schemaType - Drupal display schema type, 'view' or 'form'.
|
|
313
|
+
* @param {string} context.type - The JSON:API resource type.
|
|
281
314
|
* @returns {ComponentOptions}
|
|
282
315
|
*/
|
|
283
316
|
componentOptions: ({ mode, schema, schemaType, type }) => ([
|
|
@@ -318,6 +351,8 @@ export default {
|
|
|
318
351
|
|
|
319
352
|
/**
|
|
320
353
|
* Fetches the content entity JSON:API resource.
|
|
354
|
+
*
|
|
355
|
+
* @param {object} settings - The module settings object, including the resource query configuration.
|
|
321
356
|
*/
|
|
322
357
|
async fetchData(settings) {
|
|
323
358
|
if (!this.type) return
|
|
@@ -336,7 +371,7 @@ export default {
|
|
|
336
371
|
// Build query.
|
|
337
372
|
const query = this.getQuery(settings)
|
|
338
373
|
|
|
339
|
-
// Execute the
|
|
374
|
+
// Execute the request.
|
|
340
375
|
const resource = await this.getResource({
|
|
341
376
|
id: this.uuid,
|
|
342
377
|
prefix: this.lang,
|
|
@@ -354,12 +389,19 @@ export default {
|
|
|
354
389
|
* Provides propsData for the DruxtWrapper.
|
|
355
390
|
*
|
|
356
391
|
* @param {object} context - The module component ViewModel.
|
|
392
|
+
* @param {object} context.fields - Entity fields based on the display mode.
|
|
393
|
+
* @param {object} context.model - The model object.
|
|
394
|
+
* @param {object} context.schema - The DruxtSchema object.
|
|
357
395
|
* @returns {PropsData}
|
|
358
396
|
*/
|
|
359
397
|
propsData: ({ fields, model, schema }) => ({ entity: model, fields, schema, value: model }),
|
|
360
398
|
|
|
361
399
|
/**
|
|
362
400
|
* Component settings.
|
|
401
|
+
*
|
|
402
|
+
* @param {object} context - The module component ViewModel.
|
|
403
|
+
* @param {object} wrapperSettings - Settings provided by the wrapper component.
|
|
404
|
+
* @returns {object} The merged module settings.
|
|
363
405
|
*/
|
|
364
406
|
settings: (context, wrapperSettings) => {
|
|
365
407
|
const { $druxt, settings } = context
|
|
@@ -387,7 +429,8 @@ export default {
|
|
|
387
429
|
* A scoped slot is provided for each field being rendered, as per the
|
|
388
430
|
* current display mode.
|
|
389
431
|
*
|
|
390
|
-
*
|
|
432
|
+
* The `default` slot will also render all fields as per the
|
|
433
|
+
* Drupal display mode configuration.
|
|
391
434
|
*
|
|
392
435
|
* @example <caption>DruxtEntity**ResourceType**.vue</caption> @lang vue
|
|
393
436
|
* <template>
|
|
@@ -397,6 +440,7 @@ export default {
|
|
|
397
440
|
* </div>
|
|
398
441
|
* </template>
|
|
399
442
|
*
|
|
443
|
+
* @param {Function} h - The Vue createElement function.
|
|
400
444
|
* @return {ScopedSlots} The Scoped slots object.
|
|
401
445
|
*/
|
|
402
446
|
slots(h) {
|
|
@@ -465,10 +509,12 @@ export default {
|
|
|
465
509
|
}
|
|
466
510
|
|
|
467
511
|
/**
|
|
468
|
-
* Provides the available naming options for the
|
|
512
|
+
* Provides the available naming options for the wrapper component.
|
|
469
513
|
*
|
|
470
514
|
* @typedef {array[]} ComponentOptions
|
|
471
515
|
*
|
|
516
|
+
* @see {@link https://druxtjs.org/explanation/component-resolution|Component resolution}
|
|
517
|
+
*
|
|
472
518
|
* @example @lang js
|
|
473
519
|
* [
|
|
474
520
|
* 'DruxtEntity[ResourceType][DisplayMode][SchemaType][Langcode]',
|
|
@@ -508,7 +554,7 @@ export default {
|
|
|
508
554
|
|
|
509
555
|
/**
|
|
510
556
|
* Provides settings for the Entity module, via the `nuxt.config.js` `druxt.entity`,
|
|
511
|
-
* the
|
|
557
|
+
* the wrapper component `druxt` object or the DruxtEntity component `settings`
|
|
512
558
|
* property.
|
|
513
559
|
*
|
|
514
560
|
* @typedef {object} ModuleSettings
|
|
@@ -525,7 +571,7 @@ export default {
|
|
|
525
571
|
* query: {
|
|
526
572
|
* bypassCache: ({ $store }) => $store.$auth.loggedIn,
|
|
527
573
|
* fields: [['title'], ['user--user', ['display_name']]],
|
|
528
|
-
* include: ['uid']
|
|
574
|
+
* include: ['uid'],
|
|
529
575
|
* schema: true,
|
|
530
576
|
* },
|
|
531
577
|
* },
|
|
@@ -540,7 +586,7 @@ export default {
|
|
|
540
586
|
* query: {
|
|
541
587
|
* bypassCache: true,
|
|
542
588
|
* fields: [['title'], ['user--user', ['display_name']]],
|
|
543
|
-
* include: ['uid']
|
|
589
|
+
* include: ['uid'],
|
|
544
590
|
* schema: true,
|
|
545
591
|
* }
|
|
546
592
|
* }"
|
|
@@ -549,7 +595,7 @@ export default {
|
|
|
549
595
|
*/
|
|
550
596
|
|
|
551
597
|
/**
|
|
552
|
-
* Provides property data for use in the
|
|
598
|
+
* Provides property data for use in the wrapper component.
|
|
553
599
|
*
|
|
554
600
|
* @typedef {object} PropsData
|
|
555
601
|
* @param {object} entity - The Drupal Entity JSON:API resource data.
|
|
@@ -583,7 +629,7 @@ export default {
|
|
|
583
629
|
*/
|
|
584
630
|
|
|
585
631
|
/**
|
|
586
|
-
* Provides scoped slots for use in the
|
|
632
|
+
* Provides scoped slots for use in the wrapper component.
|
|
587
633
|
*
|
|
588
634
|
* @typedef {object} ScopedSlots
|
|
589
635
|
* @param {function} * - Slot per field.
|
|
@@ -30,7 +30,7 @@ import { default as DruxtEntity } from './DruxtEntity.vue'
|
|
|
30
30
|
* mixins: [DruxtEntityMixin]
|
|
31
31
|
* }
|
|
32
32
|
*
|
|
33
|
-
* @example <caption>DruxtEntityForm
|
|
33
|
+
* @example <caption>DruxtEntityForm default slot (template injection)</caption> @lang vue
|
|
34
34
|
* <DruxtEntityForm type="">
|
|
35
35
|
* <template #default="{ entity }">
|
|
36
36
|
* <!-- Do whatever you want here -->
|
|
@@ -40,6 +40,7 @@ import { default as DruxtEntity } from './DruxtEntity.vue'
|
|
|
40
40
|
*
|
|
41
41
|
* @extends DruxtEntity
|
|
42
42
|
* @see {@link ./DruxtEntity|DruxtEntity}
|
|
43
|
+
* @see https://druxtjs.org/modules/entity
|
|
43
44
|
*/
|
|
44
45
|
export default {
|
|
45
46
|
name: 'DruxtEntityForm',
|
|
@@ -83,7 +84,9 @@ export default {
|
|
|
83
84
|
/**
|
|
84
85
|
* An array of errors if present in the form submission response data.
|
|
85
86
|
*
|
|
86
|
-
* @
|
|
87
|
+
* @param {object} vm - The component ViewModel.
|
|
88
|
+
* @param {object} vm.response - The form submission response data.
|
|
89
|
+
* @return {object[]} The JSON:API errors from the form submission response, or `undefined`.
|
|
87
90
|
*/
|
|
88
91
|
errors: ({ response }) => (response || {}).errors,
|
|
89
92
|
},
|
|
@@ -123,7 +126,8 @@ export default {
|
|
|
123
126
|
this.$store.commit('druxt/addResource', { resource })
|
|
124
127
|
this.$emit('submit', resource)
|
|
125
128
|
} catch (err) {
|
|
126
|
-
|
|
129
|
+
// Network-level failures reject without a response object.
|
|
130
|
+
this.response = (err.response || {}).data
|
|
127
131
|
this.$emit('error', this.response)
|
|
128
132
|
}
|
|
129
133
|
|
|
@@ -137,7 +141,8 @@ export default {
|
|
|
137
141
|
/**
|
|
138
142
|
* Adds a `buttons` slot to the DruxtEntity scope slots.
|
|
139
143
|
*
|
|
140
|
-
* @
|
|
144
|
+
* @param {Function} h - The Vue createElement function.
|
|
145
|
+
* @return {object} The DruxtEntity scoped slots, with an added `buttons` slot and a default slot that appends the form buttons after the fields.
|
|
141
146
|
*/
|
|
142
147
|
slots(h) {
|
|
143
148
|
// Use DruxtEntity to build the Field based slots.
|
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
/**
|
|
28
28
|
* Get scoped slots for Entity form buttons.
|
|
29
29
|
*
|
|
30
|
-
* @return {object}
|
|
30
|
+
* @return {object} Scoped slots for the `submit` and `reset` buttons, and a default slot rendering both.
|
|
31
31
|
*/
|
|
32
32
|
getScopedSlots() {
|
|
33
33
|
const buttons = ['submit', 'reset']
|
|
@@ -62,6 +62,13 @@ export default {
|
|
|
62
62
|
},
|
|
63
63
|
|
|
64
64
|
druxt: {
|
|
65
|
+
/**
|
|
66
|
+
* Provides the available component naming options for the Druxt Wrapper.
|
|
67
|
+
*
|
|
68
|
+
* @param {object} context - The module component ViewModel.
|
|
69
|
+
* @param {object} context.schema - The DruxtSchema object.
|
|
70
|
+
* @returns {Array} The component naming options.
|
|
71
|
+
*/
|
|
65
72
|
componentOptions: ({ schema }) => {
|
|
66
73
|
let options = []
|
|
67
74
|
// Ensure that the schema config data is present.
|
|
@@ -7,7 +7,10 @@ const modelWatch = DruxtModule.watch.model
|
|
|
7
7
|
delete DruxtModule.watch.model
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Renders a Drupal
|
|
10
|
+
* Renders a Drupal field using a component chosen by the field type and
|
|
11
|
+
* formatter settings.
|
|
12
|
+
*
|
|
13
|
+
* @see https://druxtjs.org/modules/entity
|
|
11
14
|
*
|
|
12
15
|
* @example
|
|
13
16
|
* <DruxtField
|
|
@@ -33,6 +36,7 @@ export default {
|
|
|
33
36
|
* JSON:API errors.
|
|
34
37
|
*
|
|
35
38
|
* @type {object[]}
|
|
39
|
+
* @default []
|
|
36
40
|
*/
|
|
37
41
|
errors: {
|
|
38
42
|
type: Array,
|
|
@@ -61,7 +65,9 @@ export default {
|
|
|
61
65
|
},
|
|
62
66
|
|
|
63
67
|
/**
|
|
64
|
-
* @deprecated
|
|
68
|
+
* @deprecated in druxt-entity:0.5.0 and is removed from druxt-entity:2.0.0.
|
|
69
|
+
* Use the component suggestion system instead.
|
|
70
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
65
71
|
*/
|
|
66
72
|
options: {
|
|
67
73
|
type: Object,
|
|
@@ -87,6 +93,10 @@ export default {
|
|
|
87
93
|
},
|
|
88
94
|
|
|
89
95
|
/**
|
|
96
|
+
* Provides the reactive field model, initialized from the value property.
|
|
97
|
+
*
|
|
98
|
+
* @param {object} vm - The component ViewModel.
|
|
99
|
+
* @param {(array|boolean|number|object|string)} vm.value - The Field value.
|
|
90
100
|
* @property {object} model - The model object.
|
|
91
101
|
*/
|
|
92
102
|
data: ({ value }) => ({
|
|
@@ -186,6 +196,7 @@ export default {
|
|
|
186
196
|
* Provides the available component naming options for the Druxt Wrapper.
|
|
187
197
|
*
|
|
188
198
|
* @param {object} context - The module component ViewModel.
|
|
199
|
+
* @param {object} context.schema - The DruxtSchema field schema object.
|
|
189
200
|
* @returns {ComponentOptions}
|
|
190
201
|
*/
|
|
191
202
|
componentOptions: ({ schema }) => ([
|
|
@@ -198,6 +209,10 @@ export default {
|
|
|
198
209
|
* Provides propsData for the DruxtWrapper.
|
|
199
210
|
*
|
|
200
211
|
* @param {object} context - The module component ViewModel.
|
|
212
|
+
* @param {object[]} context.errors - Field errors from the form submission response.
|
|
213
|
+
* @param {Array|boolean|number|object|string} context.model - The field value.
|
|
214
|
+
* @param {boolean} context.relationship - `true` if this field is a JSON:API relationship.
|
|
215
|
+
* @param {object} context.schema - The DruxtSchema field schema object.
|
|
201
216
|
* @returns {PropsData}
|
|
202
217
|
*/
|
|
203
218
|
propsData: ({ errors, model, relationship, schema }) => ({ errors, relationship, schema, value: model }),
|
|
@@ -208,7 +223,7 @@ export default {
|
|
|
208
223
|
* A scoped slot per field item is provided, with support for:
|
|
209
224
|
* - File, Image, Link, Number, Text and other View fields.
|
|
210
225
|
* - Boolean, Date/Time, Text and other Form fields.
|
|
211
|
-
* -
|
|
226
|
+
* - Entity references.
|
|
212
227
|
*
|
|
213
228
|
* A scoped slot is provided for the label, as well as label-above and
|
|
214
229
|
* label-inline depending on the field schema.
|
|
@@ -224,6 +239,7 @@ export default {
|
|
|
224
239
|
* </div>
|
|
225
240
|
* </template>
|
|
226
241
|
*
|
|
242
|
+
* @param {Function} h - The Vue createElement function.
|
|
227
243
|
* @return {ScopedSlots} The Scoped slots object.
|
|
228
244
|
*/
|
|
229
245
|
slots(h) {
|
|
@@ -464,7 +480,7 @@ export default {
|
|
|
464
480
|
}
|
|
465
481
|
|
|
466
482
|
/**
|
|
467
|
-
* Provides the available naming options for the
|
|
483
|
+
* Provides the available naming options for the wrapper component.
|
|
468
484
|
*
|
|
469
485
|
* @typedef {array[]} ComponentOptions
|
|
470
486
|
*
|
|
@@ -502,7 +518,7 @@ export default {
|
|
|
502
518
|
*/
|
|
503
519
|
|
|
504
520
|
/**
|
|
505
|
-
* Provides propsData for use in the
|
|
521
|
+
* Provides propsData for use in the wrapper component.
|
|
506
522
|
*
|
|
507
523
|
* @typedef {object} PropsData
|
|
508
524
|
* @param {object[]} errors - JSON:API errors.
|
|
@@ -536,10 +552,10 @@ export default {
|
|
|
536
552
|
*/
|
|
537
553
|
|
|
538
554
|
/**
|
|
539
|
-
* Provides scoped slots for use in the
|
|
555
|
+
* Provides scoped slots for use in the wrapper component.
|
|
540
556
|
*
|
|
541
557
|
* @typedef {object} ScopedSlots
|
|
542
|
-
* @param {function}
|
|
558
|
+
* @param {function} * - A slot per field item, e.g. `field-0`.
|
|
543
559
|
* @param {function} label - The field label.
|
|
544
560
|
* @param {function} label-above - The field label, if label position is 'above'.
|
|
545
561
|
* @param {function} label-inline - The field label, if label position is 'inline'.
|
|
@@ -9,6 +9,15 @@
|
|
|
9
9
|
|
|
10
10
|
import { DruxtRouterMixin } from 'druxt-router'
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Renders the resolved DruxtRouter route as a DruxtEntity component, using the
|
|
14
|
+
* 'full' display mode.
|
|
15
|
+
*
|
|
16
|
+
* Used by the DruxtRouter to render decoupled Drupal entity routes; it is not
|
|
17
|
+
* intended to be used directly.
|
|
18
|
+
*
|
|
19
|
+
* @see https://druxtjs.org/modules/router
|
|
20
|
+
*/
|
|
12
21
|
export default {
|
|
13
22
|
mixins: [DruxtRouterMixin],
|
|
14
23
|
}
|
|
@@ -30,8 +30,10 @@
|
|
|
30
30
|
import { DruxtFieldMixin } from 'druxt-entity'
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
* @deprecated
|
|
33
|
+
* Renders a basic string field's values as HTML.
|
|
34
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
35
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
36
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
35
37
|
*/
|
|
36
38
|
export default {
|
|
37
39
|
name: 'DruxtFieldBasicString',
|
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
import { DruxtFieldMixin } from 'druxt-entity'
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @deprecated
|
|
32
|
+
* Renders a datetime field's values as plain text.
|
|
33
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
34
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
35
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
34
36
|
*/
|
|
35
37
|
export default {
|
|
36
38
|
name: 'DruxtFieldDatetimeDefault',
|
|
@@ -29,8 +29,10 @@ import DruxtEntity from '../../components/DruxtEntity.vue'
|
|
|
29
29
|
import { DruxtFieldMixin } from 'druxt-entity'
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @deprecated
|
|
32
|
+
* Renders an entity reference field's referenced entities as DruxtEntity components.
|
|
33
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
34
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
35
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
34
36
|
*/
|
|
35
37
|
export default {
|
|
36
38
|
name: 'DruxtFieldEntityReferenceEntityView',
|
|
@@ -34,8 +34,10 @@ import { DruxtFieldMixin } from 'druxt-entity'
|
|
|
34
34
|
import { mapActions } from 'vuex'
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @deprecated
|
|
37
|
+
* Renders an entity reference field as the referenced entities' labels, optionally linked.
|
|
38
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
39
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
40
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
39
41
|
*/
|
|
40
42
|
export default {
|
|
41
43
|
name: 'DruxtFieldEntityReferenceLabel',
|
|
@@ -43,8 +45,10 @@ export default {
|
|
|
43
45
|
mixins: [DruxtFieldMixin],
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
+
* Provides the referenced entities' label and link data for rendering.
|
|
49
|
+
*
|
|
50
|
+
* @property {string} [component=span] - The component used to wrap the field items.
|
|
51
|
+
* @property {boolean|object} entities - The label text and link props per referenced entity, or `false` until fetched.
|
|
48
52
|
* @property {boolean} loading - Loading status.
|
|
49
53
|
*/
|
|
50
54
|
data: () => ({
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
import DruxtFieldEntityReferenceEntityView from './DruxtFieldEntityReferenceEntityView.vue'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @deprecated
|
|
6
|
+
* Renders an entity reference revisions field's referenced entities as DruxtEntity components.
|
|
7
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
8
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
9
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
8
10
|
*/
|
|
9
11
|
export default {
|
|
10
12
|
name: 'DruxtFieldEntityReferenceRevisionsEntityView',
|
|
@@ -33,8 +33,10 @@ import { DruxtFieldMixin } from 'druxt-entity'
|
|
|
33
33
|
import { mapActions } from 'vuex'
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @deprecated
|
|
36
|
+
* Renders a file field's items as links to the referenced files.
|
|
37
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
38
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
39
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
38
40
|
*/
|
|
39
41
|
export default {
|
|
40
42
|
name: 'DruxtFieldFileDefault',
|
|
@@ -42,7 +44,9 @@ export default {
|
|
|
42
44
|
mixins: [DruxtFieldMixin],
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
|
-
*
|
|
47
|
+
* Provides the fetched file resources for rendering.
|
|
48
|
+
*
|
|
49
|
+
* @property {object[]} entities - The File JSON:API resources referenced by the field items.
|
|
46
50
|
*/
|
|
47
51
|
data: () => ({
|
|
48
52
|
entities: []
|
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
import DruxtFieldFileDefault from './DruxtFieldFileDefault.vue'
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @deprecated
|
|
32
|
+
* Renders an image field's items as HTML image elements.
|
|
33
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
34
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
35
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
34
36
|
*/
|
|
35
37
|
export default {
|
|
36
38
|
name: 'DruxtFieldImage',
|
|
@@ -31,8 +31,10 @@
|
|
|
31
31
|
import { DruxtFieldMixin } from 'druxt-entity'
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @deprecated
|
|
34
|
+
* Renders a link field's items as HTML anchors or NuxtLink components.
|
|
35
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
36
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
37
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
36
38
|
*/
|
|
37
39
|
export default {
|
|
38
40
|
name: 'DruxtFieldLink',
|
|
@@ -31,8 +31,10 @@
|
|
|
31
31
|
import { DruxtFieldMixin } from 'druxt-entity'
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @deprecated
|
|
34
|
+
* Renders a list field's values as an unordered list.
|
|
35
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
36
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
37
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
36
38
|
*/
|
|
37
39
|
export default {
|
|
38
40
|
name: 'DruxtFieldListDefault',
|
|
@@ -37,8 +37,10 @@
|
|
|
37
37
|
import { DruxtFieldMixin } from 'druxt-entity'
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @deprecated
|
|
40
|
+
* Renders an integer field's values with the configured prefix and suffix.
|
|
41
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
42
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
43
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
42
44
|
*/
|
|
43
45
|
export default {
|
|
44
46
|
name: 'DruxtFieldNumberInteger',
|
|
@@ -47,12 +49,24 @@ export default {
|
|
|
47
49
|
|
|
48
50
|
/** */
|
|
49
51
|
computed: {
|
|
52
|
+
/**
|
|
53
|
+
* The text to render before each value, if enabled by the field display settings.
|
|
54
|
+
*
|
|
55
|
+
* @type {boolean|string}
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
50
58
|
prefix() {
|
|
51
59
|
if (!this.schema.settings.display.prefix_suffix || !this.schema.settings.config.prefix) return false
|
|
52
60
|
|
|
53
61
|
return this.schema.settings.config.prefix
|
|
54
62
|
},
|
|
55
63
|
|
|
64
|
+
/**
|
|
65
|
+
* The text to render after each value, if enabled by the field display settings.
|
|
66
|
+
*
|
|
67
|
+
* @type {boolean|string}
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
56
70
|
suffix() {
|
|
57
71
|
if (!this.schema.settings.display.prefix_suffix || !this.schema.settings.config.suffix) return false
|
|
58
72
|
|
|
@@ -31,8 +31,10 @@ import { DruxtFieldMixin } from 'druxt-entity'
|
|
|
31
31
|
import { mapActions } from 'vuex'
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @deprecated
|
|
34
|
+
* Renders a responsive image field's items as HTML image elements.
|
|
35
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
36
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
37
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
36
38
|
*/
|
|
37
39
|
export default {
|
|
38
40
|
name: 'DruxtFieldResponsiveImage',
|
|
@@ -40,7 +42,9 @@ export default {
|
|
|
40
42
|
mixins: [DruxtFieldMixin],
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
|
-
*
|
|
45
|
+
* Provides the fetched image file resources for rendering.
|
|
46
|
+
*
|
|
47
|
+
* @property {object[]} entities - The File JSON:API resources referenced by the field items.
|
|
44
48
|
*/
|
|
45
49
|
data: () => ({
|
|
46
50
|
entities: []
|
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
import { DruxtFieldMixin } from 'druxt-entity'
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @deprecated
|
|
32
|
+
* Renders a string field's values as plain text.
|
|
33
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
34
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
35
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
34
36
|
*/
|
|
35
37
|
export default {
|
|
36
38
|
name: 'DruxtFieldString',
|
|
@@ -30,8 +30,10 @@
|
|
|
30
30
|
import { DruxtFieldMixin } from 'druxt-entity'
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
* @deprecated
|
|
33
|
+
* Renders a formatted text field's processed HTML.
|
|
34
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
35
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
36
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
35
37
|
*/
|
|
36
38
|
export default {
|
|
37
39
|
name: 'DruxtFieldTextDefault',
|
|
@@ -48,7 +50,7 @@ export default {
|
|
|
48
50
|
*
|
|
49
51
|
* @param {object} item - The field item.
|
|
50
52
|
*
|
|
51
|
-
* @return {string}
|
|
53
|
+
* @return {string} The item's processed HTML.
|
|
52
54
|
*/
|
|
53
55
|
format: (item) => item.processed
|
|
54
56
|
}
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
import DruxtFieldTextDefault from './DruxtFieldTextDefault.vue'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @deprecated
|
|
6
|
+
* Renders a formatted text field's summary, or the value trimmed to the configured length.
|
|
7
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
8
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
9
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
8
10
|
*/
|
|
9
11
|
export default {
|
|
10
12
|
name: 'DruxtFieldTextSummaryOrTrimmed',
|
|
@@ -35,7 +37,7 @@ export default {
|
|
|
35
37
|
*
|
|
36
38
|
* @param {object} item - The field item.
|
|
37
39
|
*
|
|
38
|
-
* @return {string}
|
|
40
|
+
* @return {string} The item's summary, or the value trimmed to the trim length.
|
|
39
41
|
*/
|
|
40
42
|
format(item) {
|
|
41
43
|
return item.summary
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
import DruxtFieldTextDefault from './DruxtFieldTextDefault.vue'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @deprecated
|
|
6
|
+
* Renders a formatted text field's value, trimmed to the configured length.
|
|
7
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
8
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
9
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
8
10
|
*/
|
|
9
11
|
export default {
|
|
10
12
|
name: 'DruxtFieldTextTrimmed',
|
|
@@ -35,7 +37,7 @@ export default {
|
|
|
35
37
|
*
|
|
36
38
|
* @param {object} item - The field item.
|
|
37
39
|
*
|
|
38
|
-
* @return {string}
|
|
40
|
+
* @return {string} The item's value, trimmed to the trim length.
|
|
39
41
|
*/
|
|
40
42
|
format(item) {
|
|
41
43
|
return item.value.slice(0, this.trimLength)
|
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
import { DruxtFieldMixin } from 'druxt-entity'
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @deprecated
|
|
32
|
+
* Renders a timestamp field's values as plain text.
|
|
33
|
+
* @deprecated in druxt-entity:0.16.0 and is removed from druxt-entity:2.0.0.
|
|
34
|
+
* Use a field wrapper component resolved by the component suggestion system instead.
|
|
35
|
+
* @see https://druxtjs.org/modules/entity/deprecations
|
|
34
36
|
*/
|
|
35
37
|
export default {
|
|
36
38
|
name: 'DruxtFieldTimestamp',
|
package/dist/druxt-entity.esm.js
CHANGED
|
@@ -68,6 +68,7 @@ async function DruxtEntityStorybook({ stories }) {
|
|
|
68
68
|
}));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
const extendComponent = (component) => ({ ...component, isAsync: false });
|
|
71
72
|
const DruxtEntityNuxtModule = async function(moduleOptions = {}) {
|
|
72
73
|
const options = {
|
|
73
74
|
baseUrl: moduleOptions.baseUrl,
|
|
@@ -77,7 +78,7 @@ const DruxtEntityNuxtModule = async function(moduleOptions = {}) {
|
|
|
77
78
|
...((this.options || {}).druxt || {}).entity,
|
|
78
79
|
...moduleOptions,
|
|
79
80
|
components: {
|
|
80
|
-
fields:
|
|
81
|
+
fields: false,
|
|
81
82
|
...(((this.options || {}).druxt || {}).entity || {}).components,
|
|
82
83
|
...moduleOptions.components
|
|
83
84
|
}
|
|
@@ -88,10 +89,11 @@ const DruxtEntityNuxtModule = async function(moduleOptions = {}) {
|
|
|
88
89
|
this.nuxt.hook("components:dirs", (dirs) => {
|
|
89
90
|
dirs.push({
|
|
90
91
|
path: join(__dirname, "components"),
|
|
91
|
-
ignore: ["fields"]
|
|
92
|
+
ignore: ["fields"],
|
|
93
|
+
extendComponent
|
|
92
94
|
});
|
|
93
95
|
if (options.entity.components.fields) {
|
|
94
|
-
dirs.push({ path: join(__dirname, "components/fields") });
|
|
96
|
+
dirs.push({ path: join(__dirname, "components/fields"), extendComponent });
|
|
95
97
|
}
|
|
96
98
|
});
|
|
97
99
|
this.nuxt.hook("storybook:config", async ({ stories }) => {
|
package/dist/druxt-entity.ssr.js
CHANGED
|
@@ -72,6 +72,7 @@ async function DruxtEntityStorybook({ stories }) {
|
|
|
72
72
|
}));
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
const extendComponent = (component) => ({ ...component, isAsync: false });
|
|
75
76
|
const DruxtEntityNuxtModule = async function(moduleOptions = {}) {
|
|
76
77
|
const options = {
|
|
77
78
|
baseUrl: moduleOptions.baseUrl,
|
|
@@ -81,7 +82,7 @@ const DruxtEntityNuxtModule = async function(moduleOptions = {}) {
|
|
|
81
82
|
...((this.options || {}).druxt || {}).entity,
|
|
82
83
|
...moduleOptions,
|
|
83
84
|
components: {
|
|
84
|
-
fields:
|
|
85
|
+
fields: false,
|
|
85
86
|
...(((this.options || {}).druxt || {}).entity || {}).components,
|
|
86
87
|
...moduleOptions.components
|
|
87
88
|
}
|
|
@@ -92,10 +93,11 @@ const DruxtEntityNuxtModule = async function(moduleOptions = {}) {
|
|
|
92
93
|
this.nuxt.hook("components:dirs", (dirs) => {
|
|
93
94
|
dirs.push({
|
|
94
95
|
path: path.join(__dirname, "components"),
|
|
95
|
-
ignore: ["fields"]
|
|
96
|
+
ignore: ["fields"],
|
|
97
|
+
extendComponent
|
|
96
98
|
});
|
|
97
99
|
if (options.entity.components.fields) {
|
|
98
|
-
dirs.push({ path: path.join(__dirname, "components/fields") });
|
|
100
|
+
dirs.push({ path: path.join(__dirname, "components/fields"), extendComponent });
|
|
99
101
|
}
|
|
100
102
|
});
|
|
101
103
|
this.nuxt.hook("storybook:config", async ({ stories }) => {
|
package/icon.svg
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<rect stroke="#036397" x="3.5" y="5" width="17" height="14" rx="2" />
|
|
3
|
+
<circle stroke="#036397" cx="8.25" cy="10.75" r="1.75" />
|
|
4
|
+
<path stroke="#3b8070" d="M12.75 9.75H17M12.75 13.25H17M7 16.25h10" />
|
|
5
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "druxt-entity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0-dev.20260920043715",
|
|
4
4
|
"description": "Drupal Display Mode powered Entity, Form and Field Druxt components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"url": "git+https://github.com/druxt/druxt.js"
|
|
31
31
|
},
|
|
32
32
|
"license": "MIT",
|
|
33
|
+
"author": "Stuart Clark <stuart@druxtjs.org>",
|
|
33
34
|
"exports": {
|
|
34
35
|
".": {
|
|
35
36
|
"require": "./dist/druxt-entity.ssr.js",
|
|
@@ -41,14 +42,20 @@
|
|
|
41
42
|
"module": "dist/druxt-entity.esm.js",
|
|
42
43
|
"files": [
|
|
43
44
|
"dist",
|
|
44
|
-
"templates"
|
|
45
|
+
"templates",
|
|
46
|
+
"icon.svg",
|
|
47
|
+
"banner.svg"
|
|
45
48
|
],
|
|
46
49
|
"dependencies": {
|
|
47
50
|
"deepmerge": "^4.3.1",
|
|
48
|
-
"drupal-jsonapi-params": "^2.2
|
|
49
|
-
"druxt": "
|
|
50
|
-
"druxt-router": "
|
|
51
|
-
"druxt-schema": "
|
|
51
|
+
"drupal-jsonapi-params": "^2.3.2",
|
|
52
|
+
"druxt": "0.24.1-dev.20260920043715",
|
|
53
|
+
"druxt-router": "0.31.1-dev.20260920043715",
|
|
54
|
+
"druxt-schema": "0.11.4-dev.20260920043715"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"druxt-test-utils": "^0.2.15",
|
|
58
|
+
"vuex": "^3.6.2"
|
|
52
59
|
},
|
|
53
60
|
"publishConfig": {
|
|
54
61
|
"access": "public"
|