Stopgap sort order + cleanup
This commit is contained in:
		
							parent
							
								
									30f8e89c40
								
							
						
					
					
						commit
						84cf7817bb
					
				
					 5 changed files with 14 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
import DS from 'ember-data';
 | 
			
		||||
import config from '../config/environment';
 | 
			
		||||
import Ember from 'ember';
 | 
			
		||||
 | 
			
		||||
export default DS.Model.extend({
 | 
			
		||||
  speciesName : DS.attr('string'),
 | 
			
		||||
| 
						 | 
				
			
			@ -14,4 +15,8 @@ export default DS.Model.extend({
 | 
			
		|||
  createdBy   : DS.attr('number'),
 | 
			
		||||
  updatedBy   : DS.attr('number'),
 | 
			
		||||
  deletedBy   : DS.attr('number'),
 | 
			
		||||
 | 
			
		||||
  speciesNameMU: function() {
 | 
			
		||||
    return Ember.String.htmlSafe(`<em>${this.get('speciesName')}</em>`);
 | 
			
		||||
  }.property('speciesName').readOnly(),
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,13 +20,9 @@ export default DS.Model.extend({
 | 
			
		|||
 | 
			
		||||
  strainNameMU: function() {
 | 
			
		||||
    let type = this.get('typeStrain') ? '<sup>T</sup>' : '';
 | 
			
		||||
    return `${this.get('strainName')}${type}`;
 | 
			
		||||
    return Ember.String.htmlSafe(`${this.get('strainName')}${type}`);
 | 
			
		||||
  }.property('strainName', 'typeStrain').readOnly(),
 | 
			
		||||
 | 
			
		||||
  fullName: function() {
 | 
			
		||||
    return `${this.get('species.speciesName')} (strain ${this.get('strainName')})`;
 | 
			
		||||
  }.property('species', 'strainName').readOnly(),
 | 
			
		||||
 | 
			
		||||
  fullNameMU: function() {
 | 
			
		||||
    return Ember.String.htmlSafe(`<em>${this.get('species.speciesName')}</em> ${this.get('strainNameMU')}`);
 | 
			
		||||
  }.property('species', 'strainNameMU').readOnly(),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,7 +16,7 @@ export default Ember.Controller.extend({
 | 
			
		|||
      selectedStrains.forEach((strain) => {
 | 
			
		||||
        let s = this.store.getById('strain', strain);
 | 
			
		||||
        strains.pushObject(s);
 | 
			
		||||
      })
 | 
			
		||||
      });
 | 
			
		||||
      this.set('strains', strains);
 | 
			
		||||
 | 
			
		||||
      this.store.find('measurement', {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,9 +11,10 @@ export default Ember.Component.extend({
 | 
			
		|||
      characteristics: this.store.findAll('characteristic'),
 | 
			
		||||
    }).then((models) => {
 | 
			
		||||
      // Set up search parameters
 | 
			
		||||
      // Clean up sort order
 | 
			
		||||
      let selects = [
 | 
			
		||||
        { model: 'species', id: 'id', text: 'speciesName',
 | 
			
		||||
          children: 'strains', cid: 'id', ctext: 'fullName' },
 | 
			
		||||
        { model: 'species', id: 'id', text: 'speciesNameMU',
 | 
			
		||||
          children: 'strains', cid: 'id', ctext: 'strainNameMU' },
 | 
			
		||||
        { model: 'characteristicTypes', id: 'id', text: 'characteristicTypeName',
 | 
			
		||||
          children: 'characteristics', cid: 'id', ctext: 'characteristicName' },
 | 
			
		||||
      ];
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +26,8 @@ export default Ember.Component.extend({
 | 
			
		|||
        models[item.model] = models[item.model].sortBy(item.text);
 | 
			
		||||
        let temp = models[item.model].map((data) => {
 | 
			
		||||
          let temp_children = [];
 | 
			
		||||
          data.get(item.children).forEach((child) => {
 | 
			
		||||
          let sorted_children = data.get(item.children).sortBy(item.ctext);
 | 
			
		||||
          sorted_children.forEach((child) => {
 | 
			
		||||
            temp_children.push({id: child.get(item.cid), text: child.get(item.ctext)});
 | 
			
		||||
          });
 | 
			
		||||
          return {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,12 +7,12 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
 | 
			
		|||
  },
 | 
			
		||||
  setupController: function(controller, model) {
 | 
			
		||||
    var tableAttrs = [
 | 
			
		||||
      { name: 'Name', attr: 'fullName' },
 | 
			
		||||
      { name: 'Name', attr: 'fullNameMU' },
 | 
			
		||||
      { name: 'Total Measurements', attr: 'totalMeasurements' }
 | 
			
		||||
    ];
 | 
			
		||||
    controller.set('model', model);
 | 
			
		||||
    controller.set('tableAttrs', tableAttrs);
 | 
			
		||||
    controller.set('row', 'strain-index-row');
 | 
			
		||||
    controller.set('sort', ['fullName']);
 | 
			
		||||
    controller.set('sort', ['fullNameMU']);
 | 
			
		||||
  },
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue