comparison client/src/components/KeyboardHandler.vue @ 3553:869505c5087b

client: fairway profile: close compare view with ESC key also added a notice at the top of the screen that indicates when ESC key can be used to either cancel drawing (line, polygon, crosscut) or to close the compare split view for two sounding results
author Markus Kottlaender <markus@intevation.de>
date Fri, 31 May 2019 14:32:24 +0200
parents
children 0fa20662ca66
comparison
equal deleted inserted replaced
3552:ffc8fb059d1a 3553:869505c5087b
1 <template>
2 <transition name="fade">
3 <div class="notice" v-if="showNotice">
4 <span>{{ noticeText }}</span>
5 </div>
6 </transition>
7 </template>
8
9 <style lang="sass" scoped>
10 .notice
11 position: absolute
12 top: 0
13 width: 100%
14 text-align: center
15 z-index: 1
16 font-size: 11px
17 line-height: 11px
18 > span
19 opacity: 0.5
20 background: white
21 display: inline-block
22 border-bottom-right-radius: 0.25rem
23 border-bottom-left-radius: 0.25rem
24 padding: 3px 5px
25 </style>
26
27 <script>
28 /* This is Free Software under GNU Affero General Public License v >= 3.0
29 * without warranty, see README.md and license for details.
30 *
31 * SPDX-License-Identifier: AGPL-3.0-or-later
32 * License-Filename: LICENSES/AGPL-3.0.txt
33 *
34 * Copyright (C) 2018 by via donau
35 * – Österreichische Wasserstraßen-Gesellschaft mbH
36 * Software engineering by Intevation GmbH
37 *
38 * Author(s):
39 * Markus Kottländer <markus.kottlaender@intevation.de>
40 */
41
42 import { mapState } from "vuex";
43
44 export default {
45 computed: {
46 ...mapState("application", ["paneSetup"]),
47 ...mapState("map", [
48 "openLayersMaps",
49 "lineToolEnabled",
50 "polygonToolEnabled",
51 "cutToolEnabled"
52 ]),
53 showNotice() {
54 return (
55 this.lineToolEnabled ||
56 this.polygonToolEnabled ||
57 this.cutToolEnabled ||
58 this.paneSetup.includes("COMPARESURVEYS")
59 );
60 },
61 noticeText() {
62 if (
63 this.lineToolEnabled ||
64 this.polygonToolEnabled ||
65 this.cutToolEnabled
66 ) {
67 return this.$gettext("Press ESC to stop drawing.");
68 } else if (this.paneSetup.includes("COMPARESURVEYS")) {
69 return this.$gettext("Press ESC to close compare view.");
70 }
71 }
72 },
73 mounted() {
74 window.addEventListener("keydown", e => {
75 // Escape
76 if (e.keyCode === 27) {
77 if (
78 this.lineToolEnabled ||
79 this.polygonToolEnabled ||
80 this.cutToolEnabled
81 ) {
82 this.$store.commit("map/lineToolEnabled", false);
83 this.$store.commit("map/polygonToolEnabled", false);
84 this.$store.commit("map/cutToolEnabled", false);
85 this.$store.commit("map/setCurrentMeasurement", null);
86 this.openLayersMaps.forEach(m => {
87 m.getLayer("DRAWTOOL")
88 .getSource()
89 .clear();
90 });
91 } else if (this.paneSetup.includes("COMPARESURVEYS")) {
92 this.$store.commit("fairwayprofile/additionalSurvey", null);
93 }
94 }
95 });
96 }
97 };
98 </script>