Clean up strain-species relationship

This commit is contained in:
Matthew Dillon 2015-06-03 09:25:26 -08:00
parent afcf24a8d8
commit f3aaa4739d
9 changed files with 29 additions and 11 deletions

View file

@ -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'),

View file

@ -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'),

View file

@ -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');
}
});

View file

@ -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')
});
}
});

View file

@ -1 +1 @@
<em>{{strain.speciesName}}</em> (strain {{strain.strainName}})
<em>{{strain.species.speciesName}}</em> (strain {{strain.strainName}})

View file

@ -14,7 +14,19 @@
<div class="grid-4">
<dl class="span-2">
<dt>Species</dt>
<dd><em>{{strain.speciesName}}</em></dd>
<dd>
{{#if isEditing}}
{{
view "select"
content=species
optionValuePath="content.id"
optionLabelPath="content.speciesName"
selection=strain.species
}}
{{else}}
<em>{{strain.species.speciesName}}</em>
{{/if}}
</dd>
</dl>
<dl class="span-2">
<dt>Type Strain?</dt>

View file

@ -19,7 +19,7 @@
{{#each strain in controller}}
<tr>
<td>
{{#link-to 'measurements' strain}}
{{#link-to 'measurements' strain.id}}
{{scientific-name strain=strain}}
{{/link-to}}
</td>

View file

@ -1,4 +1,4 @@
{{strains/strain-details strain=model}}
{{strains/strain-details strain=model.strain species=model.species}}
<div class="measurements-container">
{{outlet}}

View file

@ -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",