|
4 | 4 | :textColor="iconColor" :color="'blue'"
|
5 | 5 | :selected="selected && selected === widget"
|
6 | 6 | :opened="!widget.closed"
|
| 7 | + :toggle="canHaveChildren" |
7 | 8 | @treeview:open="setWidgetClosed(false)"
|
8 | 9 | @treeview:close="setWidgetClosed(true)"
|
9 | 10 | @click="select">
|
10 |
| - <draggable v-if="canHaveChildren" :list="children" group="sitemap-treeview" animation="150" fallbackOnBody="true" swapThreshold="0.6" |
| 11 | + <draggable :list="children" group="sitemap-treeview" animation="150" fallbackOnBody="true" swapThreshold="0.6" |
11 | 12 | @start="onStart" @change="onChange" @end="onEnd">
|
12 | 13 | <sitemap-treeview-item class="sitemap-treeview-item" v-for="(childwidget, idx) in children"
|
13 | 14 | :key="idx"
|
@@ -66,18 +67,21 @@ export default {
|
66 | 67 | },
|
67 | 68 | onStart (event) {
|
68 | 69 | console.debug('Drag start event:', event)
|
| 70 | + this.$set(this.localMoveState, 'moving', true) |
69 | 71 | this.$set(this.localMoveState, 'widget', this.widget.slots.widgets[event.oldIndex])
|
70 | 72 | this.$set(this.localMoveState, 'oldList', this.widget.slots.widgets)
|
71 | 73 | this.$set(this.localMoveState, 'oldIndex', event.oldIndex)
|
72 | 74 | },
|
73 | 75 | onChange (event) {
|
74 | 76 | console.debug('Drag change event:', event)
|
75 | 77 | if (event.added) {
|
| 78 | + this.$set(this.localMoveState, 'moving', false) |
76 | 79 | this.validateMove(event.added.newIndex)
|
77 | 80 | }
|
78 | 81 | },
|
79 | 82 | onEnd (event) {
|
80 | 83 | console.debug('Drag end event:', event)
|
| 84 | + this.$set(this.localMoveState, 'moving', false) |
81 | 85 | this.validateMove(event.newIndex)
|
82 | 86 | },
|
83 | 87 | validateMove (newIndex) {
|
@@ -123,7 +127,7 @@ export default {
|
123 | 127 | return this.widget.slots?.widgets || []
|
124 | 128 | },
|
125 | 129 | canHaveChildren () {
|
126 |
| - return this.LINKABLE_WIDGET_TYPES.includes(this.widget.component) |
| 130 | + return (this.LINKABLE_WIDGET_TYPES.includes(this.widget.component) && (this.children.length > 0 || this.localMoveState.moving)) === true |
127 | 131 | }
|
128 | 132 | }
|
129 | 133 | }
|
|
0 commit comments