@ditojs/admin 2.97.0 → 2.99.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 +1355 -1349
- package/dist/dito-admin.umd.js +3 -3
- package/package.json +5 -5
- package/src/components/DitoForm.vue +8 -0
- package/src/mixins/ItemMixin.js +5 -2
- package/src/mixins/ResourceMixin.js +14 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/admin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.99.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/main/packages/admin",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"not ie_mob > 0"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@ditojs/ui": "^2.
|
|
44
|
-
"@ditojs/utils": "^2.
|
|
43
|
+
"@ditojs/ui": "^2.99.0",
|
|
44
|
+
"@ditojs/utils": "^2.99.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@kyvg/vue3-notification": "^3.4.2",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"vue-upload-component": "^3.1.17"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@ditojs/build": "^2.
|
|
92
|
+
"@ditojs/build": "^2.99.0",
|
|
93
93
|
"typescript": "^6.0.3",
|
|
94
94
|
"vite": "^8.0.10"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "ba1ce26d349a74e8143faa614488182b67416db1"
|
|
97
97
|
}
|
|
@@ -359,6 +359,14 @@ export default DitoComponent.component('DitoForm', {
|
|
|
359
359
|
this.setData(null)
|
|
360
360
|
},
|
|
361
361
|
|
|
362
|
+
// @override ResourceMixin.shouldApplyLoadedData()
|
|
363
|
+
shouldApplyLoadedData() {
|
|
364
|
+
// Drop a GET response if the user has made local edits while the
|
|
365
|
+
// request was in flight — applying it would wholesale-replace
|
|
366
|
+
// `loadedData` and silently clobber those edits.
|
|
367
|
+
return !this.isDirty
|
|
368
|
+
},
|
|
369
|
+
|
|
362
370
|
// @override ResourceMixin.setData()
|
|
363
371
|
setData(data) {
|
|
364
372
|
// setData() is called after submit when data has changed.
|
package/src/mixins/ItemMixin.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
isListSource
|
|
7
7
|
} from '../utils/schema.js'
|
|
8
8
|
import { appendDataPath } from '../utils/data.js'
|
|
9
|
-
import { isObject, isString, isFunction } from '@ditojs/utils'
|
|
9
|
+
import { isObject, isString, isNumber, isFunction } from '@ditojs/utils'
|
|
10
10
|
|
|
11
11
|
// @vue/component
|
|
12
12
|
export default {
|
|
@@ -114,7 +114,10 @@ export default {
|
|
|
114
114
|
isListSource(sourceSchema) && columns && Object.keys(columns)[0] ||
|
|
115
115
|
'name'
|
|
116
116
|
)
|
|
117
|
-
|
|
117
|
+
const value = item[key]
|
|
118
|
+
// Only primitives display as a label. If the property holds an array
|
|
119
|
+
// or object, fall through to the auto-generated label.
|
|
120
|
+
text = isString(value) || isNumber(value) ? value : null
|
|
118
121
|
}
|
|
119
122
|
const hadLabel = !!text
|
|
120
123
|
// If no label was found so far, try to produce one from the index.
|
|
@@ -160,6 +160,13 @@ export default {
|
|
|
160
160
|
this.loadedData = null
|
|
161
161
|
},
|
|
162
162
|
|
|
163
|
+
// @overridable
|
|
164
|
+
// Subclasses override this to skip applying response data when local
|
|
165
|
+
// state would be overwritten — see DitoForm, which checks `isDirty`.
|
|
166
|
+
shouldApplyLoadedData() {
|
|
167
|
+
return true
|
|
168
|
+
},
|
|
169
|
+
|
|
163
170
|
// @overridable
|
|
164
171
|
setData(data) {
|
|
165
172
|
this.loadedData = data
|
|
@@ -217,7 +224,13 @@ export default {
|
|
|
217
224
|
}
|
|
218
225
|
}
|
|
219
226
|
} else {
|
|
220
|
-
|
|
227
|
+
// Skip applying response data when the consumer (e.g. a dirty
|
|
228
|
+
// DitoForm) reports it would overwrite local edits made while the
|
|
229
|
+
// GET was in flight. The 'load' event still fires — the GET *did*
|
|
230
|
+
// complete; we just chose not to apply it.
|
|
231
|
+
if (this.shouldApplyLoadedData()) {
|
|
232
|
+
this.setData(response.data)
|
|
233
|
+
}
|
|
221
234
|
this.emitSchemaEvent('load')
|
|
222
235
|
}
|
|
223
236
|
})
|