@ditojs/admin 3.1.0 → 3.1.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.
- package/dist/dito-admin.es.js +461 -451
- package/dist/dito-admin.umd.js +5 -5
- package/package.json +5 -5
- package/src/mixins/ResourceMixin.js +4 -2
- package/src/types/DitoTypeTreeList.vue +4 -3
- package/src/utils/FormModel.js +11 -11
- package/src/utils/schema/data.js +27 -4
- package/src/utils/schema/validation.js +2 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/admin",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
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/main/packages/admin",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"not ie_mob > 0"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@ditojs/ui": "^3.1.
|
|
45
|
-
"@ditojs/utils": "^3.1.
|
|
44
|
+
"@ditojs/ui": "^3.1.1",
|
|
45
|
+
"@ditojs/utils": "^3.1.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@kyvg/vue3-notification": "^3.4.2",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"vue-upload-component": "^3.2.2"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"@ditojs/build": "^3.1.
|
|
90
|
+
"@ditojs/build": "^3.1.1",
|
|
91
91
|
"@kyvg/vue3-notification": "^3.4.2",
|
|
92
92
|
"@tiptap/core": "^3.31.4",
|
|
93
93
|
"@tiptap/extension-blockquote": "^3.31.4",
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
"vue-router": "^5.3.1",
|
|
132
132
|
"vue-upload-component": "^3.2.2"
|
|
133
133
|
},
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "acce85bb38d817aab18f9d5d03b3aa9dff00c3f9"
|
|
135
135
|
}
|
|
@@ -54,8 +54,10 @@ export default {
|
|
|
54
54
|
// `isTransient()` to only return `!this.providesData`.
|
|
55
55
|
const form = this.formComponent
|
|
56
56
|
return (
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
(
|
|
58
|
+
!this.providesData &&
|
|
59
|
+
!this.linksToView
|
|
60
|
+
) ||
|
|
59
61
|
form && (
|
|
60
62
|
form.isTransient ||
|
|
61
63
|
form.isCreating
|
package/src/utils/FormModel.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@ditojs/utils'
|
|
10
10
|
import DitoContext from '../DitoContext.js'
|
|
11
11
|
import { DataSchemaResolver } from './DataSchemaResolver.js'
|
|
12
|
-
import { isNested
|
|
12
|
+
import { isNested } from './schema/structure.js'
|
|
13
13
|
import { isEmptySchema } from './schema/lookup.js'
|
|
14
14
|
import {
|
|
15
15
|
getSchemaValue,
|
|
@@ -295,7 +295,7 @@ export class FormModel {
|
|
|
295
295
|
initializeData(schema, data, this.component, {
|
|
296
296
|
dataPath: this.dataPath,
|
|
297
297
|
rootData: this.rootData,
|
|
298
|
-
|
|
298
|
+
shouldSkipSourcesWithResource: true,
|
|
299
299
|
// The model writes the values of components with `compute()`,
|
|
300
300
|
// including their defaults:
|
|
301
301
|
shouldSetDefaultsOfComponentsWithCompute: false
|
|
@@ -318,9 +318,8 @@ export class FormModel {
|
|
|
318
318
|
processSchemaData(schema, data, {
|
|
319
319
|
dataPath: this.dataPath,
|
|
320
320
|
componentPath: this.componentPath,
|
|
321
|
-
shouldProcess: entry => (
|
|
322
|
-
|
|
323
|
-
),
|
|
321
|
+
shouldProcess: entry => this.isEntryShown(entry),
|
|
322
|
+
shouldSkipSourcesWithResource: true,
|
|
324
323
|
before: entry => {
|
|
325
324
|
if (hasComputedValueSource(entry.schema)) {
|
|
326
325
|
computedValueEntries.set(entry.componentPath, entry)
|
|
@@ -585,12 +584,13 @@ function takeOverChangedValues(target, before, after) {
|
|
|
585
584
|
return target
|
|
586
585
|
}
|
|
587
586
|
const isSameShape = (
|
|
588
|
-
isPlainObject(before) && isPlainObject(after) && isPlainObject(target) ||
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
587
|
+
isPlainObject(before) && isPlainObject(after) && isPlainObject(target) || (
|
|
588
|
+
isArray(before) &&
|
|
589
|
+
isArray(after) &&
|
|
590
|
+
isArray(target) &&
|
|
591
|
+
before.length === after.length &&
|
|
592
|
+
after.length === target.length
|
|
593
|
+
)
|
|
594
594
|
)
|
|
595
595
|
if (!isSameShape) {
|
|
596
596
|
return clone(after)
|
package/src/utils/schema/data.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
someNestedSchemaComponent,
|
|
17
17
|
hasNestedSchemaComponents,
|
|
18
18
|
isPanelWithOwnData,
|
|
19
|
+
isSourceWithResource,
|
|
19
20
|
isNested
|
|
20
21
|
} from './structure.js'
|
|
21
22
|
import {
|
|
@@ -129,9 +130,10 @@ export function isMissingValue(schema, data, name, context) {
|
|
|
129
130
|
// Only read the value if needed, so that callers that are tracked, e.g. the
|
|
130
131
|
// walk of the form model's data, don't depend on all values.
|
|
131
132
|
return (
|
|
132
|
-
!(name in data) ||
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
!(name in data) || (
|
|
134
|
+
!!getTypeOptions(schema)?.treatNullAsMissing?.(getContext(context)) &&
|
|
135
|
+
data[name] === null
|
|
136
|
+
)
|
|
135
137
|
)
|
|
136
138
|
}
|
|
137
139
|
|
|
@@ -178,6 +180,7 @@ export function initializeData(schema, data = {}, component, {
|
|
|
178
180
|
dataPath = null,
|
|
179
181
|
rootData = data,
|
|
180
182
|
shouldProcess,
|
|
183
|
+
shouldSkipSourcesWithResource = false,
|
|
181
184
|
// Whether to also set the defaults of components with `compute()`. New data
|
|
182
185
|
// starts with all defaults, which `compute()` can rely on. In data that was
|
|
183
186
|
// loaded, `compute()` may derive missing values instead, and they fall back
|
|
@@ -214,6 +217,7 @@ export function initializeData(schema, data = {}, component, {
|
|
|
214
217
|
dataPath,
|
|
215
218
|
before,
|
|
216
219
|
shouldProcess,
|
|
220
|
+
shouldSkipSourcesWithResource,
|
|
217
221
|
options
|
|
218
222
|
})
|
|
219
223
|
}
|
|
@@ -429,6 +433,11 @@ export function processData(schema, sourceSchema, data, dataPath, {
|
|
|
429
433
|
* them contain the `componentPath` of the component, tab or panel, continuing
|
|
430
434
|
* `componentPath` like `DitoMixin.componentPath` does.
|
|
431
435
|
*
|
|
436
|
+
* With `shouldSkipSourcesWithResource`, sources with their own resource are
|
|
437
|
+
* skipped along with their items, which they load and save through their
|
|
438
|
+
* resource, but not their panels, which display the data that contains them,
|
|
439
|
+
* see `DitoContainer.panelEntries`.
|
|
440
|
+
*
|
|
432
441
|
* The primitive values of lists with `wrapPrimitives` are walked wrapped in
|
|
433
442
|
* objects under the `wrapPrimitives` key, like the admin edits them, see
|
|
434
443
|
* `SourceMixin`. `wrappedPrimitiveName` is that key while walking such an
|
|
@@ -444,9 +453,16 @@ export function processSchemaData(schema, data, {
|
|
|
444
453
|
before = null,
|
|
445
454
|
after = null,
|
|
446
455
|
shouldProcess = () => true,
|
|
456
|
+
shouldSkipSourcesWithResource = false,
|
|
447
457
|
options
|
|
448
458
|
}) {
|
|
449
|
-
const walkOptions = {
|
|
459
|
+
const walkOptions = {
|
|
460
|
+
before,
|
|
461
|
+
after,
|
|
462
|
+
shouldProcess,
|
|
463
|
+
shouldSkipSourcesWithResource,
|
|
464
|
+
options
|
|
465
|
+
}
|
|
450
466
|
const getDataPath = (dataPath, token) =>
|
|
451
467
|
dataPath != null
|
|
452
468
|
? appendDataPath(dataPath, token)
|
|
@@ -472,6 +488,13 @@ export function processSchemaData(schema, data, {
|
|
|
472
488
|
if (!shouldProcess(entry)) {
|
|
473
489
|
continue
|
|
474
490
|
}
|
|
491
|
+
if (
|
|
492
|
+
shouldSkipSourcesWithResource &&
|
|
493
|
+
isSourceWithResource(componentSchema)
|
|
494
|
+
) {
|
|
495
|
+
processTabOrPanelSchemas(componentSchema.panels, entry.componentPath)
|
|
496
|
+
continue
|
|
497
|
+
}
|
|
475
498
|
if (isPanelWithOwnData(componentSchema)) {
|
|
476
499
|
// The components of panels with their own data don't edit `data`.
|
|
477
500
|
continue
|
|
@@ -2,7 +2,6 @@ import DitoContext from '../../DitoContext.js'
|
|
|
2
2
|
import * as validators from '../../validators/index.js'
|
|
3
3
|
import { isFunction, isRegExp, asArray, normalizeDataPath } from '@ditojs/utils'
|
|
4
4
|
import { getTypeOptions } from './types.js'
|
|
5
|
-
import { isSourceWithResource } from './structure.js'
|
|
6
5
|
import {
|
|
7
6
|
getSchemaValue,
|
|
8
7
|
shouldRenderSchema,
|
|
@@ -86,10 +85,8 @@ export function getDataValidationErrors(schema, data, {
|
|
|
86
85
|
rootData
|
|
87
86
|
})
|
|
88
87
|
|
|
89
|
-
const shouldProcess = entry =>
|
|
90
|
-
!isSourceWithResource(entry.schema) &&
|
|
88
|
+
const shouldProcess = entry =>
|
|
91
89
|
shouldRenderSchema(entry.schema, createContext(entry))
|
|
92
|
-
)
|
|
93
90
|
|
|
94
91
|
const before = entry => {
|
|
95
92
|
const { schema, data, name, dataPath } = entry
|
|
@@ -112,6 +109,7 @@ export function getDataValidationErrors(schema, data, {
|
|
|
112
109
|
processSchemaData(schema, data, {
|
|
113
110
|
dataPath,
|
|
114
111
|
shouldProcess,
|
|
112
|
+
shouldSkipSourcesWithResource: true,
|
|
115
113
|
before,
|
|
116
114
|
options: { component, rootData }
|
|
117
115
|
})
|