From 84cf7817bbbc89d8c3dec5321ba6dad7c6cd1a5c Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 17 Jun 2015 16:24:10 -0800 Subject: [PATCH] Stopgap sort order + cleanup --- app/models/species.js | 5 +++++ app/models/strain.js | 6 +----- app/pods/compare/controller.js | 2 +- app/pods/components/measurement-search-panel/component.js | 8 +++++--- app/pods/strains/index/route.js | 4 ++-- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/models/species.js b/app/models/species.js index 08da3cf..8c679ee 100644 --- a/app/models/species.js +++ b/app/models/species.js @@ -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(`${this.get('speciesName')}`); + }.property('speciesName').readOnly(), }); diff --git a/app/models/strain.js b/app/models/strain.js index a1f86b6..09983a5 100644 --- a/app/models/strain.js +++ b/app/models/strain.js @@ -20,13 +20,9 @@ export default DS.Model.extend({ strainNameMU: function() { let type = this.get('typeStrain') ? 'T' : ''; - 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(`${this.get('species.speciesName')} ${this.get('strainNameMU')}`); }.property('species', 'strainNameMU').readOnly(), diff --git a/app/pods/compare/controller.js b/app/pods/compare/controller.js index fe7ebe5..c867880 100644 --- a/app/pods/compare/controller.js +++ b/app/pods/compare/controller.js @@ -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', { diff --git a/app/pods/components/measurement-search-panel/component.js b/app/pods/components/measurement-search-panel/component.js index 35aff9d..e56e6e9 100644 --- a/app/pods/components/measurement-search-panel/component.js +++ b/app/pods/components/measurement-search-panel/component.js @@ -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 { diff --git a/app/pods/strains/index/route.js b/app/pods/strains/index/route.js index d2515c6..81bcc2b 100644 --- a/app/pods/strains/index/route.js +++ b/app/pods/strains/index/route.js @@ -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']); }, });