-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathShortcutDialog.vue
73 lines (69 loc) · 1.51 KB
/
ShortcutDialog.vue
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
<template>
<v-dialog v-model="isActive" max-width="500px">
<v-card>
<v-card-title>
ショートカット編集
</v-card-title>
<v-card-text>
<form @submit.prevent="add()">
<v-text-field
v-model.lazy="command"
label="登録するコマンドを入力..."
autofocus
/>
</form>
<v-chip
class="mr-2"
v-for="(command, i) in shortcuts"
:key="i"
@click:close="remove(command)"
close
>{{ command }}</v-chip
>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn @click.stop="isActive = false" color="primary" text
>閉じる</v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
@Component({
props: {
value: Boolean
},
watch: {
value(val: boolean) {
if (val != this.$data.isActive) {
this.$data.isActive = val;
}
},
isActive(val: boolean) {
this.$emit("input", val);
}
}
})
export default class ShortcutDialog extends Vue {
data() {
return {
isActive: false,
command: ""
};
}
add() {
this.$store.commit("addShortcut", this.$data.command);
this.$data.command = "";
}
remove(command: string) {
this.$store.commit("removeShortcut", command);
}
get shortcuts() {
return this.$store.state.shortcuts;
}
}
</script>