Skip to content

Commit 9b668d2

Browse files
committed
feat(ui): ArgsPicker drap and drop
1 parent fe758dd commit 9b668d2

1 file changed

Lines changed: 42 additions & 14 deletions

File tree

web/src/components/ArgsPicker.vue

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,30 @@
6666
>
6767
<legend style="padding: 0 3px;">{{ title || $t('Args') }}</legend>
6868
<v-chip-group column style="margin-top: -4px;">
69-
<v-chip
70-
v-for="(v, i) in modifiedVars"
71-
close
72-
@click:close="deleteVar(i)"
73-
:key="i"
74-
@click="editVar(i)"
69+
<draggable
70+
v-model="modifiedVars"
71+
@end="onDragEnd"
72+
:animation="200"
73+
class="d-flex flex-wrap"
74+
ghost-class="chip-ghost"
7575
>
76-
<div
77-
style="
78-
max-width: 200px;
79-
overflow: hidden;
80-
text-overflow: ellipsis;
81-
"
82-
>{{ v.name }}</div>
83-
</v-chip>
76+
<v-chip
77+
v-for="(v, i) in modifiedVars"
78+
close
79+
@click:close="deleteVar(i)"
80+
:key="i"
81+
@click="editVar(i)"
82+
class="draggable-chip"
83+
>
84+
<div
85+
style="
86+
max-width: 200px;
87+
overflow: hidden;
88+
text-overflow: ellipsis;
89+
"
90+
>{{ v.name }}</div>
91+
</v-chip>
92+
</draggable>
8493
<v-chip @click="editVar(null)">
8594
+ <span
8695
class="ml-1"
@@ -92,10 +101,25 @@
92101
</div>
93102
</template>
94103
<style lang="scss">
104+
.draggable-chip {
105+
cursor: grab;
95106
107+
&:active {
108+
cursor: grabbing;
109+
}
110+
}
111+
112+
.chip-ghost {
113+
opacity: 0.5;
114+
}
96115
</style>
97116
<script>
117+
import draggable from 'vuedraggable';
118+
98119
export default {
120+
components: {
121+
draggable,
122+
},
99123
props: {
100124
vars: Array,
101125
title: String,
@@ -175,6 +199,10 @@ export default {
175199
this.modifiedVars.splice(index, 1);
176200
this.$emit('change', this.modifiedVars.map((x) => x.name));
177201
},
202+
203+
onDragEnd() {
204+
this.$emit('change', this.modifiedVars.map((x) => x.name));
205+
},
178206
},
179207
};
180208
</script>

0 commit comments

Comments
 (0)