Roughing in measurements again
This commit is contained in:
		
							parent
							
								
									6f50a381fc
								
							
						
					
					
						commit
						878e8d1b60
					
				
					 12 changed files with 127 additions and 20 deletions
				
			
		| 
						 | 
				
			
			@ -3,8 +3,8 @@ import DS from 'ember-data';
 | 
			
		|||
export default DS.Model.extend({
 | 
			
		||||
  characteristicName: DS.attr('string'),
 | 
			
		||||
  characteristicType: DS.attr('string'),
 | 
			
		||||
  strains: DS.hasMany('strain'),
 | 
			
		||||
  measurements: DS.hasMany('measurements'),
 | 
			
		||||
  strains: DS.hasMany('strain', { async: true }),
 | 
			
		||||
  measurements: DS.hasMany('measurements', { async: true }),
 | 
			
		||||
  createdAt: DS.attr('date'),
 | 
			
		||||
  updatedAt: DS.attr('date'),
 | 
			
		||||
  deletedAt: DS.attr('date'),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,8 +2,8 @@ import DS from 'ember-data';
 | 
			
		|||
import Ember from 'ember';
 | 
			
		||||
 | 
			
		||||
export default DS.Model.extend({
 | 
			
		||||
  strain: DS.belongsTo('strain'),
 | 
			
		||||
  characteristic: DS.attr('string'),
 | 
			
		||||
  strain: DS.belongsTo('strain', { async: true }),
 | 
			
		||||
  characteristic: DS.belongsTo('characteristic', { async: true }),
 | 
			
		||||
  textMeasurementType: DS.attr('string'),
 | 
			
		||||
  txtValue: DS.attr('string'),
 | 
			
		||||
  numValue: DS.attr('number'),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,9 @@
 | 
			
		|||
        {{#link-to 'characteristics' tagName='li' href=false}}
 | 
			
		||||
          {{#link-to 'characteristics'}}Characteristics{{/link-to}}
 | 
			
		||||
        {{/link-to}}
 | 
			
		||||
        {{#link-to 'measurements' tagName='li' href=false}}
 | 
			
		||||
          {{#link-to 'measurements'}}Measurements{{/link-to}}
 | 
			
		||||
        {{/link-to}}
 | 
			
		||||
        {{#link-to 'about' tagName='li' href=false}}
 | 
			
		||||
          {{#link-to 'about'}}About{{/link-to}}
 | 
			
		||||
        {{/link-to}}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								app/pods/components/measurement-index-row/component.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								app/pods/components/measurement-index-row/component.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
import Ember from 'ember';
 | 
			
		||||
 | 
			
		||||
export default Ember.Component.extend({
 | 
			
		||||
  tagName: 'tr',
 | 
			
		||||
});
 | 
			
		||||
							
								
								
									
										11
									
								
								app/pods/components/measurement-index-row/template.hbs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								app/pods/components/measurement-index-row/template.hbs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
<td>
 | 
			
		||||
  {{#link-to 'strains.show' data.strain.id}}
 | 
			
		||||
    {{scientific-name strain=data.strain}}
 | 
			
		||||
  {{/link-to}}
 | 
			
		||||
</td>
 | 
			
		||||
<td>
 | 
			
		||||
  {{data.characteristic.characteristicName}}
 | 
			
		||||
</td>
 | 
			
		||||
<td>
 | 
			
		||||
  {{{data.computedValue}}}
 | 
			
		||||
</td>
 | 
			
		||||
							
								
								
									
										21
									
								
								app/pods/measurements/route.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								app/pods/measurements/route.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
import Ember from 'ember';
 | 
			
		||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
 | 
			
		||||
 | 
			
		||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
 | 
			
		||||
  model: function() {
 | 
			
		||||
    return Ember.RSVP.hash({
 | 
			
		||||
      measurements: this.store.findAll('measurement'),
 | 
			
		||||
      species: this.store.findAll('species')
 | 
			
		||||
    });
 | 
			
		||||
  },
 | 
			
		||||
  setupController: function(controller, models) {
 | 
			
		||||
    var tableAttrs = [
 | 
			
		||||
      { name: 'Strain', attr: 'strain.strainName' },
 | 
			
		||||
      { name: 'Characteristic', attr: 'characteristic.CharacteristicName' },
 | 
			
		||||
      { name: 'Value', attr: 'computedValue'}
 | 
			
		||||
    ];
 | 
			
		||||
    controller.set('model', models);
 | 
			
		||||
    controller.set('tableAttrs', tableAttrs);
 | 
			
		||||
    controller.set('row', 'measurement-index-row');
 | 
			
		||||
  },
 | 
			
		||||
});
 | 
			
		||||
							
								
								
									
										11
									
								
								app/pods/measurements/template.hbs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								app/pods/measurements/template.hbs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
<h2>{{genus-name}} Measurements</h2>
 | 
			
		||||
<h3>Total measurements: {{model.length}}</h3>
 | 
			
		||||
 | 
			
		||||
{{
 | 
			
		||||
  view "select"
 | 
			
		||||
  content=model.species
 | 
			
		||||
  optionValuePath="content.id"
 | 
			
		||||
  optionLabelPath="content.speciesName"
 | 
			
		||||
}}
 | 
			
		||||
 | 
			
		||||
{{sortable-table content=model.measurements tableAttrs=tableAttrs row=row}}
 | 
			
		||||
| 
						 | 
				
			
			@ -20,6 +20,7 @@ Router.map(function() {
 | 
			
		|||
    this.route('show', { path: ':strain_id' });
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  this.route('measurements');
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
export default Router;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue