Pulling stuff back out of strain component

This commit is contained in:
Matthew Dillon 2015-06-03 13:38:40 -08:00
parent 7260b95937
commit 033ff530d2
9 changed files with 67 additions and 24 deletions

View file

@ -0,0 +1,21 @@
import Ember from 'ember';
export default Ember.Controller.extend({
isEditing: true,
actions: {
save: function() {
var strain = this.get('strain');
if (strain.get('isDirty')) {
strain.save();
}
this.transitionToRoute('strains.index');
},
cancel: function() {
var strain = this.get('strain');
if (strain.get('isNew')) {
strain.deleteRecord();
}
this.transitionToRoute('strains.index');
}
}
});

View file

@ -0,0 +1,19 @@
import Ember from 'ember';
export default Ember.Controller.extend({
isEditing: false,
actions: {
save: function() {
var strain = this.get('strain');
if (strain.get('isDirty')) {
strain.save();
}
this.toggleProperty('isEditing');
},
cancel: function() {
this.get('strain').get('errors').clear();
this.get('strain').rollback();
this.toggleProperty('isEditing');
}
}
});