@ditojs/admin 2.28.0 → 2.28.2
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/dist/dito-admin.es.js +37 -20
- package/dist/dito-admin.umd.js +5 -5
- package/package.json +2 -2
- package/src/components/DitoForm.vue +3 -3
- package/src/components/DitoPanel.vue +5 -0
- package/src/components/DitoSchema.vue +5 -2
- package/src/mixins/DitoMixin.js +4 -1
- package/src/mixins/ResourceMixin.js +15 -6
- package/src/mixins/SourceMixin.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/admin",
|
|
3
|
-
"version": "2.28.
|
|
3
|
+
"version": "2.28.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Dito.js Admin is a schema based admin interface for Dito.js Server, featuring auto-generated views and forms and built with Vue.js",
|
|
6
6
|
"repository": "https://github.com/ditojs/dito/tree/master/packages/admin",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"vite": "^5.2.10"
|
|
84
84
|
},
|
|
85
85
|
"types": "types",
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "a9db3666df01cb3ee66a0ec7525d9221e15c5655",
|
|
87
87
|
"scripts": {
|
|
88
88
|
"build": "vite build",
|
|
89
89
|
"watch": "yarn build --mode 'development' --watch",
|
|
@@ -322,8 +322,8 @@ export default DitoComponent.component('DitoForm', {
|
|
|
322
322
|
},
|
|
323
323
|
|
|
324
324
|
// @override ResourceMixin.getResource()
|
|
325
|
-
getResource(
|
|
326
|
-
const resource = ResourceMixin.methods.getResource.call(this,
|
|
325
|
+
getResource(options) {
|
|
326
|
+
const resource = ResourceMixin.methods.getResource.call(this, options)
|
|
327
327
|
return getMemberResource(this.itemId, resource) || resource
|
|
328
328
|
},
|
|
329
329
|
|
|
@@ -404,7 +404,7 @@ export default DitoComponent.component('DitoForm', {
|
|
|
404
404
|
|
|
405
405
|
// Allow buttons to override both method and resource path to submit to:
|
|
406
406
|
let { method } = this
|
|
407
|
-
let resource = this.getResource(method)
|
|
407
|
+
let resource = this.getResource({ method })
|
|
408
408
|
const buttonResource = getResource(button.schema.resource, {
|
|
409
409
|
parent: resource
|
|
410
410
|
})
|
|
@@ -8,6 +8,7 @@ component.dito-panel(
|
|
|
8
8
|
)
|
|
9
9
|
DitoSchema.dito-panel__schema(
|
|
10
10
|
:schema="panelSchema"
|
|
11
|
+
:dataSchema="panelDataSchema"
|
|
11
12
|
:dataPath="panelDataPath"
|
|
12
13
|
:data="panelData"
|
|
13
14
|
:meta="meta"
|
|
@@ -114,6 +115,10 @@ export default DitoComponent.component('DitoPanel', {
|
|
|
114
115
|
return this.hasOwnData ? 'form' : 'div'
|
|
115
116
|
},
|
|
116
117
|
|
|
118
|
+
panelDataSchema() {
|
|
119
|
+
return this.hasOwnData ? this.schema : this.schemaComponent.schema
|
|
120
|
+
},
|
|
121
|
+
|
|
117
122
|
panelDataPath() {
|
|
118
123
|
// If the panel provides its own data, then it needs to prefix all
|
|
119
124
|
// components with its data-path, but if it shares data with the schema
|
|
@@ -145,6 +145,9 @@ export default DitoComponent.component('DitoSchema', {
|
|
|
145
145
|
|
|
146
146
|
props: {
|
|
147
147
|
schema: { type: Object, required: true },
|
|
148
|
+
// `dataSchema` is only provided for panels, where the panel schema
|
|
149
|
+
// is different from the data schema for panels without own data.
|
|
150
|
+
dataSchema: { type: Object, default: props => props.schema },
|
|
148
151
|
dataPath: { type: String, default: '' },
|
|
149
152
|
data: { type: Object, default: null },
|
|
150
153
|
meta: { type: Object, default: () => ({}) },
|
|
@@ -675,7 +678,7 @@ export default DitoComponent.component('DitoSchema', {
|
|
|
675
678
|
// We can't set `this.data = ...` because it's a property, but we can set
|
|
676
679
|
// all known properties on it to the values returned by
|
|
677
680
|
// `setDefaultValues()`, as they are all reactive already from the starts:
|
|
678
|
-
Object.assign(this.data, setDefaultValues(this.
|
|
681
|
+
Object.assign(this.data, setDefaultValues(this.dataSchema, {}, this))
|
|
679
682
|
this.clearErrors()
|
|
680
683
|
},
|
|
681
684
|
|
|
@@ -715,7 +718,7 @@ export default DitoComponent.component('DitoSchema', {
|
|
|
715
718
|
|
|
716
719
|
processData({ target = 'clipboard', schemaOnly = true } = {}) {
|
|
717
720
|
return processData(
|
|
718
|
-
this.
|
|
721
|
+
this.dataSchema,
|
|
719
722
|
this.sourceSchema,
|
|
720
723
|
this.data,
|
|
721
724
|
this.dataPath,
|
package/src/mixins/DitoMixin.js
CHANGED
|
@@ -314,7 +314,10 @@ export default {
|
|
|
314
314
|
resource = getResource(resource, {
|
|
315
315
|
// Resources without a parent inherit the one from `dataComponent`
|
|
316
316
|
// automatically.
|
|
317
|
-
parent: this.dataComponent?.getResource(
|
|
317
|
+
parent: this.dataComponent?.getResource({
|
|
318
|
+
method: resource?.method,
|
|
319
|
+
child: resource
|
|
320
|
+
}) ?? null
|
|
318
321
|
})
|
|
319
322
|
return this.api.resources.any(resource)
|
|
320
323
|
},
|
|
@@ -124,13 +124,18 @@ export default {
|
|
|
124
124
|
},
|
|
125
125
|
|
|
126
126
|
methods: {
|
|
127
|
-
getResource(method = 'get') {
|
|
127
|
+
getResource({ method = 'get', child } = {}) {
|
|
128
128
|
// Returns the resource object representing the resource for the
|
|
129
129
|
// associated source schema.
|
|
130
|
-
|
|
130
|
+
const resource = this.sourceSchema?.resource
|
|
131
|
+
return getResource(resource, {
|
|
131
132
|
type: 'collection',
|
|
132
133
|
method,
|
|
133
|
-
parent: this.parentResourceComponent?.getResource(
|
|
134
|
+
parent: this.parentResourceComponent?.getResource({
|
|
135
|
+
method,
|
|
136
|
+
child: resource
|
|
137
|
+
}) ?? null,
|
|
138
|
+
child
|
|
134
139
|
})
|
|
135
140
|
},
|
|
136
141
|
|
|
@@ -229,7 +234,7 @@ export default {
|
|
|
229
234
|
async handleRequest(
|
|
230
235
|
{
|
|
231
236
|
method,
|
|
232
|
-
resource = this.getResource(method),
|
|
237
|
+
resource = this.getResource({ method }),
|
|
233
238
|
query,
|
|
234
239
|
data
|
|
235
240
|
},
|
|
@@ -285,8 +290,12 @@ export default {
|
|
|
285
290
|
},
|
|
286
291
|
|
|
287
292
|
async submit(button) {
|
|
288
|
-
|
|
289
|
-
|
|
293
|
+
let { resource } = button.schema
|
|
294
|
+
resource = getResource(resource, {
|
|
295
|
+
parent: this.getResource({
|
|
296
|
+
method: resource?.method,
|
|
297
|
+
child: resource
|
|
298
|
+
})
|
|
290
299
|
})
|
|
291
300
|
if (resource) {
|
|
292
301
|
const { method } = resource
|