@ditojs/admin 1.17.0 → 1.19.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.
- package/dist/dito-admin.es.js +1381 -1351
- package/dist/dito-admin.umd.js +4 -4
- package/package.json +6 -6
- package/src/components/DitoForm.vue +1 -0
- package/src/components/DitoPane.vue +1 -1
- package/src/components/DitoView.vue +25 -23
- package/src/types/TypeList.vue +3 -1
- package/src/utils/schema.js +56 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
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",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"not ie_mob > 0"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ditojs/ui": "^1.
|
|
41
|
-
"@ditojs/utils": "^1.
|
|
40
|
+
"@ditojs/ui": "^1.19.0",
|
|
41
|
+
"@ditojs/utils": "^1.19.0",
|
|
42
42
|
"codeflask": "^1.4.1",
|
|
43
43
|
"filesize": "^10.0.5",
|
|
44
44
|
"filesize-parser": "^1.5.0",
|
|
@@ -60,14 +60,14 @@
|
|
|
60
60
|
"vuedraggable": "^2.24.3"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@ditojs/build": "^1.
|
|
63
|
+
"@ditojs/build": "^1.19.0",
|
|
64
64
|
"pug": "^3.0.2",
|
|
65
65
|
"sass": "1.56.1",
|
|
66
66
|
"type-fest": "^3.3.0",
|
|
67
67
|
"typescript": "^4.9.3",
|
|
68
|
-
"vite": "^3.2.
|
|
68
|
+
"vite": "^3.2.5",
|
|
69
69
|
"vite-plugin-vue2": "^2.0.2"
|
|
70
70
|
},
|
|
71
71
|
"types": "types",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "b6260469c956b99774657045f192fd429c6521d1"
|
|
73
73
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.dito-form.dito-scroll-parent(
|
|
3
3
|
:class="{ 'dito-form-nested': isNestedRoute }"
|
|
4
|
+
:data-resource="sourceSchema.path"
|
|
4
5
|
)
|
|
5
6
|
// NOTE: Nested form components are kept alive by using `v-show` instead of
|
|
6
7
|
// `v-if` here, so event handling and other things still work with nested
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
flex-flow: row wrap
|
|
41
41
|
align-content: flex-start
|
|
42
42
|
align-items: baseline
|
|
43
|
-
// Remove padding added by `.dito-container`
|
|
43
|
+
// Remove the padding added by `.dito-container` inside `.dito-pane`:
|
|
44
44
|
margin: (-$form-spacing) (-$form-spacing-half)
|
|
45
45
|
// Add removed horizontal margin again to max-width:
|
|
46
46
|
max-width: $content-width + 2 * $form-spacing-half
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
// Only render DitoView when it is active, otherwise a normal router-view
|
|
3
|
+
// instead, to nest further route components.
|
|
4
|
+
// NOTE: This is different from the handling in DitoForm, where `v-show` is
|
|
5
|
+
// used to always render forms even when other nested forms are present.
|
|
6
|
+
router-view(
|
|
7
|
+
v-if="!isLastRoute"
|
|
8
|
+
:key="name"
|
|
9
|
+
)
|
|
10
|
+
.dito-view.dito-scroll-parent(
|
|
11
|
+
v-else-if="shouldRender(viewSchema)"
|
|
12
|
+
:data-resource="sourceSchema.path"
|
|
13
|
+
)
|
|
14
|
+
dito-schema.dito-scroll(
|
|
15
|
+
:schema="viewSchema"
|
|
16
|
+
:data="data"
|
|
17
|
+
:meta="meta"
|
|
18
|
+
:store="getChildStore(name)"
|
|
19
|
+
:disabled="isLoading"
|
|
20
|
+
:generateLabels="false"
|
|
21
|
+
:menuHeader="true"
|
|
9
22
|
)
|
|
10
|
-
.dito-view.dito-scroll-parent(
|
|
11
|
-
v-else-if="shouldRender(viewSchema)"
|
|
12
|
-
)
|
|
13
|
-
dito-schema.dito-scroll(
|
|
14
|
-
:schema="viewSchema"
|
|
15
|
-
:data="data"
|
|
16
|
-
:meta="meta"
|
|
17
|
-
:store="getChildStore(name)"
|
|
18
|
-
:disabled="isLoading"
|
|
19
|
-
:generateLabels="false"
|
|
20
|
-
:menuHeader="true"
|
|
21
|
-
)
|
|
22
23
|
</template>
|
|
23
24
|
|
|
24
25
|
<script>
|
|
@@ -68,16 +69,17 @@ export default DitoComponent.component('dito-view', {
|
|
|
68
69
|
},
|
|
69
70
|
|
|
70
71
|
viewSchema() {
|
|
71
|
-
const { schema } = this
|
|
72
|
+
const { component, ...schema } = this.schema
|
|
72
73
|
// Translate single-component schemas into multi-component schemas,
|
|
73
74
|
// so they can be rendered directly through DitoSchema also:
|
|
74
75
|
return this.isSingleComponentView
|
|
75
76
|
? {
|
|
76
|
-
|
|
77
|
+
...schema,
|
|
77
78
|
components: {
|
|
78
79
|
[schema.name]: {
|
|
79
|
-
|
|
80
|
-
label: false
|
|
80
|
+
name: schema.name,
|
|
81
|
+
label: false,
|
|
82
|
+
...component
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
}
|
package/src/types/TypeList.vue
CHANGED
package/src/utils/schema.js
CHANGED
|
@@ -40,14 +40,21 @@ export function forEachSchema(schema, callback) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export function forEachSchemaComponent(schema, callback) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return res
|
|
48
|
-
}
|
|
43
|
+
if (isSingleComponentView(schema)) {
|
|
44
|
+
const res = callback(schema.component, schema.name)
|
|
45
|
+
if (res !== undefined) {
|
|
46
|
+
return res
|
|
49
47
|
}
|
|
50
|
-
}
|
|
48
|
+
} else {
|
|
49
|
+
return forEachSchema(schema, schema => {
|
|
50
|
+
for (const [name, component] of Object.entries(schema.components || {})) {
|
|
51
|
+
const res = callback(component, name)
|
|
52
|
+
if (res !== undefined) {
|
|
53
|
+
return res
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
}
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
export function findSchemaComponent(schema, callback) {
|
|
@@ -71,6 +78,22 @@ export function everySchemaComponent(schema, callback) {
|
|
|
71
78
|
) !== false
|
|
72
79
|
}
|
|
73
80
|
|
|
81
|
+
export function isSchema(schema) {
|
|
82
|
+
return isObject(schema) && isString(schema.type)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function isForm(schema) {
|
|
86
|
+
return isSchema(schema) && schema.type === 'form'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function isView(schema) {
|
|
90
|
+
return isSchema(schema) && schema.type === 'view'
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function getSchemaIdentifier(schema) {
|
|
94
|
+
return schema.name || schema.label || schema.type
|
|
95
|
+
}
|
|
96
|
+
|
|
74
97
|
export async function resolveSchema(schema, unwrapModule = false) {
|
|
75
98
|
if (isFunction(schema)) {
|
|
76
99
|
schema = schema()
|
|
@@ -126,7 +149,7 @@ export async function resolveSchemas(
|
|
|
126
149
|
|
|
127
150
|
export async function resolvePanels(schema) {
|
|
128
151
|
const { panels } = schema
|
|
129
|
-
if (
|
|
152
|
+
if (panels) {
|
|
130
153
|
schema.panels = await resolveSchemas(panels)
|
|
131
154
|
}
|
|
132
155
|
}
|
|
@@ -135,11 +158,15 @@ export async function processView(component, api, schema, name, routes) {
|
|
|
135
158
|
const children = []
|
|
136
159
|
processRouteSchema(api, schema, name)
|
|
137
160
|
await resolvePanels(schema)
|
|
138
|
-
if (
|
|
139
|
-
|
|
161
|
+
if (isView(schema)) {
|
|
162
|
+
if (isSingleComponentView(schema)) {
|
|
163
|
+
await processComponent(api, schema.component, name, children, 0)
|
|
164
|
+
} else {
|
|
165
|
+
// A multi-component view, start at level 1
|
|
166
|
+
await processSchemaComponents(api, schema, children, 1)
|
|
167
|
+
}
|
|
140
168
|
} else {
|
|
141
|
-
|
|
142
|
-
await processSchemaComponents(api, schema, children, 1)
|
|
169
|
+
throw new Error(`Invalid view schema: '${getSchemaIdentifier(schema)}'`)
|
|
143
170
|
}
|
|
144
171
|
routes.push({
|
|
145
172
|
path: `/${schema.path}`,
|
|
@@ -198,29 +225,36 @@ export async function processForms(api, schema, level) {
|
|
|
198
225
|
|
|
199
226
|
export async function resolveForm(form) {
|
|
200
227
|
form = await resolveSchema(form, true)
|
|
228
|
+
if (!isForm(form)) {
|
|
229
|
+
throw new Error(`Invalid form schema: '${getSchemaIdentifier(form)}'`)
|
|
230
|
+
}
|
|
201
231
|
if (form) {
|
|
202
232
|
await resolvePanels(form)
|
|
203
233
|
}
|
|
204
234
|
return form
|
|
205
235
|
}
|
|
206
236
|
|
|
207
|
-
export function isSingleComponentView(schema) {
|
|
208
|
-
// If the schema has a type, it is a single-component view.
|
|
209
|
-
return !!schema.type
|
|
210
|
-
}
|
|
211
|
-
|
|
212
237
|
export function hasFormSchema(schema) {
|
|
213
238
|
// Support both single form and multiple forms notation, as well as inlined
|
|
214
239
|
// components.
|
|
215
|
-
return
|
|
216
|
-
schema
|
|
217
|
-
schema.forms ||
|
|
218
|
-
schema.components
|
|
240
|
+
return (
|
|
241
|
+
isSchema(schema) &&
|
|
242
|
+
isObject(schema.form || schema.forms || schema.components)
|
|
219
243
|
)
|
|
220
244
|
}
|
|
221
245
|
|
|
222
246
|
export function hasMultipleFormSchemas(schema) {
|
|
223
|
-
return
|
|
247
|
+
return (
|
|
248
|
+
isSchema(schema) &&
|
|
249
|
+
Object.keys(schema?.forms || {}).length > 1
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export function isSingleComponentView(schema) {
|
|
254
|
+
return (
|
|
255
|
+
isView(schema) &&
|
|
256
|
+
isObject(schema.component)
|
|
257
|
+
)
|
|
224
258
|
}
|
|
225
259
|
|
|
226
260
|
export function getViewSchema(schema, context) {
|