Measurement row component
This commit is contained in:
		
							parent
							
								
									ced405cd03
								
							
						
					
					
						commit
						c68f0a0fee
					
				
					 5 changed files with 55 additions and 17 deletions
				
			
		
							
								
								
									
										6
									
								
								app/components/measurements/measurement-row.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								app/components/measurements/measurement-row.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
import Ember from 'ember';
 | 
			
		||||
 | 
			
		||||
export default Ember.Component.extend({
 | 
			
		||||
  tagName: 'tr',
 | 
			
		||||
  measurement: null, // passed in
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
import DS from 'ember-data';
 | 
			
		||||
import Ember from 'ember';
 | 
			
		||||
 | 
			
		||||
export default DS.Model.extend({
 | 
			
		||||
  strain: DS.belongsTo('strain'),
 | 
			
		||||
| 
						 | 
				
			
			@ -11,5 +12,24 @@ export default DS.Model.extend({
 | 
			
		|||
  notes: DS.attr('string'),
 | 
			
		||||
  testMethod: DS.attr('string'),
 | 
			
		||||
  createdAt: DS.attr('date'),
 | 
			
		||||
  updatedAt: DS.attr('date')
 | 
			
		||||
  updatedAt: DS.attr('date'),
 | 
			
		||||
  computedValue: Ember.computed('textMeasurementType', 'txtValue', 'numValue', function() {
 | 
			
		||||
    var val;
 | 
			
		||||
    if (this.get('textMeasurementType')) {
 | 
			
		||||
      val = this.get('textMeasurementType');
 | 
			
		||||
    } else if (this.get('txtValue')) {
 | 
			
		||||
      val = this.get('txtValue');
 | 
			
		||||
    } else if (this.get('numValue')) {
 | 
			
		||||
      val = this.get('numValue');
 | 
			
		||||
      if (this.get('confidenceInterval')) {
 | 
			
		||||
        val = val + ' ± ' + this.get('confidenceInterval');
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
      val = "error";
 | 
			
		||||
    }
 | 
			
		||||
    if (this.get('unitType')) {
 | 
			
		||||
      val = val + ' ' + this.get('unitType');
 | 
			
		||||
    }
 | 
			
		||||
    return val;
 | 
			
		||||
  })
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
<td>{{measurement.characteristic}}</td>
 | 
			
		||||
<td>{{{measurement.computedValue}}}</td>
 | 
			
		||||
<td>{{measurement.notes}}</td>
 | 
			
		||||
<td>{{measurement.testMethod}}</td>
 | 
			
		||||
| 
						 | 
				
			
			@ -2,27 +2,14 @@
 | 
			
		|||
  <thead>
 | 
			
		||||
    <tr>
 | 
			
		||||
      <th>Characteristic</th>
 | 
			
		||||
      <th>Text Meas. Type</th>
 | 
			
		||||
      <th>Text Value</th>
 | 
			
		||||
      <th>Num. Value</th>
 | 
			
		||||
      <th>Confidence Int.</th>
 | 
			
		||||
      <th>Unit</th>
 | 
			
		||||
      <th>Measurement</th>
 | 
			
		||||
      <th>Notes</th>
 | 
			
		||||
      <th>Test Method</th>
 | 
			
		||||
    </tr>
 | 
			
		||||
  </thead>
 | 
			
		||||
  <tbody>
 | 
			
		||||
    {{#each measurement in model}}
 | 
			
		||||
      <tr>
 | 
			
		||||
        <td>{{measurement.characteristic}}</td>
 | 
			
		||||
        <td>{{measurement.textMeasurementType}}</td>
 | 
			
		||||
        <td>{{measurement.txtValue}}</td>
 | 
			
		||||
        <td>{{measurement.numValue}}</td>
 | 
			
		||||
        <td>{{measurement.confidenceInterval}}</td>
 | 
			
		||||
        <td>{{measurement.unitType}}</td>
 | 
			
		||||
        <td>{{measurement.notes}}</td>
 | 
			
		||||
        <td>{{measurement.testMethod}}</td>
 | 
			
		||||
      </tr>
 | 
			
		||||
    {{#each model as |measurement|}}
 | 
			
		||||
      {{measurements/measurement-row measurement=measurement}}
 | 
			
		||||
    {{/each}}
 | 
			
		||||
  </tbody>
 | 
			
		||||
</table>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue