-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathScheduleList.vue
More file actions
81 lines (75 loc) · 1.87 KB
/
Copy pathScheduleList.vue
File metadata and controls
81 lines (75 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<template>
<ol style="margin-block-start: 0em">
<div v-for="(room, index) in rooms" :key="index">
<li :value="room.actualIndex + 1" style="padding: 0.5vh">
{{ room.value }}
</li>
<CustomButton
v-if="
index != rooms.length - 1 &&
room.value.trim() !== '' &&
rooms[index + 1].value.trim() !== ''
"
style="
font-size: 0.7em;
margin-left: -1.5em;
margin-top: 0.1em;
margin-bottom: 0.3em;
padding-left: 2vw;
"
@click="go(index)"
>
↓ Go from {{ rooms[index].value }} to {{ rooms[index + 1].value }} ↓
</CustomButton>
</div>
</ol>
</template>
<script lang="ts">
// eslint-disable-next-line no-unused-vars
import Vue, { PropType } from "vue";
import CustomButton from "@/components/buttons/CustomButton.vue";
interface StoredRoom {
value: string;
originalIndex: number;
}
interface StoredRoomWithActualIndex extends StoredRoom {
actualIndex: number;
}
function range(len: number) {
return [...Array(len).keys()];
}
export default Vue.extend({
components: { CustomButton },
props: {
allRooms: { type: Array as PropType<StoredRoom[]>, required: true },
order: {
type: Array as PropType<number[] | null>,
default: null,
},
},
computed: {
orderWithDefault() {
return this.order ?? range(this.allRooms.length);
},
rooms(): StoredRoomWithActualIndex[] {
return this.orderWithDefault.map((ind) => ({
...(this.allRooms[ind] ?? { value: "", originalIndex: 0 }),
actualIndex: ind,
}));
},
},
methods: {
go(index: number) {
this.$emit("go", {
fromRoom: this.rooms[index].value,
toRoom: this.rooms[index + 1].value,
});
},
},
});
</script>
<style scoped>
li {
color: var(--less-important-text-color);
}
</style>