Improve conditionLabel method in BranchView component to handle edge cases and ensure accurate state representation. Added checks for null and undefined values, and clarified the return value for zero or negative conditions.

This commit is contained in:
Torsten Schulz (local)
2025-12-22 14:54:51 +01:00
parent 7139d321ea
commit d0c73503a2
7 changed files with 53 additions and 3 deletions

View File

@@ -104,6 +104,14 @@
/>
{{ $t('falukant.branch.director.starttransport') }}
</label>
<label>
<input
type="checkbox"
v-model="director.mayRepairVehicles"
@change="saveSetting('mayRepairVehicles', director.mayRepairVehicles)"
/>
{{ $t('falukant.branch.director.repairVehicles') }}
</label>
</div>
<div class="field">

View File

@@ -232,6 +232,7 @@
"produce": "Darf produzieren",
"sell": "Darf verkaufen",
"starttransport": "Darf Transporte veranlassen",
"repairVehicles": "Darf Fahrzeuge reparieren",
"emptyTransport": {
"title": "Transport ohne Produkte",
"description": "Bewege Transportmittel von dieser Niederlassung zu einer anderen, um sie besser zu nutzen.",

View File

@@ -163,7 +163,8 @@
},
"director": {
"income": "Income",
"incomeUpdated": "Salary has been successfully updated."
"incomeUpdated": "Salary has been successfully updated.",
"repairVehicles": "May repair vehicles"
},
"vehicles": {
"cargo_cart": "Cargo cart",

View File

@@ -692,7 +692,10 @@ export default {
},
conditionLabel(value) {
const v = Number(value) || 0;
// 0 ist ein gültiger Zustand (z.B. komplett kaputt) und darf nicht als "Unbekannt" enden.
if (value === null || value === undefined) return 'Unbekannt';
const v = Number(value);
if (!Number.isFinite(v)) return 'Unbekannt';
if (v >= 95) return 'Ausgezeichnet'; // 95100
if (v >= 72) return 'Sehr gut'; // 7294
if (v >= 54) return 'Gut'; // 5471
@@ -700,7 +703,7 @@ export default {
if (v >= 22) return 'Schlecht'; // 2238
if (v >= 6) return 'Sehr schlecht'; // 621
if (v >= 1) return 'Katastrophal'; // 15
return 'Unbekannt';
return 'Katastrophal'; // 0 oder kleiner
},
speedLabel(value) {