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:
@@ -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">
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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'; // 95–100
|
||||
if (v >= 72) return 'Sehr gut'; // 72–94
|
||||
if (v >= 54) return 'Gut'; // 54–71
|
||||
@@ -700,7 +703,7 @@ export default {
|
||||
if (v >= 22) return 'Schlecht'; // 22–38
|
||||
if (v >= 6) return 'Sehr schlecht'; // 6–21
|
||||
if (v >= 1) return 'Katastrophal'; // 1–5
|
||||
return 'Unbekannt';
|
||||
return 'Katastrophal'; // 0 oder kleiner
|
||||
},
|
||||
|
||||
speedLabel(value) {
|
||||
|
||||
Reference in New Issue
Block a user