chore: moved stock computations to store

This commit is contained in:
2025-03-07 15:11:34 +01:00
parent 72f28abf10
commit 90e257127c
4 changed files with 78 additions and 57 deletions
+2 -23
View File
@@ -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'),