@ditojs/admin 2.95.0 → 2.97.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.css +1 -1
- package/dist/dito-admin.es.js +54 -19
- package/dist/dito-admin.umd.js +5 -5
- package/package.json +7 -7
- package/src/DitoContext.js +1 -1
- package/src/components/DitoCreateButton.vue +11 -3
- package/src/components/DitoEditButtons.vue +4 -2
- package/src/components/DitoLabel.vue +2 -0
- package/src/components/DitoSchema.vue +2 -0
- package/src/components/DitoSchemaInlined.vue +9 -5
- package/src/mixins/ItemMixin.js +1 -3
- package/src/mixins/SourceMixin.js +19 -6
- package/src/styles/_button.scss +6 -3
- package/src/types/DitoTypeList.vue +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/admin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.97.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.97.0",
|
|
44
|
+
"@ditojs/utils": "^2.97.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.
|
|
93
|
-
"typescript": "^6.0.
|
|
94
|
-
"vite": "^8.0.
|
|
92
|
+
"@ditojs/build": "^2.97.0",
|
|
93
|
+
"typescript": "^6.0.3",
|
|
94
|
+
"vite": "^8.0.10"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "a15b3aa1474b88b4dbefd114491605b5715a6526"
|
|
97
97
|
}
|
package/src/DitoContext.js
CHANGED
|
@@ -24,7 +24,7 @@ const contexts = new WeakMap()
|
|
|
24
24
|
function toObject(context) {
|
|
25
25
|
const rawStart = toRaw(context)
|
|
26
26
|
let raw = rawStart
|
|
27
|
-
let object
|
|
27
|
+
let object
|
|
28
28
|
// In case `DitoContext.extend()` was used, we need to find the actual context
|
|
29
29
|
// object from the object's the inheritance chain:
|
|
30
30
|
do {
|
|
@@ -63,12 +63,20 @@ export default DitoComponent.component('DitoCreateButton', {
|
|
|
63
63
|
path: { type: String, required: true },
|
|
64
64
|
verb: { type: String, required: true },
|
|
65
65
|
text: { type: String, default: null },
|
|
66
|
-
disabled: { type: Boolean, required: true }
|
|
66
|
+
disabled: { type: Boolean, required: true },
|
|
67
|
+
insertIndex: { type: Number, default: null }
|
|
67
68
|
},
|
|
68
69
|
|
|
69
70
|
computed: {
|
|
70
71
|
forms() {
|
|
71
|
-
|
|
72
|
+
// When inserting per-item, `this.schema` is the item's form, not the
|
|
73
|
+
// list schema. Fall back to `sourceSchema` (the parent list's schema via
|
|
74
|
+
// `meta.schema`) so all creatable forms are discoverable in the pulldown.
|
|
75
|
+
const schema =
|
|
76
|
+
this.insertIndex != null
|
|
77
|
+
? this.sourceSchema || this.schema
|
|
78
|
+
: this.schema
|
|
79
|
+
return getFormSchemas(schema, this.context)
|
|
72
80
|
},
|
|
73
81
|
|
|
74
82
|
creatableForms() {
|
|
@@ -107,7 +115,7 @@ export default DitoComponent.component('DitoCreateButton', {
|
|
|
107
115
|
createItem(form, type = null) {
|
|
108
116
|
if (!this.shouldDisableSchema(form)) {
|
|
109
117
|
if (this.isInlined) {
|
|
110
|
-
this.sourceComponent.createItem(form, type)
|
|
118
|
+
this.sourceComponent.createItem(form, type, this.insertIndex)
|
|
111
119
|
} else {
|
|
112
120
|
const { creatable } = this.schema
|
|
113
121
|
const query = {
|
|
@@ -31,8 +31,9 @@ DitoButtons.dito-edit-buttons.dito-buttons--round(
|
|
|
31
31
|
:nested="nested"
|
|
32
32
|
:path="createPath"
|
|
33
33
|
:verb="verbs.create"
|
|
34
|
-
:text="createButtonText"
|
|
34
|
+
:text="insertIndex != null ? null : createButtonText"
|
|
35
35
|
:disabled="isCreatableDisabled"
|
|
36
|
+
:insertIndex="insertIndex"
|
|
36
37
|
)
|
|
37
38
|
button.dito-button(
|
|
38
39
|
v-if="deletable"
|
|
@@ -67,7 +68,8 @@ export default DitoComponent.component('DitoEditButtons', {
|
|
|
67
68
|
creatable: { type: Boolean, default: false },
|
|
68
69
|
deletable: { type: Boolean, default: false },
|
|
69
70
|
editPath: { type: String, default: null },
|
|
70
|
-
createPath: { type: String, default: null }
|
|
71
|
+
createPath: { type: String, default: null },
|
|
72
|
+
insertIndex: { type: Number, default: null }
|
|
71
73
|
},
|
|
72
74
|
|
|
73
75
|
computed: {
|
|
@@ -102,6 +102,8 @@ export default DitoComponent.component('DitoLabel', {
|
|
|
102
102
|
position: relative;
|
|
103
103
|
// Vertically center all items in the label, e.g. chevron, edit-buttons.
|
|
104
104
|
align-items: center;
|
|
105
|
+
// Let nested labels with ellipsis shrink below their content width.
|
|
106
|
+
min-width: 0;
|
|
105
107
|
min-height: $input-height;
|
|
106
108
|
margin-right: $form-spacing-half; // When inlined.
|
|
107
109
|
|
|
@@ -825,6 +825,8 @@ export default DitoComponent.component('DitoSchema', {
|
|
|
825
825
|
.dito-schema-header {
|
|
826
826
|
display: flex;
|
|
827
827
|
justify-content: space-between;
|
|
828
|
+
// Let nested labels with ellipsis shrink below their content width.
|
|
829
|
+
min-width: 0;
|
|
828
830
|
|
|
829
831
|
.dito-header & {
|
|
830
832
|
// When teleported into main header.
|
|
@@ -21,7 +21,7 @@ DitoSchema.dito-schema-inlined(
|
|
|
21
21
|
//- others in `TypeList` as a scope, for better handling of layout.
|
|
22
22
|
template(#edit-buttons)
|
|
23
23
|
DitoEditButtons(
|
|
24
|
-
v-if="deletable || draggable || editable"
|
|
24
|
+
v-if="deletable || draggable || editable || insertIndex != null"
|
|
25
25
|
:schema="schema"
|
|
26
26
|
:dataPath="dataPath"
|
|
27
27
|
:data="data"
|
|
@@ -32,6 +32,9 @@ DitoSchema.dito-schema-inlined(
|
|
|
32
32
|
:draggable="draggable"
|
|
33
33
|
:editable="editable"
|
|
34
34
|
:editPath="editPath"
|
|
35
|
+
:creatable="insertIndex != null"
|
|
36
|
+
:createPath="createPath"
|
|
37
|
+
:insertIndex="insertIndex"
|
|
35
38
|
@delete="$emit('delete')"
|
|
36
39
|
)
|
|
37
40
|
</template>
|
|
@@ -59,6 +62,8 @@ export default DitoComponent.component('DitoSchemaInlined', {
|
|
|
59
62
|
editable: { type: Boolean, default: false },
|
|
60
63
|
deletable: { type: Boolean, default: false },
|
|
61
64
|
editPath: { type: String, default: null },
|
|
65
|
+
createPath: { type: String, default: null },
|
|
66
|
+
insertIndex: { type: Number, default: null },
|
|
62
67
|
labelNode: { type: HTMLElement, default: null },
|
|
63
68
|
accumulatedBasis: { type: Number, default: null }
|
|
64
69
|
},
|
|
@@ -87,10 +92,9 @@ export default DitoComponent.component('DitoSchemaInlined', {
|
|
|
87
92
|
grid-template-columns: 100%;
|
|
88
93
|
|
|
89
94
|
&:not(:hover, .dito-schema--open) {
|
|
90
|
-
> .dito-schema-header
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
95
|
+
> .dito-schema-header
|
|
96
|
+
.dito-button:not(.dito-button--edit, .dito-button--remove) {
|
|
97
|
+
display: none;
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
}
|
package/src/mixins/ItemMixin.js
CHANGED
|
@@ -122,9 +122,7 @@ export default {
|
|
|
122
122
|
// Always use extended style when auto-generating labels from index/id:
|
|
123
123
|
extended = true
|
|
124
124
|
text =
|
|
125
|
-
isListSource(sourceSchema) && index !== null
|
|
126
|
-
? (text = `${index + 1}`)
|
|
127
|
-
: ''
|
|
125
|
+
isListSource(sourceSchema) && index !== null ? `${index + 1}` : ''
|
|
128
126
|
}
|
|
129
127
|
if (extended) {
|
|
130
128
|
const formLabel = getFormLabel()
|
|
@@ -318,7 +318,7 @@ export default {
|
|
|
318
318
|
type: Boolean,
|
|
319
319
|
default: false,
|
|
320
320
|
get(draggable) {
|
|
321
|
-
return this.isListSource &&
|
|
321
|
+
return this.isListSource && draggable
|
|
322
322
|
}
|
|
323
323
|
}),
|
|
324
324
|
|
|
@@ -450,15 +450,17 @@ export default {
|
|
|
450
450
|
}
|
|
451
451
|
},
|
|
452
452
|
|
|
453
|
-
createItem(schema, type) {
|
|
453
|
+
createItem(schema, type, index = null) {
|
|
454
454
|
const item = this.createData(schema, type)
|
|
455
455
|
if (this.isObjectSource) {
|
|
456
456
|
this.objectData = item
|
|
457
|
+
} else if (index != null) {
|
|
458
|
+
this.listData.splice(index, 0, item)
|
|
457
459
|
} else {
|
|
458
460
|
this.listData.push(item)
|
|
459
461
|
}
|
|
460
462
|
if (this.collapsible) {
|
|
461
|
-
this.$nextTick(() => this.openSchemaComponent(-1))
|
|
463
|
+
this.$nextTick(() => this.openSchemaComponent(index ?? -1))
|
|
462
464
|
}
|
|
463
465
|
this.onChange()
|
|
464
466
|
return item
|
|
@@ -531,9 +533,20 @@ export default {
|
|
|
531
533
|
},
|
|
532
534
|
|
|
533
535
|
getSchemaComponent(index) {
|
|
534
|
-
const { schemaComponents } = this
|
|
535
|
-
const
|
|
536
|
-
|
|
536
|
+
const { listData, schemaComponents } = this
|
|
537
|
+
const candidate = schemaComponents.at(index)
|
|
538
|
+
if (listData?.length) {
|
|
539
|
+
// Fast path: registration order usually matches `listData`. Fall back
|
|
540
|
+
// to a search by reference when it doesn't (non-tail inserts, drag
|
|
541
|
+
// reorders), since `schemaComponents` is filled by mount-order pushes.
|
|
542
|
+
const item = listData.at(index)
|
|
543
|
+
return item == null
|
|
544
|
+
? null
|
|
545
|
+
: candidate?.data === item
|
|
546
|
+
? candidate
|
|
547
|
+
: schemaComponents.find(c => c.data === item)
|
|
548
|
+
}
|
|
549
|
+
return candidate
|
|
537
550
|
},
|
|
538
551
|
|
|
539
552
|
openSchemaComponent(index) {
|
package/src/styles/_button.scss
CHANGED
|
@@ -155,9 +155,12 @@
|
|
|
155
155
|
|
|
156
156
|
&--round,
|
|
157
157
|
&--small {
|
|
158
|
-
// For now, nothing for
|
|
159
|
-
// .dito-button--create:empty::before
|
|
160
|
-
|
|
158
|
+
// For now, nothing for create:
|
|
159
|
+
// .dito-button--create:empty::before
|
|
160
|
+
|
|
161
|
+
.dito-button--add:empty::before {
|
|
162
|
+
@extend %icon-add;
|
|
163
|
+
}
|
|
161
164
|
|
|
162
165
|
.dito-button--upload:empty::before {
|
|
163
166
|
@extend %icon-upload;
|
|
@@ -85,9 +85,11 @@
|
|
|
85
85
|
:collapsed="collapsed"
|
|
86
86
|
:collapsible="collapsible"
|
|
87
87
|
:deletable="deletable"
|
|
88
|
-
:draggable="draggable"
|
|
88
|
+
:draggable="draggable && listData.length > 1"
|
|
89
89
|
:editable="editable"
|
|
90
90
|
:editPath="getEditPath(item, index)"
|
|
91
|
+
:createPath="createPath"
|
|
92
|
+
:insertIndex="creatable && draggable ? index : null"
|
|
91
93
|
@delete="deleteItem(item, index)"
|
|
92
94
|
)
|
|
93
95
|
component(
|