Skip to content

Commit

Permalink
wip: fix comp id bug (skylines-project#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-R committed Oct 12, 2017
1 parent 5b65189 commit 3d07a15
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ember/app/components/change-aircraft-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default Ember.Component.extend(Validations, {

classNames: ['panel-body'],

fixCalc: null,

flightId: null,
models: null,
modelId: null,
Expand All @@ -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);
}
Expand Down
13 changes: 13 additions & 0 deletions ember/app/utils/fix-calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 3d07a15

Please sign in to comment.