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

@@ -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) {