From 7daac21b8a29dde3967864978718ddb98259c13e Mon Sep 17 00:00:00 2001 From: Jiri Pokorny Date: Sun, 3 Dec 2023 21:53:59 +0100 Subject: [PATCH] Moved sealevels to ranges --- .../planner/src/app/altitude/altitude.component.ts | 10 +--------- projects/planner/src/app/shared/UnitConversion.ts | 3 +++ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/projects/planner/src/app/altitude/altitude.component.ts b/projects/planner/src/app/altitude/altitude.component.ts index e77d4a7b..a8cc2fae 100644 --- a/projects/planner/src/app/altitude/altitude.component.ts +++ b/projects/planner/src/app/altitude/altitude.component.ts @@ -24,10 +24,6 @@ export class AltitudeComponent implements OnInit { @Input() public altitudeForm!: FormGroup; - // TODO move to unit defaults - private metricLevels = [0, 300, 800, 1500]; - private imperialLevels = [0, 1000, 2600, 5000]; - constructor(private fb: NonNullableFormBuilder, private inputs: InputControls, private validators: ValidatorGroups, @@ -106,10 +102,6 @@ export class AltitudeComponent implements OnInit { } private selectLevels(): number[] { - if (this.units.imperialUnits) { - return this.imperialLevels; - } - - return this.metricLevels; + return this.units.ranges.altitudeLevels; } } diff --git a/projects/planner/src/app/shared/UnitConversion.ts b/projects/planner/src/app/shared/UnitConversion.ts index 54fd6a12..2bfa3b55 100644 --- a/projects/planner/src/app/shared/UnitConversion.ts +++ b/projects/planner/src/app/shared/UnitConversion.ts @@ -173,6 +173,7 @@ export interface RangeConstants { duration: [number, number]; durationLabel: string; altitude: [number, number]; + altitudeLevels: [number, number, number, number] altitudeLabel: string; altitudePressure: [number, number]; speed: [number, number]; @@ -185,6 +186,7 @@ const toLabel = (range: [number, number], unit: string): string => `${range[0]} class MetricRanges implements RangeConstants { public readonly units = new MetricUnits(); public readonly altitude: [number, number] = [0, 5000]; + public readonly altitudeLevels: [number, number, number, number] = [0, 300, 800, 1500]; public readonly altitudeLabel: string = toLabel(this.altitude, this.units.altitudeShortcut); public readonly altitudePressure: [number, number] = [0.7, 1.2]; public readonly consumed: [number, number] = [0, 350]; @@ -220,6 +222,7 @@ class MetricRanges implements RangeConstants { class ImperialRanges implements RangeConstants { public readonly units = new ImperialUnits(); public readonly altitude: [number, number] = [0, 16500]; + public readonly altitudeLevels: [number, number, number, number] = [0, 1000, 2600, 5000]; public readonly altitudeLabel: string = toLabel(this.altitude, this.units.altitudeShortcut); public readonly altitudePressure: [number, number] = [10, 18]; public readonly consumed: [number, number] = [0, 5100];