From 931fd7b21bfebc50e8e2d7f7fb057bce4ff26c6a Mon Sep 17 00:00:00 2001 From: Spythere Date: Sat, 11 Jan 2025 00:20:58 +0100 Subject: [PATCH] feat: copying a railway stock of active drivers and timetable journal --- .../JournalTimetables/EntryDetails.vue | 30 +++++++++++++++-- src/locales/en.json | 9 +++++- src/locales/pl.json | 9 +++++- src/styles/global.scss | 2 +- src/views/DriverView.vue | 32 ++++++++++++++++--- 5 files changed, 73 insertions(+), 9 deletions(-) diff --git a/src/components/JournalView/JournalTimetables/EntryDetails.vue b/src/components/JournalView/JournalTimetables/EntryDetails.vue index 81c3cdf..5c47d06 100644 --- a/src/components/JournalView/JournalTimetables/EntryDetails.vue +++ b/src/components/JournalView/JournalTimetables/EntryDetails.vue @@ -95,7 +95,11 @@
{{ $t('journal.stock-preview') }}: -
+
+ +
-
- -
+ + + +
@@ -79,6 +82,7 @@ import { useMainStore } from '../store/mainStore'; import { useApiStore } from '../store/apiStore'; import { Status } from '../typings/common'; import { regions as regionsJSON } from '../data/options.json'; +import { useI18n } from 'vue-i18n'; const props = defineProps({ trainId: { @@ -93,6 +97,8 @@ const props = defineProps({ const mainStore = useMainStore(); const apiStore = useApiStore(); +const i18n = useI18n(); + const chosenTrain = computed(() => mainStore.trainList.find((train) => train.id == props.trainId || train.modalId == props.modalId) ); @@ -104,6 +110,24 @@ const otherDriverTrains = computed(() => { (train.timetableData || train.online || train.lastSeen >= Date.now() - 60000) ); }); + +function copyStockToClipboard() { + const stockString = chosenTrain.value?.stockList.join(';'); + + if (!stockString) { + alert(i18n.t('trains.stock-clipboard-failure')); + return; + } + + navigator.clipboard + .writeText(stockString) + .then(() => { + prompt(i18n.t('trains.stock-clipboard-success'), stockString); + }) + .catch(() => { + alert(i18n.t('trains.stock-clipboard-failure')); + }); +}