diff --git a/app/pods/protected/strains/show/controller.js b/app/pods/protected/strains/show/controller.js index 7128b9a..e5e3e77 100644 --- a/app/pods/protected/strains/show/controller.js +++ b/app/pods/protected/strains/show/controller.js @@ -1,12 +1,9 @@ import Ember from 'ember'; +import DeleteModel from '../../../../mixins/delete-model'; -export default Ember.Controller.extend({ - actions: { - delete: function() { - this.get('model').destroyRecord().then(() => { - this.transitionToRoute('protected.strains.index'); - }); - }, - }, +const { Controller } = Ember; +export default Controller.extend(DeleteModel, { + // Required for DeleteModel mixin + transitionRoute: 'protected.strains.index', }); diff --git a/app/pods/protected/strains/show/measurements-table-row/component.js b/app/pods/protected/strains/show/measurements-table-row/component.js index b4220cd..8ad1ba7 100644 --- a/app/pods/protected/strains/show/measurements-table-row/component.js +++ b/app/pods/protected/strains/show/measurements-table-row/component.js @@ -1,7 +1,9 @@ import Ember from 'ember'; import ajaxError from '../../../../../utils/ajax-error'; -export default Ember.Component.extend({ +const { Component } = Ember; + +export default Component.extend({ tagName: 'tr', isEditing: false, diff --git a/app/pods/protected/strains/show/measurements-table/component.js b/app/pods/protected/strains/show/measurements-table/component.js index 07d94c6..6cbf880 100644 --- a/app/pods/protected/strains/show/measurements-table/component.js +++ b/app/pods/protected/strains/show/measurements-table/component.js @@ -1,6 +1,8 @@ import Ember from 'ember'; -export default Ember.Component.extend({ +const { Component } = Ember; + +export default Component.extend({ measurementsPresent: function() { return this.get('model.measurements.length') > 0; }.property('model.measurements'), diff --git a/app/pods/protected/strains/show/route.js b/app/pods/protected/strains/show/route.js index 0a17d8b..ea320bd 100644 --- a/app/pods/protected/strains/show/route.js +++ b/app/pods/protected/strains/show/route.js @@ -1,8 +1,10 @@ import Ember from 'ember'; -export default Ember.Route.extend({ +const { Route } = Ember; + +export default Route.extend({ model: function(params) { - return this.store.findRecord('strain', params.strain_id, { reload: true }); + return this.store.findRecord('strain', params.strain_id); }, }); diff --git a/app/pods/protected/strains/show/strain-card/component.js b/app/pods/protected/strains/show/strain-card/component.js new file mode 100644 index 0000000..40802c8 --- /dev/null +++ b/app/pods/protected/strains/show/strain-card/component.js @@ -0,0 +1,14 @@ +import Ember from 'ember'; + +const { Component } = Ember; + +export default Component.extend({ + strain: null, + "on-delete": null, + + actions: { + deleteStrain: function() { + return this.attrs['on-delete'](); + }, + }, +}); diff --git a/app/pods/protected/strains/show/strain-card/template.hbs b/app/pods/protected/strains/show/strain-card/template.hbs new file mode 100644 index 0000000..989db71 --- /dev/null +++ b/app/pods/protected/strains/show/strain-card/template.hbs @@ -0,0 +1,105 @@ +
+
+ + {{strain.strainNameMU}} + + + {{! ROW 1 }} +
+
+
Species
+
+ {{#link-to 'protected.species.show' strain.species.id}} + {{strain.species.speciesNameMU}} + {{/link-to}} +
+
+
+
Type Strain?
+
+ {{if strain.typeStrain 'Yes' 'No'}} +
+
+
+ + {{! ROW 2 }} +
+
+
Accession Numbers
+
+ {{strain.accessionNumbers}} +
+
+
+
Genbank
+
+ {{genbank-url genbank=strain.genbank}} +
+
+
+
Whole Genome Sequence
+
+ {{genbank-url genbank=strain.wholeGenomeSequence}} +
+
+
+ + {{! ROW 3 }} +
+
+
Isolated From
+
+ {{{strain.isolatedFrom}}} +
+
+
+ + {{! ROW 4 }} +
+
+
Notes
+
+ {{#if strain.notes}} + {{{strain.notes}}} + {{else}} + No notes. + {{/if}} +
+
+
+ + {{! ROW 5 }} +
+
+
Characteristics
+
+ {{ + protected/strains/show/measurements-table + model=strain + canEdit=false + canAdd=false + }} +
+
+
+ + {{! ROW 6 }} +
+
+
Record Created
+
{{null-time strain.createdAt 'LL'}}
+
+
+
Record Updated
+
{{null-time strain.updatedAt 'LL'}}
+
+
+
+
+{{#if strain.canEdit}} +
+ {{#link-to 'protected.strains.edit' strain class="button-gray smaller"}} + Edit + {{/link-to}} + {{delete-button delete=(action 'deleteStrain')}} +{{/if}} diff --git a/app/pods/protected/strains/show/template.hbs b/app/pods/protected/strains/show/template.hbs index 87d5d4f..32d23d6 100644 --- a/app/pods/protected/strains/show/template.hbs +++ b/app/pods/protected/strains/show/template.hbs @@ -1,105 +1,5 @@ -
-
- - {{model.strainNameMU}} - - - {{! ROW 1 }} -
-
-
Species
-
- {{#link-to 'protected.species.show' model.species.id}} - {{model.species.speciesNameMU}} - {{/link-to}} -
-
-
-
Type Strain?
-
- {{if model.typeStrain 'Yes' 'No'}} -
-
-
- - {{! ROW 2 }} -
-
-
Accession Numbers
-
- {{model.accessionNumbers}} -
-
-
-
Genbank
-
- {{genbank-url genbank=model.genbank}} -
-
-
-
Whole Genome Sequence
-
- {{genbank-url genbank=model.wholeGenomeSequence}} -
-
-
- - {{! ROW 3 }} -
-
-
Isolated From
-
- {{{model.isolatedFrom}}} -
-
-
- - {{! ROW 4 }} -
-
-
Notes
-
- {{#if model.notes}} - {{{model.notes}}} - {{else}} - No notes. - {{/if}} -
-
-
- - {{! ROW 5 }} -
-
-
Characteristics
-
- {{ - protected/strains/show/measurements-table - model=model - canEdit=false - canAdd=false - }} -
-
-
- - {{! ROW 6 }} -
-
-
Record Created
-
{{null-time model.createdAt 'LL'}}
-
-
-
Record Updated
-
{{null-time model.updatedAt 'LL'}}
-
-
-
-
-{{#if model.canEdit}} -
- {{#link-to 'protected.strains.edit' model.id class="button-gray smaller"}} - Edit - {{/link-to}} - {{delete-button delete=(action 'delete')}} -{{/if}} +{{ + protected/strains/show/strain-card + strain=model + on-delete=(action 'delete') +}}