From 90e257127c49e1abdd2cbc16ac3513cbc0b9252d Mon Sep 17 00:00:00 2001 From: Spythere Date: Fri, 7 Mar 2025 15:11:34 +0100 Subject: [PATCH] chore: moved stock computations to store --- src/components/tabs/StockListTab.vue | 25 ++----------- src/components/tabs/StorageTab.vue | 42 +++++++++++++++++----- src/store.ts | 52 ++++++++++++++-------------- src/utils/vehicleUtils.ts | 16 +++++++++ 4 files changed, 78 insertions(+), 57 deletions(-) diff --git a/src/components/tabs/StockListTab.vue b/src/components/tabs/StockListTab.vue index cfda1df..0a55094 100644 --- a/src/components/tabs/StockListTab.vue +++ b/src/components/tabs/StockListTab.vue @@ -289,27 +289,6 @@ export default defineComponent({ return this.store.realCompositionList.find((rc) => rc.stockString == currentStockString); }, - stockString() { - if (this.store.stockList.length == 0) return ''; - - const includeColdStart = this.store.isColdStart && this.store.stockSupportsColdStart; - const includeDoubleManned = - this.store.isDoubleManned && this.store.stockSupportsDoubleManning; - - return this.store.stockList - .map((stock, i) => { - let stockTypeStr = - isTractionUnit(stock.vehicleRef) || !stock.cargo - ? stock.vehicleRef.type - : `${stock.vehicleRef.type}:${stock.cargo.id}`; - - if (i == 0 && (includeColdStart || includeDoubleManned)) - return `${stockTypeStr},${includeColdStart ? 'c' : ''}${includeDoubleManned ? 'd' : ''}`; - - return stockTypeStr; - }) - .join(';'); - }, stockIsEmpty() { return this.store.stockList.length == 0; @@ -371,7 +350,7 @@ export default defineComponent({ isTractionUnit, copyToClipboard() { - navigator.clipboard.writeText(this.stockString); + navigator.clipboard.writeText(this.store.stockString); setTimeout(() => { alert(this.$t('stocklist.alert-copied')); @@ -481,7 +460,7 @@ export default defineComponent({ if (!fileName) return; - const blob = new Blob([this.stockString]); + const blob = new Blob([this.store.stockString]); const file = fileName + '.con'; var e = document.createEvent('MouseEvents'), diff --git a/src/components/tabs/StorageTab.vue b/src/components/tabs/StorageTab.vue index a4ea4a8..3caab16 100644 --- a/src/components/tabs/StorageTab.vue +++ b/src/components/tabs/StorageTab.vue @@ -7,28 +7,47 @@
- -
+ +