From 3d07a15586178198b0d65a30e2e8c571474773fa Mon Sep 17 00:00:00 2001 From: Leonard Rapp Date: Fri, 13 Oct 2017 00:15:12 +0200 Subject: [PATCH] wip: fix comp id bug (#696) --- ember/app/components/change-aircraft-form.js | 9 +++++++++ ember/app/utils/fix-calc.js | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ember/app/components/change-aircraft-form.js b/ember/app/components/change-aircraft-form.js index 3132679092..e44d5842f0 100644 --- a/ember/app/components/change-aircraft-form.js +++ b/ember/app/components/change-aircraft-form.js @@ -24,6 +24,8 @@ export default Ember.Component.extend(Validations, { classNames: ['panel-body'], + fixCalc: null, + flightId: null, models: null, modelId: null, @@ -49,6 +51,13 @@ export default Ember.Component.extend(Validations, { try { yield this.get('ajax').request(`/api/flights/${id}/`, { method: 'POST', json }); this.get('onDidSave')(); + + let fixCalc = this.get('fixCalc'); + + fixCalc.removeFlight(id); + fixCalc.addFlightFromJSON(`/api/flights/${id}/json`); + + } catch (error) { this.set('error', error); } diff --git a/ember/app/utils/fix-calc.js b/ember/app/utils/fix-calc.js index 05a5ba784c..68f23f2a2b 100644 --- a/ember/app/utils/fix-calc.js +++ b/ember/app/utils/fix-calc.js @@ -117,6 +117,19 @@ export default Ember.Object.extend({ flights.pushObject(flight); }, + + /** + * Remove a flight from map and barogram + * @param id {int} id of flight to remove + */ + removeFlight(id) { + let flights = this.get('flights'); + + if (flights.findBy('id', id)) { + flights.removeObjects(flights.filterBy('id', id)); + } + }, + /** * Perform a JSON request to get a flight. *