@ditojs/admin 2.10.1 → 2.10.3
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 +911 -901
- package/dist/dito-admin.umd.js +5 -5
- package/package.json +4 -4
- package/src/DitoContext.js +1 -1
- package/src/components/DitoCreateButton.vue +24 -19
- package/src/components/DitoPanel.vue +0 -4
- package/src/mixins/PulldownMixin.js +5 -5
- package/src/utils/filter.js +31 -15
- package/src/utils/schema.js +3 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/admin",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.3",
|
|
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",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"not ie_mob > 0"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@ditojs/ui": "^2.10.
|
|
36
|
+
"@ditojs/ui": "^2.10.2",
|
|
37
37
|
"@ditojs/utils": "^2.10.0",
|
|
38
38
|
"@kyvg/vue3-notification": "^2.9.1",
|
|
39
39
|
"@lk77/vue3-color": "^3.0.6",
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
"@vitejs/plugin-vue": "^4.2.3",
|
|
79
79
|
"@vue/compiler-sfc": "^3.3.4",
|
|
80
80
|
"pug": "^3.0.2",
|
|
81
|
-
"sass": "1.
|
|
81
|
+
"sass": "1.63.2",
|
|
82
82
|
"typescript": "^5.1.3",
|
|
83
83
|
"vite": "^4.3.9"
|
|
84
84
|
},
|
|
85
85
|
"types": "types",
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "64c92430531216d8f463835bc07c4ac8e2370bf0",
|
|
87
87
|
"scripts": {
|
|
88
88
|
"build": "vite build",
|
|
89
89
|
"watch": "yarn build --mode 'development' --watch",
|
package/src/DitoContext.js
CHANGED
|
@@ -22,7 +22,7 @@ const contexts = new WeakMap()
|
|
|
22
22
|
|
|
23
23
|
function get(context, key, defaultValue) {
|
|
24
24
|
const object = contexts.get(toRaw(context))
|
|
25
|
-
const value = object[key]
|
|
25
|
+
const value = key in object ? object[key] : undefined
|
|
26
26
|
// If `object` explicitly sets the key to `undefined`, return it.
|
|
27
27
|
return value !== undefined || hasOwnProperty.call(object, key)
|
|
28
28
|
? value
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.dito-create-button
|
|
3
|
+
button.dito-button(
|
|
4
|
+
v-if="creatableForm"
|
|
5
|
+
:type="isInlined ? 'button' : 'submit'"
|
|
6
|
+
:disabled="disabled"
|
|
7
|
+
v-bind="getButtonAttributes(verb)"
|
|
8
|
+
@click="createItem(creatableForm)"
|
|
9
|
+
) {{ text }}
|
|
3
10
|
template(
|
|
4
|
-
v-if="
|
|
11
|
+
v-else-if="creatableForms"
|
|
5
12
|
)
|
|
6
13
|
button.dito-button(
|
|
7
14
|
type="button"
|
|
@@ -11,22 +18,14 @@
|
|
|
11
18
|
) {{ text }}
|
|
12
19
|
ul.dito-pulldown(:class="{ 'dito-open': pulldown.open }")
|
|
13
20
|
li(
|
|
14
|
-
v-for="(form, type) in
|
|
21
|
+
v-for="(form, type) in creatableForms"
|
|
15
22
|
)
|
|
16
23
|
a(
|
|
17
|
-
v-if="isFormCreatable(form)"
|
|
18
24
|
v-show="shouldShowSchema(form)"
|
|
19
25
|
:class="getFormClass(form, type)"
|
|
20
26
|
@mousedown.stop="onPulldownMouseDown(type)"
|
|
21
27
|
@mouseup="onPulldownMouseUp(type)"
|
|
22
28
|
) {{ getLabel(form) }}
|
|
23
|
-
button.dito-button(
|
|
24
|
-
v-else-if="isFormCreatable(forms.default)"
|
|
25
|
-
:type="isInlined ? 'button' : 'submit'"
|
|
26
|
-
:disabled="disabled"
|
|
27
|
-
v-bind="getButtonAttributes(verb)"
|
|
28
|
-
@click="createItem(forms.default)"
|
|
29
|
-
) {{ text }}
|
|
30
29
|
</template>
|
|
31
30
|
|
|
32
31
|
<script>
|
|
@@ -64,16 +63,22 @@ export default DitoComponent.component('DitoCreateButton', {
|
|
|
64
63
|
return getFormSchemas(this.schema, this.context)
|
|
65
64
|
},
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
creatableForms() {
|
|
67
|
+
const entries = Object.entries(this.forms).filter(
|
|
68
|
+
(type, form) => this.isFormCreatable(form)
|
|
69
|
+
)
|
|
70
|
+
return entries.length > 0
|
|
71
|
+
? Object.fromEntries(entries)
|
|
72
|
+
: null
|
|
69
73
|
},
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
const forms =
|
|
73
|
-
return (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
creatableForm() {
|
|
76
|
+
const forms = this.creatableForms
|
|
77
|
+
return forms && Object.keys(forms).length === 1 && forms.default || null
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
isInlined() {
|
|
81
|
+
return isInlined(this.schema)
|
|
77
82
|
}
|
|
78
83
|
},
|
|
79
84
|
|
|
@@ -92,7 +97,7 @@ export default DitoComponent.component('DitoCreateButton', {
|
|
|
92
97
|
},
|
|
93
98
|
|
|
94
99
|
createItem(form, type = null) {
|
|
95
|
-
if (
|
|
100
|
+
if (!this.shouldDisableSchema(form)) {
|
|
96
101
|
if (this.isInlined) {
|
|
97
102
|
this.sourceComponent.createItem(form, type)
|
|
98
103
|
} else {
|
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
},
|
|
18
18
|
|
|
19
19
|
mouseup: () => {
|
|
20
|
-
if (this.onPulldownMouseUp(
|
|
20
|
+
if (this.onPulldownMouseUp()) {
|
|
21
21
|
this.pulldown.handlers.remove()
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -28,8 +28,8 @@ export default {
|
|
|
28
28
|
},
|
|
29
29
|
|
|
30
30
|
methods: {
|
|
31
|
-
onPulldownMouseDown(value) {
|
|
32
|
-
if (
|
|
31
|
+
onPulldownMouseDown(value = null) {
|
|
32
|
+
if (value === null) {
|
|
33
33
|
this.setPulldownOpen(true)
|
|
34
34
|
this.checkTime = true
|
|
35
35
|
} else {
|
|
@@ -37,11 +37,11 @@ export default {
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
|
|
40
|
-
onPulldownMouseUp(value) {
|
|
40
|
+
onPulldownMouseUp(value = null) {
|
|
41
41
|
const { startTime } = this.pulldown
|
|
42
42
|
if (!this.checkTime || startTime && (Date.now() - startTime > 250)) {
|
|
43
43
|
this.setPulldownOpen(false)
|
|
44
|
-
if (value) {
|
|
44
|
+
if (value !== null) {
|
|
45
45
|
this.onPulldownSelect(value)
|
|
46
46
|
}
|
|
47
47
|
return true
|
package/src/utils/filter.js
CHANGED
|
@@ -69,7 +69,6 @@ export function createFiltersPanel(api, filters, dataPath, query) {
|
|
|
69
69
|
type: 'panel',
|
|
70
70
|
label: 'Filters',
|
|
71
71
|
name: '$filters',
|
|
72
|
-
target: dataPath,
|
|
73
72
|
// Override the default value
|
|
74
73
|
disabled: false,
|
|
75
74
|
sticky,
|
|
@@ -152,6 +151,15 @@ function createFiltersButtons(small) {
|
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
153
|
|
|
154
|
+
function getDataName(filterName) {
|
|
155
|
+
// Prefix filter data keys with '$' to avoid conflicts with other data keys:
|
|
156
|
+
return `$${filterName}`
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function getFilterName(dataName) {
|
|
160
|
+
return dataName.startsWith('$') ? dataName.slice(1) : null
|
|
161
|
+
}
|
|
162
|
+
|
|
155
163
|
function createFiltersComponents(filters) {
|
|
156
164
|
const comps = {}
|
|
157
165
|
for (const filter of Object.values(getNamedSchemas(filters) || {})) {
|
|
@@ -177,8 +185,8 @@ function createFiltersComponents(filters) {
|
|
|
177
185
|
}
|
|
178
186
|
}
|
|
179
187
|
}
|
|
180
|
-
comps[filter.name] = {
|
|
181
|
-
label: form.label,
|
|
188
|
+
comps[getDataName(filter.name)] = {
|
|
189
|
+
label: form.label ?? labelize(filter.name),
|
|
182
190
|
type: 'object',
|
|
183
191
|
width,
|
|
184
192
|
default: () => ({}),
|
|
@@ -194,23 +202,31 @@ function createFiltersComponents(filters) {
|
|
|
194
202
|
return comps
|
|
195
203
|
}
|
|
196
204
|
|
|
197
|
-
function getComponentsForFilter(schema,
|
|
198
|
-
const component = schema.components[
|
|
205
|
+
function getComponentsForFilter(schema, dataName) {
|
|
206
|
+
const component = schema.components[dataName]
|
|
199
207
|
return component?.form?.components
|
|
200
208
|
}
|
|
201
209
|
|
|
202
210
|
function formatFiltersData(schema, data) {
|
|
203
211
|
const filters = []
|
|
204
|
-
for (const
|
|
205
|
-
const entry = data[
|
|
212
|
+
for (const dataName in data) {
|
|
213
|
+
const entry = data[dataName]
|
|
206
214
|
if (entry) {
|
|
207
215
|
// Map components sequence to arguments:
|
|
208
|
-
const args = Object.keys(
|
|
216
|
+
const args = Object.keys(
|
|
217
|
+
getComponentsForFilter(schema, dataName)
|
|
218
|
+
).map(
|
|
209
219
|
key => entry[key] ?? null
|
|
210
220
|
)
|
|
211
221
|
// Only apply filter if there are some arguments that aren't null:
|
|
212
222
|
if (args.some(value => value !== null)) {
|
|
213
|
-
filters.push(
|
|
223
|
+
filters.push(
|
|
224
|
+
`${
|
|
225
|
+
getFilterName(dataName)
|
|
226
|
+
}:${
|
|
227
|
+
args.map(JSON.stringify).join(',')
|
|
228
|
+
}`
|
|
229
|
+
)
|
|
214
230
|
}
|
|
215
231
|
}
|
|
216
232
|
}
|
|
@@ -223,20 +239,20 @@ function parseFiltersData(schema, query) {
|
|
|
223
239
|
// from $route.query back to param lists per filter:
|
|
224
240
|
if (query) {
|
|
225
241
|
for (const filter of asArray(query.filter)) {
|
|
226
|
-
const [,
|
|
242
|
+
const [, filterName, json] = filter.match(/^(\w+):(.*)$/)
|
|
227
243
|
try {
|
|
228
|
-
filters[
|
|
244
|
+
filters[filterName] = asArray(JSON.parse(`[${json}]`))
|
|
229
245
|
} catch (error) {}
|
|
230
246
|
}
|
|
231
247
|
}
|
|
232
248
|
const filtersData = {}
|
|
233
|
-
for (const
|
|
249
|
+
for (const dataName in schema.components) {
|
|
234
250
|
const data = {}
|
|
235
251
|
// If we have retrieved params from the query, fetch the associated
|
|
236
252
|
// form components so we can map the values back to object keys:
|
|
237
|
-
const args = filters[
|
|
253
|
+
const args = filters[getFilterName(dataName)]
|
|
238
254
|
if (args) {
|
|
239
|
-
const components = getComponentsForFilter(schema,
|
|
255
|
+
const components = getComponentsForFilter(schema, dataName)
|
|
240
256
|
if (components) {
|
|
241
257
|
let index = 0
|
|
242
258
|
for (const key in components) {
|
|
@@ -244,7 +260,7 @@ function parseFiltersData(schema, query) {
|
|
|
244
260
|
}
|
|
245
261
|
}
|
|
246
262
|
}
|
|
247
|
-
filtersData[
|
|
263
|
+
filtersData[dataName] = data
|
|
248
264
|
}
|
|
249
265
|
return filtersData
|
|
250
266
|
}
|
package/src/utils/schema.js
CHANGED
|
@@ -847,10 +847,9 @@ export function processSchemaData(
|
|
|
847
847
|
: componentDataPath
|
|
848
848
|
const context = new DitoContext(options.component, {
|
|
849
849
|
schema: componentSchema,
|
|
850
|
-
data
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
index,
|
|
850
|
+
data,
|
|
851
|
+
dataPath: componentDataPath,
|
|
852
|
+
name,
|
|
854
853
|
rootData: options.rootData
|
|
855
854
|
})
|
|
856
855
|
const getForms = (
|