forked from mainsail-crew/mainsail
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMmuEditGateMapDialog.vue
More file actions
139 lines (119 loc) · 4.28 KB
/
Copy pathMmuEditGateMapDialog.vue
File metadata and controls
139 lines (119 loc) · 4.28 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<template>
<v-dialog v-model="showDialog" width="800" persistent :fullscreen="isMobile">
<panel
:title="$t('Panels.MmuPanel.EditGateMapTitle')"
:icon="mdiDatabaseEdit"
card-class="mmu-edit-ttg-map-dialog"
:margin-bottom="false">
<template #buttons>
<v-btn text tile @click="showResetConfirmationDialog = true">
{{ $t('Panels.MmuPanel.GateMapDialog.Reset') }}
</v-btn>
<v-btn icon tile @click="close">
<v-icon>{{ mdiCloseThick }}</v-icon>
</v-btn>
</template>
<v-card-text>
<v-card-subtitle class="pt-0 px-1 text--secondary">
{{ $t('Panels.MmuPanel.GateMapDialog.SelectGate') }}
</v-card-subtitle>
<v-row>
<v-col class="pb-0">
<mmu-unit
v-for="i in mmuNumUnits"
:key="i"
:selected-gate="selectedGate"
:unit-index="i - 1"
:hide-bypass="true"
:show-context-menu="false"
:unhighlight-spools="true"
@select-gate="selectGate" />
</v-col>
</v-row>
</v-card-text>
<v-divider />
<v-card-text class="min-height-420 position-relative">
<transition name="fade">
<div v-if="selectedGate === TOOL_GATE_UNKNOWN" class="overlay-text">
{{ $t('Panels.MmuPanel.GateMapDialog.SelectGate') }}
</div>
<mmu-edit-gate-map-dialog-gate-details v-else :selected-gate="selectedGate" />
</transition>
</v-card-text>
</panel>
<!-- CONFIRMATION FOR RESET ACTION -->
<confirmation-dialog
v-model="showResetConfirmationDialog"
:title="$t('Panels.MmuPanel.Dialog.AreYouSure')"
:text="$t('Panels.MmuPanel.GateMapDialog.ResetConfirmation')"
:action-button-text="$t('Panels.MmuPanel.GateMapDialog.Reset')"
@action="executeResetGateMap" />
</v-dialog>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins, VModel, Prop, Watch } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import MmuMixin, { TOOL_GATE_UNKNOWN } from '@/components/mixins/mmu'
import ConfirmationDialog from '@/components/dialogs/ConfirmationDialog.vue'
import { mdiCloseThick, mdiDatabaseEdit } from '@mdi/js'
@Component({
components: { ConfirmationDialog },
})
export default class MmuEditGateMapDialog extends Mixins(BaseMixin, MmuMixin) {
TOOL_GATE_UNKNOWN = TOOL_GATE_UNKNOWN
mdiCloseThick = mdiCloseThick
mdiDatabaseEdit = mdiDatabaseEdit
@VModel({ type: Boolean }) showDialog!: boolean
@Prop({ required: false, default: null })
readonly initialGate!: number | null
showResetConfirmationDialog = false
selectedGate = TOOL_GATE_UNKNOWN
@Watch('showDialog')
onShowDialogChanged(val: boolean) {
if (!val) return
if (this.initialGate !== null && this.initialGate !== undefined) {
this.selectedGate = this.initialGate
} else {
this.selectedGate = TOOL_GATE_UNKNOWN
}
}
selectGate(gate: number) {
this.selectedGate = gate
}
handleEscapePress(event: KeyboardEvent) {
if (event.key === 'Escape' || event.code === 'Escape') {
this.selectedGate = TOOL_GATE_UNKNOWN
}
}
mounted() {
document.addEventListener('keydown', this.handleEscapePress)
}
beforeDestroy() {
document.removeEventListener('keydown', this.handleEscapePress)
}
executeResetGateMap() {
this.doSend('MMU_GATE_MAP RESET=1')
}
close() {
this.$emit('close')
this.showDialog = false
}
}
</script>
<style scoped>
.min-height-420 {
min-height: 420px;
}
.overlay-text {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
}
</style>