Cleaning up new species a bit
This commit is contained in:
parent
b58e86a3fd
commit
886fda6843
9 changed files with 82 additions and 26 deletions
5
app/controllers/species/index.js
Normal file
5
app/controllers/species/index.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import SortableController from '../sortable';
|
||||
|
||||
export default SortableController.extend({
|
||||
sortBy: 'speciesName',
|
||||
});
|
21
app/controllers/species/new.js
Normal file
21
app/controllers/species/new.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
isEditing: true,
|
||||
actions: {
|
||||
save: function() {
|
||||
var species = this.get('model');
|
||||
if (species.get('isDirty')) {
|
||||
species.save();
|
||||
}
|
||||
this.transitionToRoute('species.index');
|
||||
},
|
||||
cancel: function() {
|
||||
var species = this.get('model');
|
||||
if (species.get('isNew')) {
|
||||
species.deleteRecord();
|
||||
}
|
||||
this.transitionToRoute('species.index');
|
||||
}
|
||||
}
|
||||
});
|
22
app/controllers/species/show.js
Normal file
22
app/controllers/species/show.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
isEditing: false,
|
||||
actions: {
|
||||
save: function() {
|
||||
var species = this.get('model');
|
||||
if (species.get('isDirty')) {
|
||||
species.save();
|
||||
}
|
||||
this.toggleProperty('isEditing');
|
||||
},
|
||||
cancel: function() {
|
||||
if (this.get('isEditing')) {
|
||||
var species = this.get('model');
|
||||
species.get('errors').clear();
|
||||
species.rollback();
|
||||
}
|
||||
this.toggleProperty('isEditing');
|
||||
}
|
||||
}
|
||||
});
|
Reference in a new issue