diff --git a/app/models/species.js b/app/models/species.js index f4906c8..c38f093 100644 --- a/app/models/species.js +++ b/app/models/species.js @@ -5,7 +5,7 @@ export default DS.Model.extend({ typeSpecies: DS.attr('boolean'), etymology: DS.attr('string'), genusName: DS.attr('string'), - strains: DS.hasMany('strain'), + strains: DS.hasMany('strain', { async: true }), totalStrains: DS.attr('number'), createdAt: DS.attr('date'), updatedAt: DS.attr('date'), diff --git a/app/models/strain.js b/app/models/strain.js index 71bf4ce..60d5d67 100644 --- a/app/models/strain.js +++ b/app/models/strain.js @@ -3,7 +3,7 @@ import Ember from 'ember'; export default DS.Model.extend({ measurements: DS.hasMany('measurements', { async: true }), - speciesName: DS.attr('string'), + species: DS.belongsTo('species', { async: true }), strainName: DS.attr('string'), typeStrain: DS.attr('boolean'), accessionNumbers: DS.attr('string'), diff --git a/app/routes/measurements/index.js b/app/routes/measurements/index.js index fdf177a..d1416be 100644 --- a/app/routes/measurements/index.js +++ b/app/routes/measurements/index.js @@ -2,6 +2,6 @@ import Ember from 'ember'; export default Ember.Route.extend({ model: function() { - return this.modelFor('strains/show').get('measurements'); + return this.modelFor('strains/show').strain.get('measurements'); } }); diff --git a/app/routes/strains/show.js b/app/routes/strains/show.js index 26d9f31..88ee2c8 100644 --- a/app/routes/strains/show.js +++ b/app/routes/strains/show.js @@ -1,4 +1,10 @@ import Ember from 'ember'; export default Ember.Route.extend({ + model: function(params) { + return Ember.RSVP.hash({ + strain: this.store.find('strain', params.strain_id), + species: this.store.findAll('species') + }); + } }); diff --git a/app/templates/components/scientific-name.hbs b/app/templates/components/scientific-name.hbs index 4683ffa..0c517d2 100644 --- a/app/templates/components/scientific-name.hbs +++ b/app/templates/components/scientific-name.hbs @@ -1 +1 @@ -{{strain.speciesName}} (strain {{strain.strainName}}) +{{strain.species.speciesName}} (strain {{strain.strainName}}) diff --git a/app/templates/components/strains/strain-details.hbs b/app/templates/components/strains/strain-details.hbs index 702fa1f..32d674e 100644 --- a/app/templates/components/strains/strain-details.hbs +++ b/app/templates/components/strains/strain-details.hbs @@ -14,7 +14,19 @@
Species
-
{{strain.speciesName}}
+
+ {{#if isEditing}} + {{ + view "select" + content=species + optionValuePath="content.id" + optionLabelPath="content.speciesName" + selection=strain.species + }} + {{else}} + {{strain.species.speciesName}} + {{/if}} +
Type Strain?
diff --git a/app/templates/strains/index.hbs b/app/templates/strains/index.hbs index 9d57ac1..0610774 100644 --- a/app/templates/strains/index.hbs +++ b/app/templates/strains/index.hbs @@ -19,7 +19,7 @@ {{#each strain in controller}} - {{#link-to 'measurements' strain}} + {{#link-to 'measurements' strain.id}} {{scientific-name strain=strain}} {{/link-to}} diff --git a/app/templates/strains/show.hbs b/app/templates/strains/show.hbs index dbeeba2..8827328 100644 --- a/app/templates/strains/show.hbs +++ b/app/templates/strains/show.hbs @@ -1,4 +1,4 @@ -{{strains/strain-details strain=model}} +{{strains/strain-details strain=model.strain species=model.species}}
{{outlet}} diff --git a/server/mocks/strains.js b/server/mocks/strains.js index 21c0e71..c316b57 100644 --- a/server/mocks/strains.js +++ b/server/mocks/strains.js @@ -5,7 +5,7 @@ module.exports = function(app) { var STRAINS = [ { id: 1, - speciesName: "Species One", + species: 1, strainName: "ABC", typeStrain: true, accessionNumbers: "Test Accession", @@ -23,7 +23,7 @@ module.exports = function(app) { }, { id: 2, - speciesName: "Species Two", + species: 2, strainName: "XYZ", typeStrain: false, accessionNumbers: "Test Accession", @@ -41,7 +41,7 @@ module.exports = function(app) { }, { id: 3, - speciesName: "Species Three", + species: 3, strainName: "QRS", typeStrain: true, accessionNumbers: "Test Accession", @@ -59,7 +59,7 @@ module.exports = function(app) { }, { id: 4, - speciesName: "Species Four", + species: 4, strainName: "LMN", typeStrain: true, accessionNumbers: "Test Accession",