@ditojs/admin 1.30.0 → 2.0.1
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 +5291 -6856
- package/dist/dito-admin.umd.js +5 -5
- package/dist/style.css +1 -1
- package/package.json +42 -27
- package/src/DitoAdmin.js +44 -58
- package/src/DitoComponent.js +18 -50
- package/src/DitoContext.js +7 -3
- package/src/TypeComponent.js +15 -13
- package/src/appState.js +4 -2
- package/src/components/DitoAccount.vue +14 -14
- package/src/components/DitoButtons.vue +18 -10
- package/src/components/DitoClipboard.vue +16 -16
- package/src/components/DitoContainer.vue +32 -32
- package/src/components/DitoCreateButton.vue +22 -23
- package/src/components/DitoDialog.vue +73 -18
- package/src/components/DitoEditButtons.vue +31 -31
- package/src/components/DitoElement.vue +6 -6
- package/src/components/DitoErrors.vue +6 -6
- package/src/components/DitoForm.vue +42 -43
- package/src/components/DitoFormNested.vue +7 -3
- package/src/components/DitoHeader.vue +19 -19
- package/src/components/DitoLabel.vue +25 -25
- package/src/components/DitoMenu.vue +9 -9
- package/src/components/DitoPagination.vue +5 -5
- package/src/components/DitoPane.vue +32 -32
- package/src/components/DitoPanel.vue +18 -18
- package/src/components/DitoPanels.vue +5 -3
- package/src/components/DitoRoot.vue +107 -30
- package/src/components/DitoSchema.vue +76 -74
- package/src/components/DitoSchemaInlined.vue +29 -29
- package/src/components/DitoScopes.vue +14 -13
- package/src/components/DitoSpinner.vue +101 -0
- package/src/components/DitoTableCell.vue +19 -25
- package/src/components/DitoTableHead.vue +10 -7
- package/src/components/DitoTabs.vue +7 -6
- package/src/components/DitoTreeItem.vue +89 -85
- package/src/components/DitoVNode.vue +9 -7
- package/src/components/DitoView.vue +25 -21
- package/src/mixins/DataMixin.js +2 -2
- package/src/mixins/DitoMixin.js +43 -46
- package/src/mixins/DomMixin.js +1 -1
- package/src/mixins/EmitterMixin.js +11 -11
- package/src/mixins/RouteMixin.js +20 -10
- package/src/mixins/SchemaParentMixin.js +2 -2
- package/src/mixins/SourceMixin.js +7 -9
- package/src/mixins/TypeMixin.js +29 -34
- package/src/mixins/ValidationMixin.js +4 -19
- package/src/types/TypeButton.vue +11 -15
- package/src/types/TypeCheckbox.vue +7 -8
- package/src/types/TypeCheckboxes.vue +14 -15
- package/src/types/TypeCode.vue +5 -5
- package/src/types/TypeColor.vue +9 -12
- package/src/types/TypeComponent.vue +12 -7
- package/src/types/TypeComputed.vue +13 -12
- package/src/types/TypeDate.vue +10 -11
- package/src/types/TypeLabel.vue +1 -1
- package/src/types/TypeList.vue +115 -92
- package/src/types/TypeMarkup.vue +166 -125
- package/src/types/TypeMultiselect.vue +37 -47
- package/src/types/TypeNumber.vue +10 -11
- package/src/types/TypeObject.vue +62 -46
- package/src/types/TypeProgress.vue +7 -8
- package/src/types/TypeRadio.vue +15 -14
- package/src/types/TypeSection.vue +10 -10
- package/src/types/TypeSelect.vue +32 -33
- package/src/types/TypeSlider.vue +20 -22
- package/src/types/TypeSwitch.vue +8 -9
- package/src/types/TypeText.vue +7 -8
- package/src/types/TypeTextarea.vue +8 -9
- package/src/types/TypeTreeList.vue +40 -34
- package/src/types/TypeUpload.vue +61 -61
- package/src/utils/accessor.js +1 -1
- package/src/utils/data.js +0 -4
- package/src/utils/options.js +48 -0
- package/src/utils/path.js +5 -0
- package/src/utils/schema.js +73 -56
- package/src/utils/vue.js +11 -0
- package/types/index.d.ts +1 -1
package/src/types/TypeColor.vue
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
:class="{ 'dito-focus': showPopup }"
|
|
9
|
-
)
|
|
2
|
+
trigger.dito-color(
|
|
3
|
+
trigger="click"
|
|
4
|
+
v-model:show="showPopup"
|
|
5
|
+
)
|
|
6
|
+
template(#trigger)
|
|
7
|
+
.dito-input(:class="{ 'dito-focus': showPopup }")
|
|
10
8
|
input(
|
|
11
9
|
ref="element"
|
|
12
10
|
:id="dataPath"
|
|
@@ -14,7 +12,6 @@
|
|
|
14
12
|
size="8"
|
|
15
13
|
v-model="hexValue"
|
|
16
14
|
v-bind="attributes"
|
|
17
|
-
v-on="listeners"
|
|
18
15
|
)
|
|
19
16
|
.dito-color-preview.dito-inherit-focus(
|
|
20
17
|
v-if="value"
|
|
@@ -25,8 +22,8 @@
|
|
|
25
22
|
@click.stop="clear"
|
|
26
23
|
:disabled="disabled"
|
|
27
24
|
)
|
|
25
|
+
template(#popup)
|
|
28
26
|
sketch-picker.dito-color-picker(
|
|
29
|
-
slot="popup"
|
|
30
27
|
v-model="colorValue"
|
|
31
28
|
:disable-alpha="!alpha"
|
|
32
29
|
:disable-fields="!inputs"
|
|
@@ -71,7 +68,7 @@
|
|
|
71
68
|
|
|
72
69
|
<script>
|
|
73
70
|
import tinycolor from 'tinycolor2'
|
|
74
|
-
import { Sketch as SketchPicker } from '
|
|
71
|
+
import { Sketch as SketchPicker } from '@lk77/vue3-color'
|
|
75
72
|
import TypeComponent from '../TypeComponent.js'
|
|
76
73
|
import { Trigger } from '@ditojs/ui/src'
|
|
77
74
|
import { getSchemaAccessor } from '../utils/accessor.js'
|
|
@@ -96,7 +93,7 @@ export default TypeComponent.register('color', {
|
|
|
96
93
|
set(value) {
|
|
97
94
|
const format = this.colorFormat
|
|
98
95
|
const key = {
|
|
99
|
-
// NOTE:
|
|
96
|
+
// NOTE: vue3-color calls it 'hex', while tinycolor calls it 'hex6'
|
|
100
97
|
hex: value?.a < 1 ? 'hex8' : 'hex',
|
|
101
98
|
rgb: 'rgba'
|
|
102
99
|
}[format] || format
|
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
component(
|
|
3
|
+
:is="schema.component"
|
|
4
|
+
v-bind="$props"
|
|
5
|
+
)
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
8
|
<script>
|
|
9
9
|
// This is the general purpose 'component' type, which can resolve to any custom
|
|
10
|
-
// component through `schema.component`, see `
|
|
11
|
-
// be used to nest arbitrary vue components in schema:
|
|
10
|
+
// component through `schema.component`, see `resolveSchemaComponent()`. This
|
|
11
|
+
// can be used to nest arbitrary vue components in schema:
|
|
12
12
|
// {
|
|
13
13
|
// type: 'component',
|
|
14
14
|
// component: import('./component')
|
|
15
15
|
// }
|
|
16
16
|
|
|
17
17
|
import TypeComponent from '../TypeComponent.js'
|
|
18
|
+
import { resolveSchemaComponent } from '../utils/schema.js'
|
|
18
19
|
|
|
19
20
|
// @vue/component
|
|
20
21
|
export default TypeComponent.register('component', {
|
|
21
22
|
// Override the standard `defaultValue: null` to not set any data for custom
|
|
22
23
|
// components, unless they provide a default value.
|
|
23
24
|
defaultValue: () => undefined, // Callback to override `defaultValue: null`
|
|
24
|
-
ignoreMissingValue: schema => !('default' in schema)
|
|
25
|
+
ignoreMissingValue: schema => !('default' in schema),
|
|
26
|
+
|
|
27
|
+
async processSchema(api, schema) {
|
|
28
|
+
await resolveSchemaComponent(schema)
|
|
29
|
+
}
|
|
25
30
|
})
|
|
26
31
|
</script>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
//- TODO: Find a better way to trigger evaluation of `value` that dose not
|
|
3
|
+
//- involve actually rendering it when the component is not visible.
|
|
4
|
+
input.dito-text.dito-input(
|
|
5
|
+
ref="element"
|
|
6
|
+
:id="dataPath"
|
|
7
|
+
:name="name"
|
|
8
|
+
type="text"
|
|
9
|
+
:value="value"
|
|
10
|
+
:disabled="disabled"
|
|
11
|
+
:readonly="true"
|
|
12
|
+
)
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
15
|
<script>
|
|
@@ -38,7 +38,8 @@ export default TypeComponent.register([
|
|
|
38
38
|
// resolved data twice.
|
|
39
39
|
resolveCounter: 2
|
|
40
40
|
})
|
|
41
|
-
|
|
41
|
+
// eslint-disable-next-line vue/no-mutating-props
|
|
42
|
+
this.data[this.name] = value
|
|
42
43
|
}
|
|
43
44
|
return TypeMixin.computed.value.get.call(this)
|
|
44
45
|
},
|
package/src/types/TypeDate.vue
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
)
|
|
2
|
+
.dito-date
|
|
3
|
+
component(
|
|
4
|
+
:is="getComponent(type)"
|
|
5
|
+
ref="element"
|
|
6
|
+
:id="dataPath"
|
|
7
|
+
:locale="locale"
|
|
8
|
+
:dateFormat="{ ...api.formats.date, ...dateFormat }"
|
|
9
|
+
v-model="dateValue"
|
|
10
|
+
v-bind="attributes"
|
|
11
|
+
)
|
|
13
12
|
</template>
|
|
14
13
|
|
|
15
14
|
<script>
|
package/src/types/TypeLabel.vue
CHANGED
package/src/types/TypeList.vue
CHANGED
|
@@ -1,71 +1,75 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
.dito-list(
|
|
3
|
+
v-if="isReady"
|
|
4
|
+
:id="dataPath"
|
|
5
|
+
:class="schema.class"
|
|
6
|
+
:style="schema.style"
|
|
7
|
+
)
|
|
8
|
+
.dito-navigation(
|
|
9
|
+
v-if="scopes || hasPagination"
|
|
7
10
|
)
|
|
8
|
-
|
|
9
|
-
v-if="scopes
|
|
11
|
+
dito-scopes(
|
|
12
|
+
v-if="scopes"
|
|
13
|
+
:query="query"
|
|
14
|
+
:scopes="scopes"
|
|
10
15
|
)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
// When there's only pagination without scopes, we need a good ol' spacer
|
|
17
|
-
// div, for the layout not to break...
|
|
18
|
-
.dito-spacer(
|
|
19
|
-
v-else-if="hasPagination"
|
|
20
|
-
)
|
|
21
|
-
dito-pagination(
|
|
22
|
-
v-if="hasPagination"
|
|
23
|
-
:query="query"
|
|
24
|
-
:limit="paginate"
|
|
25
|
-
:total="total || 0"
|
|
26
|
-
)
|
|
27
|
-
table.dito-table(
|
|
28
|
-
:class=`{
|
|
29
|
-
'dito-table-separators': isInlined,
|
|
30
|
-
'dito-table-larger-padding': hasEditButtons && !isInlined,
|
|
31
|
-
'dito-table-alternate-colors': !isInlined,
|
|
32
|
-
'dito-table-even-count': hasEvenCount
|
|
33
|
-
}`
|
|
16
|
+
//- When there's only pagination without scopes, we need a good ol' spacer
|
|
17
|
+
//- div, for the layout not to break...
|
|
18
|
+
.dito-spacer(
|
|
19
|
+
v-else-if="hasPagination"
|
|
34
20
|
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
21
|
+
dito-pagination(
|
|
22
|
+
v-if="hasPagination"
|
|
23
|
+
:query="query"
|
|
24
|
+
:limit="paginate"
|
|
25
|
+
:total="total || 0"
|
|
26
|
+
)
|
|
27
|
+
table.dito-table(
|
|
28
|
+
:class=`{
|
|
29
|
+
'dito-table-separators': isInlined,
|
|
30
|
+
'dito-table-larger-padding': hasEditButtons && !isInlined,
|
|
31
|
+
'dito-table-alternate-colors': !isInlined,
|
|
32
|
+
'dito-table-even-count': hasEvenCount
|
|
33
|
+
}`
|
|
34
|
+
)
|
|
35
|
+
dito-table-head(
|
|
36
|
+
v-if="columns"
|
|
37
|
+
:query="query"
|
|
38
|
+
:columns="columns"
|
|
39
|
+
:hasEditButtons="hasEditButtons"
|
|
40
|
+
)
|
|
41
|
+
vue-sortable(
|
|
42
|
+
tag="tbody"
|
|
43
|
+
:list="updateOrder(sourceSchema, listData, paginationRange)"
|
|
44
|
+
:options="getDragOptions(draggable)"
|
|
45
|
+
:itemKey="item => getItemUid(schema, item)"
|
|
46
|
+
@start="onStartDrag"
|
|
47
|
+
@end="onEndDrag"
|
|
48
|
+
)
|
|
49
|
+
template(#item="{ element: item, index }")
|
|
48
50
|
tr(
|
|
49
|
-
v-for="item, index in listData"
|
|
50
|
-
:key="getItemUid(schema, item)"
|
|
51
51
|
:id="getDataPath(index)"
|
|
52
52
|
)
|
|
53
53
|
template(v-if="columns")
|
|
54
|
-
|
|
54
|
+
template(
|
|
55
55
|
v-for="column in columns"
|
|
56
|
-
v-if="shouldRender(column)"
|
|
57
|
-
:key="column.name"
|
|
58
|
-
:class="getCellClass(column)"
|
|
59
|
-
:cell="column"
|
|
60
|
-
:schema="schema"
|
|
61
|
-
:dataPath="getDataPath(index)"
|
|
62
|
-
:data="item"
|
|
63
|
-
:meta="nestedMeta"
|
|
64
|
-
:store="store"
|
|
65
|
-
:nested="false"
|
|
66
|
-
:disabled="disabled || isLoading"
|
|
67
56
|
)
|
|
68
|
-
|
|
57
|
+
dito-table-cell(
|
|
58
|
+
v-if="shouldRender(column)"
|
|
59
|
+
:key="column.name"
|
|
60
|
+
:class="getCellClass(column)"
|
|
61
|
+
:cell="column"
|
|
62
|
+
:schema="schema"
|
|
63
|
+
:dataPath="getDataPath(index)"
|
|
64
|
+
:data="item"
|
|
65
|
+
:meta="nestedMeta"
|
|
66
|
+
:store="store"
|
|
67
|
+
:nested="false"
|
|
68
|
+
:disabled="disabled || isLoading"
|
|
69
|
+
)
|
|
70
|
+
template(
|
|
71
|
+
v-else
|
|
72
|
+
)
|
|
69
73
|
td
|
|
70
74
|
dito-schema-inlined(
|
|
71
75
|
v-if="isInlined"
|
|
@@ -85,8 +89,8 @@
|
|
|
85
89
|
@delete="deleteItem(item, index)"
|
|
86
90
|
)
|
|
87
91
|
component(
|
|
88
|
-
v-else-if="component"
|
|
89
|
-
:is="component"
|
|
92
|
+
v-else-if="schema.component"
|
|
93
|
+
:is="schema.component"
|
|
90
94
|
:dataPath="getDataPath(index)"
|
|
91
95
|
:data="item"
|
|
92
96
|
:nested="false"
|
|
@@ -114,36 +118,36 @@
|
|
|
114
118
|
:store="getChildStore(index)"
|
|
115
119
|
@delete="deleteItem(item, index)"
|
|
116
120
|
)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
)
|
|
121
|
-
tr
|
|
122
|
-
td.dito-cell-edit-buttons(
|
|
123
|
-
:colspan="numColumns"
|
|
124
|
-
)
|
|
125
|
-
dito-edit-buttons(
|
|
126
|
-
:creatable="creatable"
|
|
127
|
-
:createPath="path"
|
|
128
|
-
:buttons="buttonSchemas"
|
|
129
|
-
:schema="schema"
|
|
130
|
-
:dataPath="dataPath"
|
|
131
|
-
:data="listData"
|
|
132
|
-
:meta="meta"
|
|
133
|
-
:store="store"
|
|
134
|
-
)
|
|
135
|
-
// Render create buttons outside table when in a single component view:
|
|
136
|
-
dito-edit-buttons.dito-buttons-main.dito-buttons-large(
|
|
137
|
-
v-if="hasListButtons && single"
|
|
138
|
-
:creatable="creatable"
|
|
139
|
-
:createPath="path"
|
|
140
|
-
:buttons="buttonSchemas"
|
|
141
|
-
:schema="schema"
|
|
142
|
-
:dataPath="dataPath"
|
|
143
|
-
:data="listData"
|
|
144
|
-
:meta="meta"
|
|
145
|
-
:store="store"
|
|
121
|
+
//- Render create buttons inside table when not in a single component view:
|
|
122
|
+
tfoot(
|
|
123
|
+
v-if="hasListButtons && !single"
|
|
146
124
|
)
|
|
125
|
+
tr
|
|
126
|
+
td.dito-cell-edit-buttons(
|
|
127
|
+
:colspan="numColumns"
|
|
128
|
+
)
|
|
129
|
+
dito-edit-buttons(
|
|
130
|
+
:creatable="creatable"
|
|
131
|
+
:createPath="path"
|
|
132
|
+
:buttons="buttonSchemas"
|
|
133
|
+
:schema="schema"
|
|
134
|
+
:dataPath="dataPath"
|
|
135
|
+
:data="listData"
|
|
136
|
+
:meta="meta"
|
|
137
|
+
:store="store"
|
|
138
|
+
)
|
|
139
|
+
//- Render create buttons outside table when in a single component view:
|
|
140
|
+
dito-edit-buttons.dito-buttons-main.dito-buttons-large(
|
|
141
|
+
v-if="hasListButtons && single"
|
|
142
|
+
:creatable="creatable"
|
|
143
|
+
:createPath="path"
|
|
144
|
+
:buttons="buttonSchemas"
|
|
145
|
+
:schema="schema"
|
|
146
|
+
:dataPath="dataPath"
|
|
147
|
+
:data="listData"
|
|
148
|
+
:meta="meta"
|
|
149
|
+
:store="store"
|
|
150
|
+
)
|
|
147
151
|
</template>
|
|
148
152
|
|
|
149
153
|
<style lang="sass">
|
|
@@ -175,15 +179,18 @@ import TypeComponent from '../TypeComponent.js'
|
|
|
175
179
|
import DitoContext from '../DitoContext.js'
|
|
176
180
|
import SourceMixin from '../mixins/SourceMixin.js'
|
|
177
181
|
import OrderedMixin from '../mixins/OrderedMixin.js'
|
|
178
|
-
import
|
|
179
|
-
import {
|
|
182
|
+
import { Sortable as VueSortable } from 'sortablejs-vue3'
|
|
183
|
+
import {
|
|
184
|
+
getNamedSchemas, getViewEditPath,
|
|
185
|
+
resolveSchemaComponent, resolveSchemaComponents
|
|
186
|
+
} from '../utils/schema.js'
|
|
180
187
|
import { getFiltersPanel } from '../utils/filter.js'
|
|
181
188
|
import { appendDataPath } from '../utils/data.js'
|
|
182
189
|
import { pickBy, equals, hyphenate } from '@ditojs/utils'
|
|
183
190
|
|
|
184
191
|
// @vue/component
|
|
185
192
|
export default TypeComponent.register('list', {
|
|
186
|
-
components: {
|
|
193
|
+
components: { VueSortable },
|
|
187
194
|
mixins: [SourceMixin, OrderedMixin],
|
|
188
195
|
|
|
189
196
|
getSourceType(type) {
|
|
@@ -299,6 +306,22 @@ export default TypeComponent.register('list', {
|
|
|
299
306
|
return true
|
|
300
307
|
}
|
|
301
308
|
}
|
|
309
|
+
},
|
|
310
|
+
|
|
311
|
+
async processSchema(
|
|
312
|
+
api, schema, name, routes, level,
|
|
313
|
+
nested = false, flatten = false,
|
|
314
|
+
process = null
|
|
315
|
+
) {
|
|
316
|
+
await Promise.all([
|
|
317
|
+
resolveSchemaComponent(schema),
|
|
318
|
+
resolveSchemaComponents(schema.columns),
|
|
319
|
+
SourceMixin.processSchema(
|
|
320
|
+
api, schema, name, routes, level,
|
|
321
|
+
nested, flatten,
|
|
322
|
+
process
|
|
323
|
+
)
|
|
324
|
+
])
|
|
302
325
|
}
|
|
303
326
|
})
|
|
304
327
|
</script>
|