From bcf750d45162688440a9cc18bfd0817745a6ee25 Mon Sep 17 00:00:00 2001 From: Spythere Date: Thu, 22 Sep 2022 14:57:03 +0200 Subject: [PATCH] =?UTF-8?q?Wywo=C5=82ywanie=20filtr=C3=B3w=20za=20pomoc?= =?UTF-8?q?=C4=85=20klawisza=20F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/JournalView/JournalOptions.vue | 21 ++++++++++--- .../StationsView/StationFilterCard.vue | 12 +++++-- src/components/TrainsView/TrainOptions.vue | 31 ++++++++++++++----- src/mixins/keyMixin.ts | 25 +++++++++++++++ src/views/TrainsView.vue | 4 +++ 5 files changed, 79 insertions(+), 14 deletions(-) create mode 100644 src/mixins/keyMixin.ts diff --git a/src/components/JournalView/JournalOptions.vue b/src/components/JournalView/JournalOptions.vue index 85522e9..ba106b4 100644 --- a/src/components/JournalView/JournalOptions.vue +++ b/src/components/JournalView/JournalOptions.vue @@ -4,7 +4,7 @@ @@ -53,6 +53,8 @@ v-else class="search-input" @keydown.enter="onSearchConfirm" + @focus="preventKeyDown = true" + @blur="preventKeyDown = false" :placeholder="$t(`options.${propName}`)" v-model="searchersValues[propName]" /> @@ -68,7 +70,7 @@ {{ $t('options.reset-button') }} - + {{ $t('options.search-button') }} @@ -87,6 +89,7 @@ diff --git a/src/mixins/keyMixin.ts b/src/mixins/keyMixin.ts new file mode 100644 index 0000000..dd1979f --- /dev/null +++ b/src/mixins/keyMixin.ts @@ -0,0 +1,25 @@ +import { defineComponent } from 'vue'; + +export default defineComponent({ + data() { + return { + preventKeyDown: false, + }; + }, + + activated() { + window.addEventListener('keydown', this.handleKeyDown); + }, + + deactivated() { + window.removeEventListener('keydown', this.handleKeyDown); + }, + + methods: { + onKeyDownFunction() {}, + + handleKeyDown(e: KeyboardEvent) { + if (e.key.toLowerCase() == 'f' && !this.preventKeyDown) this.onKeyDownFunction(); + }, + }, +}); diff --git a/src/views/TrainsView.vue b/src/views/TrainsView.vue index 41c1048..0797a4d 100644 --- a/src/views/TrainsView.vue +++ b/src/views/TrainsView.vue @@ -79,7 +79,11 @@ export default defineComponent({ this.searchedTrain = this.train; this.searchedDriver = this.driver || ''; } + }, + + + });