@ditojs/admin 2.0.4 → 2.1.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 +2065 -1969
- package/dist/dito-admin.umd.js +4 -4
- package/dist/style.css +1 -1
- package/package.json +32 -31
- package/src/DitoAdmin.js +66 -31
- package/src/DitoComponent.js +4 -1
- package/src/DitoContext.js +13 -5
- package/src/{TypeComponent.js → DitoTypeComponent.js} +8 -5
- package/src/components/DitoAccount.vue +20 -19
- package/src/components/DitoButtons.vue +14 -12
- package/src/components/DitoClipboard.vue +16 -8
- package/src/components/DitoContainer.vue +56 -43
- package/src/components/DitoCreateButton.vue +20 -15
- package/src/components/DitoDialog.vue +78 -53
- package/src/components/DitoEditButtons.vue +16 -14
- package/src/components/DitoElement.vue +2 -3
- package/src/components/DitoErrors.vue +18 -13
- package/src/components/DitoForm.vue +41 -24
- package/src/components/DitoFormNested.vue +12 -10
- package/src/components/DitoHeader.vue +103 -69
- package/src/components/DitoLabel.vue +108 -81
- package/src/components/DitoMenu.vue +52 -36
- package/src/components/DitoPagination.vue +9 -7
- package/src/components/DitoPane.vue +53 -45
- package/src/components/DitoPanel.vue +62 -42
- package/src/components/DitoPanels.vue +11 -10
- package/src/components/DitoRoot.vue +57 -46
- package/src/components/DitoSchema.vue +179 -131
- package/src/components/DitoSchemaInlined.vue +39 -28
- package/src/components/DitoScopes.vue +41 -31
- package/src/components/DitoSpinner.vue +31 -40
- package/src/components/DitoTableCell.vue +9 -9
- package/src/components/DitoTableHead.vue +52 -37
- package/src/components/DitoTabs.vue +39 -29
- package/src/components/DitoTreeItem.vue +140 -86
- package/src/components/DitoVNode.vue +1 -1
- package/src/components/DitoView.vue +13 -11
- package/src/mixins/DataMixin.js +11 -9
- package/src/mixins/DitoMixin.js +47 -25
- package/src/mixins/EmitterMixin.js +2 -1
- package/src/mixins/ItemMixin.js +15 -10
- package/src/mixins/LoadingMixin.js +2 -1
- package/src/mixins/NumberMixin.js +15 -10
- package/src/mixins/OptionsMixin.js +24 -12
- package/src/mixins/ResourceMixin.js +42 -34
- package/src/mixins/RouteMixin.js +8 -8
- package/src/mixins/SortableMixin.js +1 -1
- package/src/mixins/SourceMixin.js +68 -34
- package/src/mixins/TypeMixin.js +5 -4
- package/src/mixins/ValidationMixin.js +3 -0
- package/src/styles/_base.scss +17 -0
- package/src/styles/_button.scss +212 -0
- package/src/styles/_imports.scss +2 -0
- package/src/styles/_layout.scss +22 -0
- package/src/styles/_notifications.scss +54 -0
- package/src/styles/_pulldown.scss +39 -0
- package/src/styles/_scroll.scss +15 -0
- package/src/styles/_settings.scss +68 -0
- package/src/styles/_sortable.scss +13 -0
- package/src/styles/_table.scss +224 -0
- package/src/styles/style.scss +9 -0
- package/src/types/DitoTypeButton.vue +72 -0
- package/src/types/{TypeCheckbox.vue → DitoTypeCheckbox.vue} +12 -11
- package/src/types/{TypeCheckboxes.vue → DitoTypeCheckboxes.vue} +21 -15
- package/src/types/{TypeCode.vue → DitoTypeCode.vue} +46 -34
- package/src/types/{TypeColor.vue → DitoTypeColor.vue} +71 -52
- package/src/types/{TypeComponent.vue → DitoTypeComponent.vue} +2 -2
- package/src/types/DitoTypeComputed.vue +54 -0
- package/src/types/DitoTypeDate.vue +64 -0
- package/src/types/DitoTypeLabel.vue +23 -0
- package/src/types/{TypeList.vue → DitoTypeList.vue} +83 -61
- package/src/types/{TypeMarkup.vue → DitoTypeMarkup.vue} +172 -122
- package/src/types/DitoTypeMultiselect.vue +434 -0
- package/src/types/DitoTypeNumber.vue +46 -0
- package/src/types/{TypeObject.vue → DitoTypeObject.vue} +41 -26
- package/src/types/{TypePanel.vue → DitoTypePanel.vue} +2 -2
- package/src/types/{TypeProgress.vue → DitoTypeProgress.vue} +4 -6
- package/src/types/{TypeRadio.vue → DitoTypeRadio.vue} +17 -13
- package/src/types/{TypeSection.vue → DitoTypeSection.vue} +17 -17
- package/src/types/{TypeSelect.vue → DitoTypeSelect.vue} +39 -35
- package/src/types/{TypeSlider.vue → DitoTypeSlider.vue} +29 -23
- package/src/types/{TypeSwitch.vue → DitoTypeSwitch.vue} +15 -13
- package/src/types/DitoTypeText.vue +77 -0
- package/src/types/{TypeTextarea.vue → DitoTypeTextarea.vue} +17 -14
- package/src/types/DitoTypeTreeList.vue +191 -0
- package/src/types/{TypeUpload.vue → DitoTypeUpload.vue} +92 -65
- package/src/types/index.js +26 -26
- package/src/utils/SchemaGraph.js +21 -13
- package/src/utils/accessor.js +17 -9
- package/src/utils/data.js +4 -1
- package/src/utils/filter.js +8 -10
- package/src/utils/options.js +3 -3
- package/src/utils/resource.js +12 -10
- package/src/utils/schema.js +190 -125
- package/src/utils/type.js +31 -20
- package/src/validations/_decimals.js +1 -2
- package/types/index.d.ts +27 -23
- package/src/styles/_base.sass +0 -15
- package/src/styles/_button.sass +0 -127
- package/src/styles/_imports.sass +0 -2
- package/src/styles/_layout.sass +0 -13
- package/src/styles/_notifications.sass +0 -33
- package/src/styles/_pulldown.sass +0 -26
- package/src/styles/_scroll.sass +0 -13
- package/src/styles/_settings.sass +0 -55
- package/src/styles/_sortable.sass +0 -9
- package/src/styles/_table.sass +0 -153
- package/src/styles/style.sass +0 -10
- package/src/types/TypeButton.vue +0 -73
- package/src/types/TypeComputed.vue +0 -53
- package/src/types/TypeDate.vue +0 -64
- package/src/types/TypeLabel.vue +0 -19
- package/src/types/TypeMultiselect.vue +0 -376
- package/src/types/TypeNumber.vue +0 -44
- package/src/types/TypeText.vue +0 -67
- package/src/types/TypeTreeList.vue +0 -164
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
.dito-section(
|
|
3
|
-
|
|
4
|
-
)
|
|
5
|
-
dito-pane.dito-section-pane(
|
|
2
|
+
.dito-section(:class="{ 'dito-section-labelled': !!schema.label }")
|
|
3
|
+
DitoPane.dito-section-pane(
|
|
6
4
|
:schema="getItemFormSchema(schema, item, context)"
|
|
7
5
|
:dataPath="dataPath"
|
|
8
6
|
:data="item"
|
|
@@ -12,23 +10,12 @@
|
|
|
12
10
|
)
|
|
13
11
|
</template>
|
|
14
12
|
|
|
15
|
-
<style lang="sass">
|
|
16
|
-
@import '../styles/_imports'
|
|
17
|
-
|
|
18
|
-
.dito-section
|
|
19
|
-
&.dito-section-labelled
|
|
20
|
-
border: $border-style
|
|
21
|
-
border-radius: $border-radius
|
|
22
|
-
padding: $form-spacing
|
|
23
|
-
box-sizing: border-box
|
|
24
|
-
</style>
|
|
25
|
-
|
|
26
13
|
<script>
|
|
27
|
-
import
|
|
14
|
+
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
28
15
|
import { getItemFormSchema, processSchemaComponents } from '../utils/schema.js'
|
|
29
16
|
|
|
30
17
|
// @vue/component
|
|
31
|
-
export default
|
|
18
|
+
export default DitoTypeComponent.register('section', {
|
|
32
19
|
defaultValue: () => undefined, // Callback to override `defaultValue: null`
|
|
33
20
|
ignoreMissingValue: schema => !schema.nested && !('default' in schema),
|
|
34
21
|
defaultNested: false,
|
|
@@ -51,3 +38,16 @@ export default TypeComponent.register('section', {
|
|
|
51
38
|
}
|
|
52
39
|
})
|
|
53
40
|
</script>
|
|
41
|
+
|
|
42
|
+
<style lang="scss">
|
|
43
|
+
@import '../styles/_imports';
|
|
44
|
+
|
|
45
|
+
.dito-section {
|
|
46
|
+
&.dito-section-labelled {
|
|
47
|
+
border: $border-style;
|
|
48
|
+
border-radius: $border-radius;
|
|
49
|
+
padding: $form-spacing;
|
|
50
|
+
box-sizing: border-box;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</style>
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
//- Nesting is needed to make an arrow appear over the select item:
|
|
3
3
|
.dito-select
|
|
4
4
|
select(
|
|
5
|
-
ref="element"
|
|
6
5
|
:id="dataPath"
|
|
6
|
+
ref="element"
|
|
7
7
|
v-model="selectedValue"
|
|
8
8
|
v-bind="attributes"
|
|
9
9
|
@mousedown="populate = true"
|
|
@@ -30,50 +30,20 @@
|
|
|
30
30
|
template(
|
|
31
31
|
v-else-if="selectedOption"
|
|
32
32
|
)
|
|
33
|
-
option(
|
|
34
|
-
:value="selectedValue"
|
|
35
|
-
) {{ getLabelForOption(selectedOption) }}
|
|
33
|
+
option(:value="selectedValue") {{ getLabelForOption(selectedOption) }}
|
|
36
34
|
button.dito-button-clear.dito-button-overlay(
|
|
37
35
|
v-if="showClearButton"
|
|
38
|
-
@click="clear"
|
|
39
36
|
:disabled="disabled"
|
|
37
|
+
@click="clear"
|
|
40
38
|
)
|
|
41
39
|
</template>
|
|
42
40
|
|
|
43
|
-
<style lang="sass">
|
|
44
|
-
@import '../styles/_imports'
|
|
45
|
-
|
|
46
|
-
// TODO: Move to dito-ui
|
|
47
|
-
$select-arrow-right: calc(($select-arrow-width - $select-arrow-size) / 2)
|
|
48
|
-
|
|
49
|
-
.dito-select
|
|
50
|
-
display: inline-block
|
|
51
|
-
position: relative
|
|
52
|
-
|
|
53
|
-
select
|
|
54
|
-
padding-right: $select-arrow-width
|
|
55
|
-
|
|
56
|
-
// Handle .dito-width-fill separately due to required nesting of select:
|
|
57
|
-
&.dito-width-fill
|
|
58
|
-
select
|
|
59
|
-
width: 100%
|
|
60
|
-
|
|
61
|
-
&::after
|
|
62
|
-
position: absolute
|
|
63
|
-
+arrow($select-arrow-size)
|
|
64
|
-
bottom: $select-arrow-bottom
|
|
65
|
-
right: calc(#{$select-arrow-right} + #{$border-width})
|
|
66
|
-
|
|
67
|
-
&.dito-disabled::after
|
|
68
|
-
border-color: $border-color
|
|
69
|
-
</style>
|
|
70
|
-
|
|
71
41
|
<script>
|
|
72
|
-
import
|
|
42
|
+
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
73
43
|
import OptionsMixin from '../mixins/OptionsMixin.js'
|
|
74
44
|
|
|
75
45
|
// @vue/component
|
|
76
|
-
export default
|
|
46
|
+
export default DitoTypeComponent.register('select', {
|
|
77
47
|
mixins: [OptionsMixin],
|
|
78
48
|
|
|
79
49
|
nativeField: true,
|
|
@@ -87,3 +57,37 @@ export default TypeComponent.register('select', {
|
|
|
87
57
|
}
|
|
88
58
|
})
|
|
89
59
|
</script>
|
|
60
|
+
|
|
61
|
+
<style lang="scss">
|
|
62
|
+
@import '../styles/_imports';
|
|
63
|
+
|
|
64
|
+
// TODO: Move to dito-ui
|
|
65
|
+
$select-arrow-right: calc(($select-arrow-width - $select-arrow-size) / 2);
|
|
66
|
+
|
|
67
|
+
.dito-select {
|
|
68
|
+
display: inline-block;
|
|
69
|
+
position: relative;
|
|
70
|
+
|
|
71
|
+
select {
|
|
72
|
+
padding-right: $select-arrow-width;
|
|
73
|
+
}
|
|
74
|
+
// Handle .dito-width-fill separately due to required nesting of select:
|
|
75
|
+
&.dito-width-fill {
|
|
76
|
+
select {
|
|
77
|
+
width: 100%;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&::after {
|
|
82
|
+
position: absolute;
|
|
83
|
+
@include arrow($select-arrow-size);
|
|
84
|
+
|
|
85
|
+
bottom: $select-arrow-bottom;
|
|
86
|
+
right: calc(#{$select-arrow-right} + #{$border-width});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&.dito-disabled::after {
|
|
90
|
+
border-color: $border-color;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.dito-slider
|
|
3
3
|
input.dito-range(
|
|
4
|
-
ref="element"
|
|
5
4
|
:id="dataPath"
|
|
6
|
-
|
|
5
|
+
ref="element"
|
|
7
6
|
v-model="inputValue"
|
|
7
|
+
type="range"
|
|
8
8
|
v-bind="attributes"
|
|
9
9
|
:min="min"
|
|
10
10
|
:max="max"
|
|
11
11
|
:step="stepValue"
|
|
12
12
|
)
|
|
13
|
-
|
|
13
|
+
InputField.dito-number(
|
|
14
14
|
v-if="input"
|
|
15
|
-
type="number"
|
|
16
15
|
v-model="inputValue"
|
|
16
|
+
type="number"
|
|
17
17
|
v-bind="attributes"
|
|
18
18
|
:min="min"
|
|
19
19
|
:max="max"
|
|
@@ -21,32 +21,16 @@
|
|
|
21
21
|
)
|
|
22
22
|
</template>
|
|
23
23
|
|
|
24
|
-
<style lang="sass">
|
|
25
|
-
@import '../styles/_imports'
|
|
26
|
-
|
|
27
|
-
.dito-slider
|
|
28
|
-
@extend %input
|
|
29
|
-
display: flex
|
|
30
|
-
.dito-range
|
|
31
|
-
flex: auto
|
|
32
|
-
height: calc(1em * var(--line-height))
|
|
33
|
-
.dito-number
|
|
34
|
-
border: 0
|
|
35
|
-
padding: 0
|
|
36
|
-
text-align: right
|
|
37
|
-
font-variant-numeric: tabular-nums
|
|
38
|
-
</style>
|
|
39
|
-
|
|
40
24
|
<script>
|
|
41
|
-
import
|
|
25
|
+
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
42
26
|
import NumberMixin from '../mixins/NumberMixin.js'
|
|
43
27
|
import { getSchemaAccessor } from '../utils/accessor.js'
|
|
44
28
|
import { InputField } from '@ditojs/ui/src'
|
|
45
29
|
|
|
46
30
|
// @vue/component
|
|
47
|
-
export default
|
|
48
|
-
components: { InputField },
|
|
31
|
+
export default DitoTypeComponent.register('slider', {
|
|
49
32
|
mixins: [NumberMixin],
|
|
33
|
+
components: { InputField },
|
|
50
34
|
nativeField: true,
|
|
51
35
|
|
|
52
36
|
computed: {
|
|
@@ -58,3 +42,25 @@ export default TypeComponent.register('slider', {
|
|
|
58
42
|
}
|
|
59
43
|
})
|
|
60
44
|
</script>
|
|
45
|
+
|
|
46
|
+
<style lang="scss">
|
|
47
|
+
@import '../styles/_imports';
|
|
48
|
+
|
|
49
|
+
.dito-slider {
|
|
50
|
+
@extend %input;
|
|
51
|
+
|
|
52
|
+
display: flex;
|
|
53
|
+
|
|
54
|
+
.dito-range {
|
|
55
|
+
flex: auto;
|
|
56
|
+
height: calc(1em * var(--line-height));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.dito-number {
|
|
60
|
+
border: 0;
|
|
61
|
+
padding: 0;
|
|
62
|
+
text-align: right;
|
|
63
|
+
font-variant-numeric: tabular-nums;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</style>
|
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
|
|
3
|
-
ref="element"
|
|
2
|
+
SwitchButton.dito-switch(
|
|
4
3
|
:id="dataPath"
|
|
5
|
-
|
|
4
|
+
ref="element"
|
|
6
5
|
v-model="value"
|
|
6
|
+
:labels="labels"
|
|
7
7
|
v-bind="attributes"
|
|
8
8
|
)
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
|
-
<style lang="sass">
|
|
12
|
-
@import '../styles/_imports'
|
|
13
|
-
|
|
14
|
-
.dito-switch
|
|
15
|
-
.dito-switch-label
|
|
16
|
-
font-size: $font-size-small
|
|
17
|
-
</style>
|
|
18
|
-
|
|
19
11
|
<script>
|
|
20
|
-
import
|
|
12
|
+
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
21
13
|
import { SwitchButton } from '@ditojs/ui/src'
|
|
22
14
|
|
|
23
15
|
// @vue/component
|
|
24
|
-
export default
|
|
16
|
+
export default DitoTypeComponent.register('switch', {
|
|
25
17
|
defaultValue: false,
|
|
26
18
|
defaultWidth: 'auto',
|
|
27
19
|
|
|
@@ -36,3 +28,13 @@ export default TypeComponent.register('switch', {
|
|
|
36
28
|
}
|
|
37
29
|
})
|
|
38
30
|
</script>
|
|
31
|
+
|
|
32
|
+
<style lang="scss">
|
|
33
|
+
@import '../styles/_imports';
|
|
34
|
+
|
|
35
|
+
.dito-switch {
|
|
36
|
+
.dito-switch-label {
|
|
37
|
+
font-size: $font-size-small;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
</style>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<template lang="pug">
|
|
2
|
+
InputField.dito-text(
|
|
3
|
+
:id="dataPath"
|
|
4
|
+
ref="element"
|
|
5
|
+
v-model="inputValue"
|
|
6
|
+
:type="inputType"
|
|
7
|
+
v-bind="attributes"
|
|
8
|
+
)
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
13
|
+
import { InputField } from '@ditojs/ui/src'
|
|
14
|
+
|
|
15
|
+
const maskedPassword = '****************'
|
|
16
|
+
|
|
17
|
+
export default DitoTypeComponent.register(
|
|
18
|
+
[
|
|
19
|
+
'text',
|
|
20
|
+
'email',
|
|
21
|
+
'url',
|
|
22
|
+
'hostname',
|
|
23
|
+
'domain',
|
|
24
|
+
'tel',
|
|
25
|
+
'password',
|
|
26
|
+
'creditcard'
|
|
27
|
+
],
|
|
28
|
+
// @vue/component
|
|
29
|
+
{
|
|
30
|
+
components: { InputField },
|
|
31
|
+
nativeField: true,
|
|
32
|
+
textField: true,
|
|
33
|
+
ignoreMissingValue: schema => schema.type === 'password',
|
|
34
|
+
|
|
35
|
+
computed: {
|
|
36
|
+
inputType() {
|
|
37
|
+
return (
|
|
38
|
+
{
|
|
39
|
+
creditcard: 'text',
|
|
40
|
+
hostname: 'text',
|
|
41
|
+
domain: 'text'
|
|
42
|
+
}[this.type] ||
|
|
43
|
+
this.type
|
|
44
|
+
)
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
inputValue: {
|
|
48
|
+
get() {
|
|
49
|
+
return this.type === 'password' &&
|
|
50
|
+
this.value === undefined &&
|
|
51
|
+
!this.focused
|
|
52
|
+
? maskedPassword
|
|
53
|
+
: this.value
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
set(value) {
|
|
57
|
+
this.value = value
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
methods: {
|
|
63
|
+
getValidations() {
|
|
64
|
+
const rule = {
|
|
65
|
+
email: 'email',
|
|
66
|
+
url: 'url',
|
|
67
|
+
hostname: 'hostname',
|
|
68
|
+
domain: 'domain',
|
|
69
|
+
password: 'password',
|
|
70
|
+
creditcard: 'creditcard'
|
|
71
|
+
}[this.type]
|
|
72
|
+
return rule ? { [rule]: true } : {}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
</script>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
textarea.dito-textarea.dito-input(
|
|
3
|
-
ref="element"
|
|
4
3
|
:id="dataPath"
|
|
4
|
+
ref="element"
|
|
5
5
|
v-model="value"
|
|
6
6
|
v-bind="attributes"
|
|
7
7
|
:rows="lines"
|
|
@@ -9,23 +9,12 @@ textarea.dito-textarea.dito-input(
|
|
|
9
9
|
)
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
|
-
<style lang="sass">
|
|
13
|
-
@import '../styles/_imports'
|
|
14
|
-
|
|
15
|
-
.dito-textarea
|
|
16
|
-
display: block
|
|
17
|
-
resize: none
|
|
18
|
-
min-height: calc(1em * var(--line-height) + #{ 2 * $input-padding-ver })
|
|
19
|
-
&.dito-resizable
|
|
20
|
-
resize: vertical
|
|
21
|
-
</style>
|
|
22
|
-
|
|
23
12
|
<script>
|
|
24
|
-
import
|
|
13
|
+
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
25
14
|
import { getSchemaAccessor } from '../utils/accessor.js'
|
|
26
15
|
|
|
27
16
|
// @vue/component
|
|
28
|
-
export default
|
|
17
|
+
export default DitoTypeComponent.register('textarea', {
|
|
29
18
|
nativeField: true,
|
|
30
19
|
textField: true,
|
|
31
20
|
|
|
@@ -41,3 +30,17 @@ export default TypeComponent.register('textarea', {
|
|
|
41
30
|
}
|
|
42
31
|
})
|
|
43
32
|
</script>
|
|
33
|
+
|
|
34
|
+
<style lang="scss">
|
|
35
|
+
@import '../styles/_imports';
|
|
36
|
+
|
|
37
|
+
.dito-textarea {
|
|
38
|
+
display: block;
|
|
39
|
+
resize: none;
|
|
40
|
+
min-height: calc(1em * var(--line-height) + #{2 * $input-padding-ver});
|
|
41
|
+
|
|
42
|
+
&.dito-resizable {
|
|
43
|
+
resize: vertical;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
<template lang="pug">
|
|
2
|
+
.dito-tree-list
|
|
3
|
+
DitoScopes(
|
|
4
|
+
v-if="scopes"
|
|
5
|
+
:query="query"
|
|
6
|
+
:scopes="scopes"
|
|
7
|
+
)
|
|
8
|
+
.dito-tree-panel
|
|
9
|
+
DitoTreeItem(
|
|
10
|
+
:schema="treeSchema"
|
|
11
|
+
:dataPath="treeDataPath"
|
|
12
|
+
:data="treeData"
|
|
13
|
+
:draggable="draggable"
|
|
14
|
+
:open="true"
|
|
15
|
+
)
|
|
16
|
+
.dito-tree-form-container(
|
|
17
|
+
v-if="hasEditableForms"
|
|
18
|
+
)
|
|
19
|
+
//- Include a router-view for the optional DitoFormInlined
|
|
20
|
+
RouterView
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
25
|
+
import SourceMixin from '../mixins/SourceMixin.js'
|
|
26
|
+
import {
|
|
27
|
+
hasFormSchema,
|
|
28
|
+
getFormSchemas,
|
|
29
|
+
resolveSchemaComponents
|
|
30
|
+
} from '../utils/schema.js'
|
|
31
|
+
|
|
32
|
+
export default DitoTypeComponent.register(
|
|
33
|
+
['tree-list', 'tree-object'],
|
|
34
|
+
// @vue/component
|
|
35
|
+
{
|
|
36
|
+
mixins: [SourceMixin],
|
|
37
|
+
|
|
38
|
+
provide() {
|
|
39
|
+
return { container: this }
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
getSourceType(type) {
|
|
43
|
+
return type === 'tree-object' ? 'object' : 'list'
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
computed: {
|
|
47
|
+
path() {
|
|
48
|
+
// Accessed from DitoTreeItem through `container.path`:
|
|
49
|
+
return this.formComponent?.path
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
editPath() {
|
|
53
|
+
// Accessed from DitoTreeItem through `container.editPath`:
|
|
54
|
+
return this.$route.path.slice(this.path?.length)
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
treeData() {
|
|
58
|
+
return this.isListSource
|
|
59
|
+
? { [this.name]: this.value }
|
|
60
|
+
: this.value
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
treeDataPath() {
|
|
64
|
+
// Remove `name` from `dataPath`, as it is added
|
|
65
|
+
// to `treeData` and `treeSchema`
|
|
66
|
+
return this.isListSource
|
|
67
|
+
? this.dataPath.slice(0, this.dataPath.length - this.name.length)
|
|
68
|
+
: this.dataPath
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
treeSchema() {
|
|
72
|
+
return this.isListSource
|
|
73
|
+
? {
|
|
74
|
+
children: {
|
|
75
|
+
name: this.name,
|
|
76
|
+
...this.schema
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
: this.schema
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
hasEditableForms() {
|
|
83
|
+
const hasEditableForms = schema => {
|
|
84
|
+
return (
|
|
85
|
+
hasFormSchema(schema) && (
|
|
86
|
+
this.getSchemaValue('editable', {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false,
|
|
89
|
+
schema
|
|
90
|
+
}) ||
|
|
91
|
+
schema.children &&
|
|
92
|
+
hasEditableForms(schema.children)
|
|
93
|
+
)
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
return hasEditableForms(this.schema)
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
async processSchema(
|
|
101
|
+
api,
|
|
102
|
+
schema,
|
|
103
|
+
name,
|
|
104
|
+
routes,
|
|
105
|
+
level,
|
|
106
|
+
nested = true,
|
|
107
|
+
flatten = false,
|
|
108
|
+
process = null
|
|
109
|
+
) {
|
|
110
|
+
await Promise.all([
|
|
111
|
+
resolveSchemaComponents(schema.properties),
|
|
112
|
+
SourceMixin.processSchema(
|
|
113
|
+
api,
|
|
114
|
+
schema,
|
|
115
|
+
name,
|
|
116
|
+
routes,
|
|
117
|
+
level,
|
|
118
|
+
nested,
|
|
119
|
+
flatten,
|
|
120
|
+
// Pass process() to add more routes to childRoutes:
|
|
121
|
+
(childRoutes, level) => {
|
|
122
|
+
const { children } = schema
|
|
123
|
+
if (children) {
|
|
124
|
+
// Add `type` to the nested tree list.
|
|
125
|
+
children.type = 'tree-list'
|
|
126
|
+
// Recursively call `processSchema()` for the nested tree list:
|
|
127
|
+
return this.processSchema(
|
|
128
|
+
api,
|
|
129
|
+
children,
|
|
130
|
+
children.name,
|
|
131
|
+
childRoutes,
|
|
132
|
+
level,
|
|
133
|
+
nested,
|
|
134
|
+
true, // Pass `true` for `flatten` in tree lists.
|
|
135
|
+
process
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
])
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
getFormSchemasForProcessing(schema, context) {
|
|
144
|
+
// Convert nested children schema to stand-alone schema component,
|
|
145
|
+
// present in each of the forms, as required by `processSchemaData()`
|
|
146
|
+
const { children } = schema
|
|
147
|
+
return getFormSchemas(
|
|
148
|
+
schema,
|
|
149
|
+
context,
|
|
150
|
+
children
|
|
151
|
+
? form => ({
|
|
152
|
+
...form,
|
|
153
|
+
components: {
|
|
154
|
+
...form.components,
|
|
155
|
+
[children.name]: children
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
: null
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
</script>
|
|
164
|
+
|
|
165
|
+
<style lang="scss">
|
|
166
|
+
@import '../styles/_imports';
|
|
167
|
+
|
|
168
|
+
.dito-tree-list {
|
|
169
|
+
@extend %field;
|
|
170
|
+
|
|
171
|
+
.dito-tree-panel {
|
|
172
|
+
display: flex;
|
|
173
|
+
justify-content: space-between;
|
|
174
|
+
|
|
175
|
+
> .dito-tree-item {
|
|
176
|
+
flex: 1 1 25%;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
> .dito-tree-form-container {
|
|
180
|
+
flex: 0 1 75%;
|
|
181
|
+
align-self: stretch;
|
|
182
|
+
background: $content-color-background;
|
|
183
|
+
border-left: $border-style;
|
|
184
|
+
border-top-right-radius: $border-radius - 1;
|
|
185
|
+
border-bottom-right-radius: $border-radius - 1;
|
|
186
|
+
margin: (-$input-padding-ver) (-$input-padding-hor);
|
|
187
|
+
margin-left: $input-padding-hor;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
</style>
|