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 Ember from 'ember';
 | 
			
		||||
 | 
			
		||||
export default DS.Model.extend({
 | 
			
		||||
  measurements: DS.hasMany('measurements', { async: true }),
 | 
			
		||||
| 
						 | 
				
			
			@ -17,7 +16,13 @@ export default DS.Model.extend({
 | 
			
		|||
  updatedBy: DS.attr('number'),
 | 
			
		||||
  deletedBy: DS.attr('number'),
 | 
			
		||||
  totalMeasurements: DS.attr('number'),
 | 
			
		||||
  fullName: Ember.computed('species.speciesName', 'strainName', function() {
 | 
			
		||||
    return this.get('species.speciesName') + ' (strain ' + this.get('strainName') + ')';
 | 
			
		||||
  })
 | 
			
		||||
  fullName: function() {
 | 
			
		||||
    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>
 | 
			
		||||
 | 
			
		||||
{{#if isLoading}}
 | 
			
		||||
  {{!-- This doesn't work yet --}}
 | 
			
		||||
  {{loading-panel}}
 | 
			
		||||
{{else}}
 | 
			
		||||
  <table class="flakes-table">
 | 
			
		||||
| 
						 | 
				
			
			@ -22,7 +23,11 @@
 | 
			
		|||
    </thead>
 | 
			
		||||
    <tbody>
 | 
			
		||||
      {{#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}}
 | 
			
		||||
    </tbody>
 | 
			
		||||
  </table>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
<td>
 | 
			
		||||
  {{#link-to 'strains.show' data.id classBinding="data.typeStrain:type-strain"}}
 | 
			
		||||
    {{scientific-name strain=data}}
 | 
			
		||||
    {{{data.fullNameMU}}}
 | 
			
		||||
  {{/link-to}}
 | 
			
		||||
</td>
 | 
			
		||||
<td>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue