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

@ -0,0 +1,29 @@
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
save: function() {
let species = this.get('model');
if (species.get('isDirty')) {
species.save().then((species) => {
this.transitionToRoute('species.show', species.get('id'));
}, (err) => {
this.get('flashMessages').error(err.responseJSON.error);
});
} else {
this.transitionToRoute('species.show', species.get('id'));
}
},
cancel: function() {
let species = this.get('model');
species.get('errors').clear();
species.rollback();
this.transitionToRoute('species.show', species.get('id'));
},
},
});

View file

@ -0,0 +1,4 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin, {});

View file

@ -0,0 +1,6 @@
{{
forms/species-form
species=model
save="save"
cancel="cancel"
}}