From 876f0226ff93ef3e65c8f85a6d45b622100b7338 Mon Sep 17 00:00:00 2001 From: Nate Geslin Date: Wed, 23 Nov 2016 22:30:40 -0600 Subject: [PATCH] feature/ATC-125 - moves creation of Legs and Waypoints to constants instead of as method arguments --- CHANGELOG.md | 2 +- .../aircraft/AircraftFlightManagementSystem.js | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d252fefc..4e9afaaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ### Minor - Refactors `canvasController.canvas_draw_sids` method to use `airport.sidCollection` instead of `airport.sid` [#144](https://github.com/n8rzz/atc/issues/144) - +- Moves creation of Legs and Waypoints to constants instead of as method arguments [#135](https://github.com/n8rzz/atc/issues/135) diff --git a/src/assets/scripts/aircraft/AircraftFlightManagementSystem.js b/src/assets/scripts/aircraft/AircraftFlightManagementSystem.js index 0a0497c1..c215b22c 100644 --- a/src/assets/scripts/aircraft/AircraftFlightManagementSystem.js +++ b/src/assets/scripts/aircraft/AircraftFlightManagementSystem.js @@ -169,9 +169,10 @@ export default class AircraftFlightManagementSystem { insertWaypointHere(data) { const airport = window.airportController.airport_get(); const prev = this.currentWaypoint; + const waypointToAdd = new Waypoint(data, airport); // TODO: split this up into smaller chunks - this.currentLeg.waypoints.splice(this.current[WAYPOINT_WITHIN_LEG], 0, new Waypoint(data, airport)); + this.currentLeg.waypoints.splice(this.current[WAYPOINT_WITHIN_LEG], 0, waypointToAdd); this.update_fp_route(); // TODO: these if blocks a repeated elsewhere, perhaps currentWaypoint can handle this logic? @@ -197,8 +198,9 @@ export default class AircraftFlightManagementSystem { } const prev = this.currentWaypoint; - // TODO: split up into smaller chunks - this.legs.splice(data.firstIndex, 0, new Leg(data, this)); + const legToAdd = new Leg(data, this) + + this.legs.splice(data.firstIndex, 0, legToAdd); this.update_fp_route(); @@ -235,8 +237,9 @@ export default class AircraftFlightManagementSystem { * Insert a Leg at the end of the flightplan */ appendLeg(data) { - // TODO: split this up into smaller chunks - this.legs.push(new Leg(data, this)); + const legToAdd = new Leg(data, this); + + this.legs.push(legToAdd); this.update_fp_route(); } @@ -245,8 +248,9 @@ export default class AircraftFlightManagementSystem { */ appendWaypoint(data) { const airport = window.airportController.airport_get(); - // TODO: split this up into smaller chunks - this.currentLeg.waypoints.splice(this.current[WAYPOINT_WITHIN_LEG] + 1, 0, new Waypoint(data, airport)); + const waypointToAdd = new Waypoint(data, airport); + + this.currentLeg.waypoints.splice(this.current[WAYPOINT_WITHIN_LEG] + 1, 0, waypointToAdd); this.update_fp_route(); }