Enhance vehicle speed display by adding localized labels in DirectorInfo, SaleSection, and BranchView components

This commit is contained in:
Torsten Schulz (local)
2025-12-09 11:45:35 +01:00
parent a7350282ee
commit 71c62cf5e8
5 changed files with 44 additions and 3 deletions

View File

@@ -132,7 +132,7 @@
<select v-model.number="emptyTransportForm.vehicleTypeId" @change="loadEmptyTransportRoute">
<option :value="null" disabled>{{ $t('falukant.branch.director.emptyTransport.selectVehicle') }}</option>
<option v-for="vt in vehicleTypeOptions()" :key="vt.id" :value="vt.id">
{{ $t(`falukant.branch.vehicles.${vt.tr}`) }} ({{ vt.count }} × {{ vt.capacity }})
{{ $t(`falukant.branch.vehicles.${vt.tr}`) }} ({{ vt.count }} × {{ vt.capacity }}) - {{ speedLabel(vt.speed) }}
</option>
</select>
</label>
@@ -255,6 +255,14 @@ export default {
}
},
speedLabel(value) {
const key = value == null ? 'unknown' : String(value);
const tKey = `falukant.branch.transport.speed.${key}`;
const translated = this.$t(tKey);
if (!translated || translated === tKey) return value;
return translated;
},
openNewDirectorDialog() {
console.log('openNewDirectorDialog');
this.$refs.newDirectorDialog.open(this.branchId);

View File

@@ -61,7 +61,7 @@
<select v-model.number="transportForm.vehicleTypeId" @change="() => { recalcMaxQuantity(); loadRouteInfo(); }">
<option :value="null" disabled>{{ $t('falukant.branch.sale.transportVehiclePlaceholder') }}</option>
<option v-for="vt in vehicleTypeOptions()" :key="vt.id" :value="vt.id">
{{ $t(`falukant.branch.vehicles.${vt.tr}`) }} ({{ vt.count }} × {{ vt.capacity }})
{{ $t(`falukant.branch.vehicles.${vt.tr}`) }} ({{ vt.count }} × {{ vt.capacity }}) - {{ speedLabel(vt.speed) }}
</option>
</select>
</label>
@@ -251,6 +251,13 @@
return new Date(a.eta).getTime() - new Date(b.eta).getTime();
});
},
speedLabel(value) {
const key = value == null ? 'unknown' : String(value);
const tKey = `falukant.branch.transport.speed.${key}`;
const translated = this.$t(tKey);
if (!translated || translated === tKey) return value;
return translated;
},
},
async mounted() {
await this.loadInventory();

View File

@@ -351,6 +351,13 @@
"status": "Status",
"actions": "Aktionen"
},
"speed": {
"1": "Langsam",
"2": "Mittel",
"3": "Schnell",
"4": "Sehr schnell",
"unknown": "Unbekannt"
},
"status": {
"inUse": "In Benutzung",
"building": "Im Bau",
@@ -391,6 +398,7 @@
"repairSuccess": "Fahrzeug wird repariert!",
"repairError": "Fehler beim Reparieren des Fahrzeugs."
},
"stocktype": {
"wood": "Holzlager",
"stone": "Steinlager",

View File

@@ -22,6 +22,14 @@
},
"transport": {
"waiting": "Transport waiting"
,
"speed": {
"1": "Slow",
"2": "Medium",
"3": "Fast",
"4": "Very fast",
"unknown": "Unknown"
}
},
"random_event": {
"windfall": {

View File

@@ -103,7 +103,7 @@
<td>{{ v.type.capacity }}</td>
<td>{{ conditionLabel(v.condition) }}</td>
<td>{{ v.type.transportMode }}</td>
<td>{{ v.type.speed }}</td>
<td>{{ speedLabel(v.type.speed) }}</td>
<td>{{ formatDateTime(v.availableFrom) }}</td>
<td>
<span v-if="v.status === 'travelling'">
@@ -601,6 +601,16 @@ export default {
return 'Unbekannt';
},
speedLabel(value) {
// Expect numeric speeds 1..4; provide localized labels as fallback to raw value
const key = value == null ? 'unknown' : String(value);
const tKey = `falukant.branch.transport.speed.${key}`;
const translated = this.$t(tKey);
// If translation returns the key (no translation found), fall back to the numeric value
if (!translated || translated === tKey) return value;
return translated;
},
async loadVehicles() {
if (!this.selectedBranch) return;
try {