Skip to content

Commit 947eaa8

Browse files
committed
feat(ui): allow re-ordering of array items
1 parent cf30976 commit 947eaa8

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

ui/src/components/code/styles/code.scss

+4-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ $code-font-sm: var(--el-font-size-small);
5353
font-size: $code-font-sm;
5454
}
5555

56-
.delete {
56+
.delete,
57+
.reorder {
5758
cursor: pointer;
5859
padding-left: 0;
5960
color: $code-gray-700;
@@ -64,7 +65,8 @@ $code-font-sm: var(--el-font-size-small);
6465
:deep(*) {
6566
--el-disabled-text-color: #{$code-gray-700};
6667

67-
.el-input__inner {
68+
.el-input__inner,
69+
.el-textarea__inner {
6870
color: $code-gray-700;
6971
font-size: $code-font-sm;
7072
}

ui/src/components/flows/tasks/TaskArray.vue

+25-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
v-for="(element, index) in items"
44
:key="'array-' + index"
55
:gutter="10"
6-
class="w-100 mb-2"
6+
class="w-100"
77
>
8-
<el-col :span="22">
8+
<el-col :span="2" class="d-flex flex-column mt-1 mb-2 reorder">
9+
<ChevronUp @click.prevent.stop="moveItem(index, 'up')" />
10+
<ChevronDown @click.prevent.stop="moveItem(index, 'down')" />
11+
</el-col>
12+
<el-col :span="20">
913
<InputText
1014
:model-value="element"
1115
@update:model-value="(v) => handleInput(v, index)"
@@ -23,7 +27,7 @@
2327
<script setup lang="ts">
2428
import {ref} from "vue";
2529
26-
import {DeleteOutline} from "../../code/utils/icons";
30+
import {DeleteOutline, ChevronUp, ChevronDown} from "../../code/utils/icons";
2731
2832
import InputText from "../../code/components/inputs/InputText.vue";
2933
import Add from "../../code/components/Add.vue";
@@ -50,4 +54,22 @@
5054
items.value.splice(index, 1);
5155
emits("update:modelValue", items.value);
5256
};
57+
const moveItem = (index: number, direction: "up" | "down") => {
58+
if (direction === "up" && index > 0) {
59+
[items.value[index - 1], items.value[index]] = [
60+
items.value[index],
61+
items.value[index - 1],
62+
];
63+
} else if (direction === "down" && index < items.value.length - 1) {
64+
[items.value[index + 1], items.value[index]] = [
65+
items.value[index],
66+
items.value[index + 1],
67+
];
68+
}
69+
emits("update:modelValue", items.value);
70+
};
5371
</script>
72+
73+
<style scoped lang="scss">
74+
@import "../../code/styles/code.scss";
75+
</style>

0 commit comments

Comments
 (0)