Species edit refactor

This commit is contained in:
Matthew Dillon 2015-07-06 11:02:41 -08:00
parent cdc825cc6a
commit 45223fd57f
16 changed files with 181 additions and 160 deletions

View file

@ -1,21 +1,30 @@
import Ember from 'ember';
export default Ember.Controller.extend({
isEditing: true,
actions: {
save: function() {
var species = this.get('model');
let species = this.get('model');
if (species.get('isDirty')) {
species.save();
species.save().then((species) => {
this.transitionToRoute('species.show', species.get('id'));
}, (err) => {
this.get('flashMessages').error(err.responseJSON.error);
});
} else {
this.transitionToRoute('species.index');
}
this.transitionToRoute('species.index');
},
cancel: function() {
var species = this.get('model');
let species = this.get('model');
if (species.get('isNew')) {
species.deleteRecord();
}
this.transitionToRoute('species.index');
}
}
},
},
});

View file

@ -5,9 +5,5 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
model: function() {
return this.store.createRecord('species');
},
actions: {
cancelSpecies: function() {
this.transitionTo('species.index');
}
}
});

View file

@ -1,7 +1,6 @@
{{
species-details
forms/species-form
species=model
isEditing=true
save="save"
cancel="cancel"
}}