This repository has been archived on 2025-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
hymenobacterdotinfo/app/pods/measurements/route.js
2015-06-11 11:23:56 -08:00

49 lines
1.6 KiB
JavaScript

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({
species: this.store.findAll('species'),
strains: this.store.findAll('strain'),
characteristics: this.store.findAll('characteristic'),
});
},
setupController: function(controller, models) {
var tableAttrs = [
{ name: 'Strain', attr: 'strain.strainName' },
{ name: 'Characteristic', attr: 'characteristic.characteristicName' },
{ name: 'Value', attr: 'computedValue'}
];
controller.set('tableAttrs', tableAttrs);
controller.set('row', 'measurement-index-row');
controller.set('measurements', []);
// Set up search parameters
models.strains = models.strains.sortBy('fullName');
let strains = models.strains.map((strain)=>{
return Ember.Object.create({
val: strain.get('id'),
lab: strain.get('fullName'),
});
});
strains.unshiftObjects(Ember.Object.create({
val: 'all',
lab: 'All Strains',
}));
controller.set('strains', strains);
models.characteristics = models.characteristics.sortBy('characteristicName');
let characteristics = models.characteristics.map((characteristic)=>{
return Ember.Object.create({
val: characteristic.get('id'),
lab: characteristic.get('characteristicName'),
});
});
characteristics.unshiftObjects(Ember.Object.create({
val: 'all',
lab: 'All Characteristics',
}));
controller.set('characteristics', characteristics);
},
});