chore: added additional cargo warnings

This commit is contained in:
2025-05-31 23:32:41 +02:00
parent 09e5c53558
commit 05ae446af7
5 changed files with 47 additions and 35 deletions
@@ -2,31 +2,25 @@
<div class="stock_warnings" v-if="hasAnyWarnings">
<div class="warning" v-if="locoNotSuitable">(!) {{ $t('stocklist.warning-not-suitable') }}</div>
<div class="warning" v-if="lengthExceeded && store.isTrainPassenger">
(!) {{ $t('stocklist.warning-passenger-too-long') }}
</div>
<div class="warning" v-if="lengthExceeded && store.isTrainPassenger">(!) {{ $t('stocklist.warning-passenger-too-long') }}</div>
<div class="warning" v-if="lengthExceeded && !store.isTrainPassenger">
(!) {{ $t('stocklist.warning-freight-too-long') }}
</div>
<div class="warning" v-if="lengthExceeded && !store.isTrainPassenger">(!) {{ $t('stocklist.warning-freight-too-long') }}</div>
<div class="warning" v-if="teamOnlyVehicles.length > 0">
(!)
{{
$t('stocklist.warning-team-only-vehicle', [
teamOnlyVehicles.map((v) => v.vehicleRef.type).join(', '),
])
}}
{{ $t('stocklist.warning-team-only-vehicle', [teamOnlyVehicles.map((v) => v.vehicleRef.type).join(', ')]) }}
</div>
<div class="warning" v-if="store.cargoWarnings.size > 0">
{{ $t('cargo-warnings.title') }}
{{ [...store.cargoWarnings].map((v) => $t(`cargo-warnings.${v}`)).join('; ') }}
</div>
<div class="warning" v-if="weightExceeded">
(!)
<i18n-t keypath="stocklist.warning-too-heavy">
<template #href>
<a
target="_blank"
href="https://docs.google.com/spreadsheets/d/1BvTU-U7huIaEheov22TrhTtROUM4MwVfdbq03GVAEM8"
>
<a target="_blank" href="https://docs.google.com/spreadsheets/d/1BvTU-U7huIaEheov22TrhTtROUM4MwVfdbq03GVAEM8">
{{ $t('stocklist.acceptable-mass-docs') }}
</a>
</template>
@@ -55,16 +49,11 @@ export default defineComponent({
},
hasAnyWarnings() {
return (
this.weightExceeded || this.lengthExceeded || this.locoNotSuitable || this.teamOnlyVehicles
);
return this.weightExceeded || this.lengthExceeded || this.locoNotSuitable || this.teamOnlyVehicles;
},
lengthExceeded() {
return (
(this.store.totalLength > 350 && this.store.isTrainPassenger) ||
(this.store.totalLength > 650 && !this.store.isTrainPassenger)
);
return (this.store.totalLength > 350 && this.store.isTrainPassenger) || (this.store.totalLength > 650 && !this.store.isTrainPassenger);
},
weightExceeded() {
@@ -76,9 +65,7 @@ export default defineComponent({
!this.store.isTrainPassenger &&
this.store.stockList.length > 1 &&
!this.store.stockList.every((stock) => isTractionUnit(stock.vehicleRef)) &&
this.store.stockList.some(
(stock) => isTractionUnit(stock.vehicleRef) && stock.vehicleRef.type.startsWith('EP')
)
this.store.stockList.some((stock) => isTractionUnit(stock.vehicleRef) && stock.vehicleRef.type.startsWith('EP'))
);
},
},
+8
View File
@@ -325,5 +325,13 @@
"418Vb_WIEBE": "loose cargo (sand, stone)",
"418Vb_ZOS": "loose cargo (sand, stone)",
"418Vb_ZUE": "loose cargo (sand, stone)"
},
"cargo-warnings": {
"title": "Cargo warnings:",
"warning_wt_20_pn": "PN: exceeded gauge (Innofreight - C45)",
"warning_un1965_twr": "TWR: LPG (UN 1965)",
"warning_un1965_tn": "TN: LPG - empty tank (UN 1965)",
"warning_un1202_twr": "TWR: diesel fuel (UN 1202)",
"warning_un1202_tn": "TN: diesel fuel - empty tank (UN 1202)"
}
}
+8
View File
@@ -324,5 +324,13 @@
"418Vb_WIEBE": "drobnica, ładunki sypkie (piasek, kamień)",
"418Vb_ZOS": "drobnica, ładunki sypkie (piasek, kamień)",
"418Vb_ZUE": "drobnica, ładunki sypkie (piasek, kamień)"
},
"cargo-warnings": {
"title": "Uwagi przewozowe:",
"warning_wt_20_pn": "PN: przekroczona skrajnia (Innofreight - C45)",
"warning_un1965_twr": "TWR: gazy węglowodorowe skroplone (UN 1965)",
"warning_un1965_tn": "TN: gazy węglowodorowe skroplone - puste cysterny (UN 1965)",
"warning_un1202_twr": "TWR: olej napędowy (UN 1202)",
"warning_un1202_tn": "TN: olej napędowy - puste cysterny (UN 1202)"
}
}
+5 -10
View File
@@ -15,6 +15,7 @@ import { defineStore } from 'pinia';
import {
acceptableWeight,
carDataList,
getCargoWarnings,
isTractionUnit,
isTrainPassenger,
locoDataList,
@@ -68,15 +69,13 @@ export const useStore = defineStore('store', {
getters: {
locoDataList: (state) => locoDataList(state.vehiclesData),
carDataList: (state) => carDataList(state.vehiclesData),
vehicleDataList: (state) => [
...locoDataList(state.vehiclesData),
...carDataList(state.vehiclesData),
],
vehicleDataList: (state) => [...locoDataList(state.vehiclesData), ...carDataList(state.vehiclesData)],
totalWeight: (state) => totalWeight(state.stockList),
totalLength: (state) => totalLength(state.stockList),
maxStockSpeed: (state) => maxStockSpeed(state.stockList),
isTrainPassenger: (state) => isTrainPassenger(state.stockList),
acceptableWeight: (state) => acceptableWeight(state.stockList),
cargoWarnings: (state) => getCargoWarnings(state.stockList),
stockSupportsColdStart: (state) => stockSupportsColdStart(state.stockList),
stockSupportsDoubleManning: (state) => stockSupportsDoubleManning(state.stockList),
@@ -85,15 +84,11 @@ export const useStore = defineStore('store', {
if (state.stockList.length == 0) return '';
const coldStartActive = state.isColdStart && stockSupportsColdStart(state.stockList);
const doubleManningActive =
state.isDoubleManned && stockSupportsDoubleManning(state.stockList);
const doubleManningActive = state.isDoubleManned && stockSupportsDoubleManning(state.stockList);
return state.stockList
.map((stock, i) => {
let stockTypeStr =
isTractionUnit(stock.vehicleRef) || !stock.cargo
? stock.vehicleRef.type
: `${stock.vehicleRef.type}:${stock.cargo.id}`;
let stockTypeStr = isTractionUnit(stock.vehicleRef) || !stock.cargo ? stock.vehicleRef.type : `${stock.vehicleRef.type}:${stock.cargo.id}`;
if (i == 0 && (coldStartActive || doubleManningActive))
return `${stockTypeStr},${coldStartActive ? 'c' : ''}${doubleManningActive ? 'd' : ''}`;
+14
View File
@@ -101,3 +101,17 @@ export function stockSupportsColdStart(stockList: IStock[]) {
export function stockSupportsDoubleManning(stockList: IStock[]) {
return stockList.length != 0 && isTractionUnit(stockList[0].vehicleRef) && stockList[0].vehicleRef.doubleManned;
}
export function getCargoWarnings(stockList: IStock[]) {
let warnings: Set<string> = new Set();
stockList.forEach((stockVehicle) => {
if (stockVehicle.vehicleRef.group == 'wagon-freight') {
if (stockVehicle.cargo && stockVehicle.cargo.id.startsWith('wt_20')) warnings.add('warning_wt_20_pn');
else if (stockVehicle.vehicleRef.type.startsWith('WB117')) warnings.add(stockVehicle.cargo ? 'warning_un1965_twr' : 'warning_un1965_tn');
else if (stockVehicle.vehicleRef.type.startsWith('445Rb')) warnings.add(stockVehicle.cargo ? 'warning_un1202_twr' : 'warning_un1202_tn');
}
});
return warnings;
}