diff --git a/app/pods/protected/compare/controller.js b/app/pods/protected/compare/controller.js
index c867880..da7295b 100644
--- a/app/pods/protected/compare/controller.js
+++ b/app/pods/protected/compare/controller.js
@@ -1,47 +1,14 @@
import Ember from 'ember';
export default Ember.Controller.extend({
- strains: [],
- dataEmpty: true,
-
actions: {
- search: function(selectedStrains, selectedCharacteristics) {
- if (Ember.isEmpty(selectedStrains) || Ember.isEmpty(selectedCharacteristics)) {
- this.set('dataEmpty', true);
- return false;
- }
+ search: function() {
+ let query = {
+ strain_ids: this.get('selectedStrains'),
+ characteristic_ids: this.get('selectedCharacteristics'),
+ };
- let data = Ember.A();
- let strains = [];
- selectedStrains.forEach((strain) => {
- let s = this.store.getById('strain', strain);
- strains.pushObject(s);
- });
- this.set('strains', strains);
-
- this.store.find('measurement', {
- strain: selectedStrains,
- characteristic: selectedCharacteristics,
- }).then((measurements) => {
- selectedCharacteristics.forEach((characteristic) => {
- let char = this.store.getById('characteristic', characteristic);
- let row = {
- characteristic: char.get('characteristicName'),
- };
- selectedStrains.forEach((strain) => {
- let meas = measurements.filterBy('strain.id', strain)
- .filterBy('characteristic.id', characteristic);
- if (!Ember.isEmpty(meas)) {
- row[strain] = meas[0].get('value');
- } else {
- row[strain] = '';
- }
- });
- data.pushObject(row);
- });
- this.set('data', data);
- this.set('dataEmpty', false);
- });
+ this.transitionToRoute('protected.compare.results', {queryParams: query});
}
- },
+ }
});
diff --git a/app/pods/protected/compare/results/controller.js b/app/pods/protected/compare/results/controller.js
new file mode 100644
index 0000000..24fd5e7
--- /dev/null
+++ b/app/pods/protected/compare/results/controller.js
@@ -0,0 +1,50 @@
+import Ember from 'ember';
+
+export default Ember.Controller.extend({
+ queryParams: ['strain_ids', 'characteristic_ids'],
+
+ strains: function() {
+ let strains = [];
+ let strain_ids = this.get('strain_ids').split(',');
+ strain_ids.forEach((id) => {
+ strains.push(this.store.peekRecord('strain', id));
+ })
+ return strains;
+ }.property('strain_ids'),
+
+ characteristics: function() {
+ let characteristics = [];
+ let characteristic_ids = this.get('characteristic_ids').split(',');
+ characteristic_ids.forEach((id) => {
+ characteristics.push(this.store.peekRecord('characteristic', id));
+ })
+ return characteristics;
+ }.property('characteristic_ids'),
+
+ // Set up data table matrix
+ data: function() {
+ let characteristics = this.get('characteristics');
+ let strains = this.get('strains');
+ let measurements = this.get('model');
+ let data = Ember.A();
+
+ characteristics.forEach((characteristic) => {
+ let row = {
+ characteristic: characteristic.get('characteristicName'),
+ };
+
+ strains.forEach((strain) => {
+ let meas = measurements.filterBy('strain.id', strain.get('id'))
+ .filterBy('characteristic.id', characteristic.get('id'));
+ if (!Ember.isEmpty(meas)) {
+ row[strain.get('id')] = meas[0].get('value');
+ } else {
+ row[strain.get('id')] = '';
+ }
+ });
+ data.pushObject(row);
+ });
+ return data;
+ }.property('characteristics', 'strains'),
+
+});
diff --git a/app/pods/protected/compare/results/route.js b/app/pods/protected/compare/results/route.js
new file mode 100644
index 0000000..757d14d
--- /dev/null
+++ b/app/pods/protected/compare/results/route.js
@@ -0,0 +1,11 @@
+import Ember from 'ember';
+
+export default Ember.Route.extend({
+ model: function(params) {
+ let compare = this.controllerFor('protected.compare');
+ compare.set('selectedStrains', params.strain_ids);
+ compare.set('selectedCharacteristics', params.characteristic_ids);
+ return this.store.query('measurement', params);
+ },
+
+});
diff --git a/app/pods/protected/compare/results/template.hbs b/app/pods/protected/compare/results/template.hbs
new file mode 100644
index 0000000..dbed78d
--- /dev/null
+++ b/app/pods/protected/compare/results/template.hbs
@@ -0,0 +1,26 @@
+
+
+
+
+ Characteristic |
+ {{#each strains as |strain|}}
+
+ {{#link-to 'protected.strains.show' strain.id classBinding="data.typeStrain:type-strain"}}
+ {{strain.fullNameMU}}
+ {{/link-to}}
+ |
+ {{/each}}
+
+
+
+ {{#each data as |row|}}
+
+ {{row.characteristic}} |
+ {{#each strains as |strain|}}
+ {{get-property row strain.id}} |
+ {{/each}}
+
+ {{/each}}
+
+
+
diff --git a/app/pods/protected/compare/route.js b/app/pods/protected/compare/route.js
index 9ccdd56..e8a8576 100644
--- a/app/pods/protected/compare/route.js
+++ b/app/pods/protected/compare/route.js
@@ -1,11 +1,13 @@
import Ember from 'ember';
export default Ember.Route.extend({
- resetController: function(controller, isExiting /*, transition*/) {
- if (isExiting) {
- controller.set('data', null);
- controller.set('strains', null);
- controller.set('dataEmpty', true);
- }
- }
+ model: function() {
+ return this.store.findAll('characteristic');
+ },
+
+ setupController: function(controller, model) {
+ controller.set('characteristics', this.store.peekAll('characteristic'));
+ controller.set('strains', this.store.peekAll('strain'));
+ },
+
});
diff --git a/app/pods/protected/compare/template.hbs b/app/pods/protected/compare/template.hbs
index 7b40e6a..f075a52 100644
--- a/app/pods/protected/compare/template.hbs
+++ b/app/pods/protected/compare/template.hbs
@@ -1,41 +1,41 @@
{{genus-name}} - Compare Strains
-{{
- measurement-search-panel
- search='search'
- strainLabel='Select one or more strains'
- charLabel='Select one or more characteristics'
-}}
-
-{{#if dataEmpty}}
-
- Please select one or more strains and one or more characteristics.
-
-{{else}}
-
-
-
-
- Characteristic |
- {{#each strains as |strain|}}
-
- {{#link-to 'protected.strains.show' strain.id classBinding="data.typeStrain:type-strain"}}
- {{strain.fullNameMU}}
- {{/link-to}}
- |
- {{/each}}
-
-
-
- {{#each data as |row|}}
-
- {{row.characteristic}} |
- {{#each strains as |strain|}}
- {{get-property row strain.id}} |
- {{/each}}
-
- {{/each}}
-
-
+
-{{/if}}
+
+{{outlet}}
diff --git a/app/router.js b/app/router.js
index c03f534..5fb53e3 100644
--- a/app/router.js
+++ b/app/router.js
@@ -20,7 +20,10 @@ Router.map(function() {
this.route('about');
this.route('characteristics');
this.route('measurements');
- this.route('compare');
+
+ this.route('compare', function() {
+ this.route('results');
+ });
this.route('species', function() {
this.route('new');