Try computed properties
This commit is contained in:
		
							parent
							
								
									ab2a169114
								
							
						
					
					
						commit
						2bf7534ec4
					
				
					 3 changed files with 16 additions and 6 deletions
				
			
		| 
						 | 
					@ -1,5 +1,4 @@
 | 
				
			||||||
import DS from 'ember-data';
 | 
					import DS from 'ember-data';
 | 
				
			||||||
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 }),
 | 
				
			||||||
| 
						 | 
					@ -17,7 +16,13 @@ export default DS.Model.extend({
 | 
				
			||||||
  updatedBy: DS.attr('number'),
 | 
					  updatedBy: DS.attr('number'),
 | 
				
			||||||
  deletedBy: DS.attr('number'),
 | 
					  deletedBy: DS.attr('number'),
 | 
				
			||||||
  totalMeasurements: DS.attr('number'),
 | 
					  totalMeasurements: DS.attr('number'),
 | 
				
			||||||
  fullName: Ember.computed('species.speciesName', 'strainName', function() {
 | 
					  fullName: function() {
 | 
				
			||||||
    return this.get('species.speciesName') + ' (strain ' + this.get('strainName') + ')';
 | 
					    return `${this.get('species.speciesName')} (strain ${this.get('strainName')})`;
 | 
				
			||||||
  })
 | 
					  }.property('species', 'strainName').readOnly(),
 | 
				
			||||||
 | 
					  fullNameMU: function() {
 | 
				
			||||||
 | 
					    let species = `<em>${this.get('species.speciesName')}</em>`,
 | 
				
			||||||
 | 
					      type = this.get('typeStrain') ? '<sup>T</sup>' : '',
 | 
				
			||||||
 | 
					      strain = `(strain ${this.get('strainName')}${type})`;
 | 
				
			||||||
 | 
					    return `${species} ${strain}`;
 | 
				
			||||||
 | 
					  }.property('species', 'strainName').readOnly(),
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{{#if isLoading}}
 | 
					{{#if isLoading}}
 | 
				
			||||||
 | 
					  {{!-- This doesn't work yet --}}
 | 
				
			||||||
  {{loading-panel}}
 | 
					  {{loading-panel}}
 | 
				
			||||||
{{else}}
 | 
					{{else}}
 | 
				
			||||||
  <table class="flakes-table">
 | 
					  <table class="flakes-table">
 | 
				
			||||||
| 
						 | 
					@ -22,7 +23,11 @@
 | 
				
			||||||
    </thead>
 | 
					    </thead>
 | 
				
			||||||
    <tbody>
 | 
					    <tbody>
 | 
				
			||||||
      {{#each measurements as |measurement|}}
 | 
					      {{#each measurements as |measurement|}}
 | 
				
			||||||
        {{measurement-index-row data=measurement}}
 | 
					        <tr>
 | 
				
			||||||
 | 
					          <td>{{{measurement.strain.fullNameMU}}}</td>
 | 
				
			||||||
 | 
					          <td>{{measurement.characteristic.characteristicName}}</td>
 | 
				
			||||||
 | 
					          <td>{{{measurement.value}}}</td>
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
      {{/each}}
 | 
					      {{/each}}
 | 
				
			||||||
    </tbody>
 | 
					    </tbody>
 | 
				
			||||||
  </table>
 | 
					  </table>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
<td>
 | 
					<td>
 | 
				
			||||||
  {{#link-to 'strains.show' data.id classBinding="data.typeStrain:type-strain"}}
 | 
					  {{#link-to 'strains.show' data.id classBinding="data.typeStrain:type-strain"}}
 | 
				
			||||||
    {{scientific-name strain=data}}
 | 
					    {{{data.fullNameMU}}}
 | 
				
			||||||
  {{/link-to}}
 | 
					  {{/link-to}}
 | 
				
			||||||
</td>
 | 
					</td>
 | 
				
			||||||
<td>
 | 
					<td>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue