diff --git a/app/components/strains/strain-details.js b/app/components/strains/strain-details.js
index cd48959..58afb31 100644
--- a/app/components/strains/strain-details.js
+++ b/app/components/strains/strain-details.js
@@ -3,18 +3,12 @@ import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['grid-1'],
isEditing: false,
- isNew: false,
actions: {
- editStrain: function() {
- this.get('strain').get('errors').clear();
- if (this.get('isNew')) {
- this.get('strain').destroyRecord().then(this.sendAction());
- }
- this.toggleProperty('isEditing');
- this.get('strain').rollback();
+ save: function() {
+ this.sendAction('save');
+ },
+ cancel: function() {
+ this.sendAction('cancel');
},
- saveStrain: function() {
- this.get('strain').save().then(this.toggleProperty('isEditing'));
- }
}
});
diff --git a/app/controllers/strains/new.js b/app/controllers/strains/new.js
new file mode 100644
index 0000000..1bd3e90
--- /dev/null
+++ b/app/controllers/strains/new.js
@@ -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');
+ }
+ }
+});
diff --git a/app/controllers/strains/show.js b/app/controllers/strains/show.js
new file mode 100644
index 0000000..1055631
--- /dev/null
+++ b/app/controllers/strains/show.js
@@ -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');
+ }
+ }
+});
diff --git a/app/routes/strains/new.js b/app/routes/strains/new.js
index 6524edc..5b2778e 100644
--- a/app/routes/strains/new.js
+++ b/app/routes/strains/new.js
@@ -7,9 +7,7 @@ export default Ember.Route.extend({
species: this.store.findAll('species')
});
},
- actions: {
- cancelStrain: function() {
- this.transitionTo('strains.index');
- }
- }
+ setupController: function(controller, models) {
+ controller.setProperties(models);
+ },
});
diff --git a/app/routes/strains/show.js b/app/routes/strains/show.js
index 88ee2c8..9d6dccf 100644
--- a/app/routes/strains/show.js
+++ b/app/routes/strains/show.js
@@ -6,5 +6,8 @@ export default Ember.Route.extend({
strain: this.store.find('strain', params.strain_id),
species: this.store.findAll('species')
});
- }
+ },
+ setupController: function(controller, models) {
+ controller.setProperties(models);
+ },
});
diff --git a/app/templates/components/species/species-details.hbs b/app/templates/components/species/species-details.hbs
index aee7091..cd61c64 100644
--- a/app/templates/components/species/species-details.hbs
+++ b/app/templates/components/species/species-details.hbs
@@ -21,6 +21,7 @@
{{/link-to}}
{{/each}}
{{#if (can "edit species" species)}}
+
{{#link-to 'strains.new' class="button-gray smaller"}}
Add Strain
{{/link-to}}
diff --git a/app/templates/components/strains/strain-details.hbs b/app/templates/components/strains/strain-details.hbs
index ccb8f17..bb9e2b8 100644
--- a/app/templates/components/strains/strain-details.hbs
+++ b/app/templates/components/strains/strain-details.hbs
@@ -120,11 +120,11 @@