Clean up strain-species relationship
This commit is contained in:
parent
afcf24a8d8
commit
f3aaa4739d
9 changed files with 29 additions and 11 deletions
|
@ -5,7 +5,7 @@ export default DS.Model.extend({
|
||||||
typeSpecies: DS.attr('boolean'),
|
typeSpecies: DS.attr('boolean'),
|
||||||
etymology: DS.attr('string'),
|
etymology: DS.attr('string'),
|
||||||
genusName: DS.attr('string'),
|
genusName: DS.attr('string'),
|
||||||
strains: DS.hasMany('strain'),
|
strains: DS.hasMany('strain', { async: true }),
|
||||||
totalStrains: DS.attr('number'),
|
totalStrains: DS.attr('number'),
|
||||||
createdAt: DS.attr('date'),
|
createdAt: DS.attr('date'),
|
||||||
updatedAt: DS.attr('date'),
|
updatedAt: DS.attr('date'),
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Ember from 'ember';
|
||||||
|
|
||||||
export default DS.Model.extend({
|
export default DS.Model.extend({
|
||||||
measurements: DS.hasMany('measurements', { async: true }),
|
measurements: DS.hasMany('measurements', { async: true }),
|
||||||
speciesName: DS.attr('string'),
|
species: DS.belongsTo('species', { async: true }),
|
||||||
strainName: DS.attr('string'),
|
strainName: DS.attr('string'),
|
||||||
typeStrain: DS.attr('boolean'),
|
typeStrain: DS.attr('boolean'),
|
||||||
accessionNumbers: DS.attr('string'),
|
accessionNumbers: DS.attr('string'),
|
||||||
|
|
|
@ -2,6 +2,6 @@ import Ember from 'ember';
|
||||||
|
|
||||||
export default Ember.Route.extend({
|
export default Ember.Route.extend({
|
||||||
model: function() {
|
model: function() {
|
||||||
return this.modelFor('strains/show').get('measurements');
|
return this.modelFor('strains/show').strain.get('measurements');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
|
|
||||||
export default Ember.Route.extend({
|
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')
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<em>{{strain.speciesName}}</em> (strain {{strain.strainName}})
|
<em>{{strain.species.speciesName}}</em> (strain {{strain.strainName}})
|
||||||
|
|
|
@ -14,7 +14,19 @@
|
||||||
<div class="grid-4">
|
<div class="grid-4">
|
||||||
<dl class="span-2">
|
<dl class="span-2">
|
||||||
<dt>Species</dt>
|
<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>
|
||||||
<dl class="span-2">
|
<dl class="span-2">
|
||||||
<dt>Type Strain?</dt>
|
<dt>Type Strain?</dt>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
{{#each strain in controller}}
|
{{#each strain in controller}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{#link-to 'measurements' strain}}
|
{{#link-to 'measurements' strain.id}}
|
||||||
{{scientific-name strain=strain}}
|
{{scientific-name strain=strain}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{{strains/strain-details strain=model}}
|
{{strains/strain-details strain=model.strain species=model.species}}
|
||||||
|
|
||||||
<div class="measurements-container">
|
<div class="measurements-container">
|
||||||
{{outlet}}
|
{{outlet}}
|
||||||
|
|
|
@ -5,7 +5,7 @@ module.exports = function(app) {
|
||||||
var STRAINS = [
|
var STRAINS = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
speciesName: "Species One",
|
species: 1,
|
||||||
strainName: "ABC",
|
strainName: "ABC",
|
||||||
typeStrain: true,
|
typeStrain: true,
|
||||||
accessionNumbers: "Test Accession",
|
accessionNumbers: "Test Accession",
|
||||||
|
@ -23,7 +23,7 @@ module.exports = function(app) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
speciesName: "Species Two",
|
species: 2,
|
||||||
strainName: "XYZ",
|
strainName: "XYZ",
|
||||||
typeStrain: false,
|
typeStrain: false,
|
||||||
accessionNumbers: "Test Accession",
|
accessionNumbers: "Test Accession",
|
||||||
|
@ -41,7 +41,7 @@ module.exports = function(app) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
speciesName: "Species Three",
|
species: 3,
|
||||||
strainName: "QRS",
|
strainName: "QRS",
|
||||||
typeStrain: true,
|
typeStrain: true,
|
||||||
accessionNumbers: "Test Accession",
|
accessionNumbers: "Test Accession",
|
||||||
|
@ -59,7 +59,7 @@ module.exports = function(app) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
speciesName: "Species Four",
|
species: 4,
|
||||||
strainName: "LMN",
|
strainName: "LMN",
|
||||||
typeStrain: true,
|
typeStrain: true,
|
||||||
accessionNumbers: "Test Accession",
|
accessionNumbers: "Test Accession",
|
||||||
|
|
Reference in a new issue