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. *