@ditojs/admin 2.66.0 → 2.68.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/admin",
3
- "version": "2.66.0",
3
+ "version": "2.68.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",
@@ -42,8 +42,8 @@
42
42
  "not ie_mob > 0"
43
43
  ],
44
44
  "dependencies": {
45
- "@ditojs/ui": "^2.66.0",
46
- "@ditojs/utils": "^2.66.0",
45
+ "@ditojs/ui": "^2.68.0",
46
+ "@ditojs/utils": "^2.68.0",
47
47
  "@kyvg/vue3-notification": "^3.4.2",
48
48
  "@lk77/vue3-color": "^3.0.6",
49
49
  "@tiptap/core": "^3.13.0",
@@ -89,9 +89,9 @@
89
89
  "vue-upload-component": "^3.1.17"
90
90
  },
91
91
  "devDependencies": {
92
- "@ditojs/build": "^2.66.0",
92
+ "@ditojs/build": "^2.68.0",
93
93
  "typescript": "^5.9.3",
94
94
  "vite": "^7.2.6"
95
95
  },
96
- "gitHead": "f4c1f6cf632c396e160a701d90fbcafe0cdf8478"
96
+ "gitHead": "8dbd4ce3ff84d83e8e4ebd8e90772ae51b25b8ce"
97
97
  }
@@ -18,6 +18,7 @@ export default {
18
18
  defaultValue: null,
19
19
  defaultNested: true,
20
20
  defaultVisible: true,
21
+ defaultMultiple: false,
21
22
  generateLabel: true,
22
23
  excludeValue: false,
23
24
  ignoreMissingValue: null,
@@ -1,6 +1,10 @@
1
1
  import DitoContext from '../DitoContext.js'
2
2
  import DataMixin from './DataMixin.js'
3
- import { hasViewSchema, getViewEditPath } from '../utils/schema.js'
3
+ import {
4
+ hasViewSchema,
5
+ getViewEditPath,
6
+ getMultipleValue
7
+ } from '../utils/schema.js'
4
8
  import { getSchemaAccessor } from '../utils/accessor.js'
5
9
  import { setTemporaryId, isReference } from '../utils/data.js'
6
10
  import {
@@ -18,6 +22,11 @@ export default {
18
22
  mixins: [DataMixin],
19
23
 
20
24
  computed: {
25
+ // @overridable
26
+ multiple() {
27
+ return getMultipleValue(this.schema)
28
+ },
29
+
21
30
  selectedValue: {
22
31
  get() {
23
32
  const convertValue = value => {
@@ -33,7 +42,7 @@ export default {
33
42
  }
34
43
 
35
44
  const value =
36
- this.relate && isArray(this.value)
45
+ this.multiple && isArray(this.value)
37
46
  ? this.value.map(convertValue).filter(value => value !== null)
38
47
  : convertValue(this.value)
39
48
 
@@ -61,7 +70,7 @@ export default {
61
70
  : value
62
71
 
63
72
  this.value =
64
- this.relate && isArray(value)
73
+ this.multiple && isArray(value)
65
74
  ? value.map(convertValue)
66
75
  : convertValue(value)
67
76
  }
@@ -275,9 +284,10 @@ export default {
275
284
  // TODO: Convert to using `relateBy`:
276
285
  const processRelate = value => (value ? { id: value.id } : value)
277
286
  // Selected options can be both objects & arrays, e.g. 'checkboxes':
278
- value = isArray(value)
279
- ? value.map(processRelate)
280
- : processRelate(value)
287
+ value =
288
+ getMultipleValue(schema) && isArray(value)
289
+ ? value.map(processRelate)
290
+ : processRelate(value)
281
291
  }
282
292
  return value
283
293
  }
@@ -29,8 +29,14 @@ export default DitoTypeComponent.register('checkboxes', {
29
29
  nativeField: true,
30
30
  defaultValue: [],
31
31
  defaultWidth: 'auto',
32
+ defaultMultiple: true,
32
33
 
33
34
  computed: {
35
+ // @override
36
+ multiple() {
37
+ return true
38
+ },
39
+
34
40
  selectedOptions: {
35
41
  get() {
36
42
  return (this.selectedValue || []).filter(value => value)
@@ -104,6 +104,7 @@ export default DitoTypeComponent.register('multiselect', {
104
104
  return this.searchedOptions || this.options
105
105
  },
106
106
 
107
+ // @override
107
108
  multiple: getSchemaAccessor('multiple', {
108
109
  type: Boolean,
109
110
  default: false
@@ -670,6 +670,10 @@ export function shouldIgnoreMissingValue(schema, context) {
670
670
  return !!getTypeOptions(schema)?.ignoreMissingValue?.(getContext(context))
671
671
  }
672
672
 
673
+ export function getMultipleValue(schema) {
674
+ return schema.multiple ?? !!getTypeOptions(schema)?.defaultMultiple
675
+ }
676
+
673
677
  export function setDefaultValues(schema, data = {}, component) {
674
678
  const options = { component, rootData: data }
675
679