Rough cut: compare.
This commit is contained in:
parent
adda1291c6
commit
30f8e89c40
10 changed files with 140 additions and 9 deletions
|
@ -4,18 +4,21 @@
|
|||
{{/link-to}}
|
||||
{{#if session.isAuthenticated}}
|
||||
<ul>
|
||||
{{#link-to 'compare' tagName='li' href=false}}
|
||||
{{link-to 'Compare' 'compare'}}
|
||||
{{/link-to}}
|
||||
{{#link-to 'measurements' tagName='li' href=false}}
|
||||
{{link-to 'Measurements' 'measurements'}}
|
||||
{{/link-to}}
|
||||
{{#link-to 'characteristics' tagName='li' href=false}}
|
||||
{{link-to 'Characteristics' 'characteristics'}}
|
||||
{{/link-to}}
|
||||
{{#link-to 'species' tagName='li' href=false}}
|
||||
{{link-to 'Species' 'species'}}
|
||||
{{/link-to}}
|
||||
{{#link-to 'strains' tagName='li' href=false}}
|
||||
{{link-to 'Strains' 'strains'}}
|
||||
{{/link-to}}
|
||||
{{#link-to 'characteristics' tagName='li' href=false}}
|
||||
{{link-to 'Characteristics' 'characteristics'}}
|
||||
{{/link-to}}
|
||||
{{#link-to 'measurements' tagName='li' href=false}}
|
||||
{{link-to 'Measurements' 'measurements'}}
|
||||
{{/link-to}}
|
||||
{{#link-to 'about' tagName='li' href=false}}
|
||||
{{link-to 'About' 'about'}}
|
||||
{{/link-to}}
|
||||
|
|
47
app/pods/compare/controller.js
Normal file
47
app/pods/compare/controller.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
4
app/pods/compare/route.js
Normal file
4
app/pods/compare/route.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin);
|
32
app/pods/compare/template.hbs
Normal file
32
app/pods/compare/template.hbs
Normal file
|
@ -0,0 +1,32 @@
|
|||
<h2>{{genus-name}} - Compare Strains</h2>
|
||||
|
||||
{{measurement-search-panel search='search'}}
|
||||
|
||||
{{#if dataEmpty}}
|
||||
<div class="flakes-message information">
|
||||
Please select one or more strains and one or more characteristics.
|
||||
</div>
|
||||
{{else}}
|
||||
<div>
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Characteristic</th>
|
||||
{{#each strains as |strain|}}
|
||||
<th>{{strain.fullNameMU}}</th>
|
||||
{{/each}}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each data as |row|}}
|
||||
<tr>
|
||||
<td>{{row.characteristic}}</td>
|
||||
{{#each strains as |strain|}}
|
||||
<td>{{get-property row strain.id}}</td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{/if}}
|
|
@ -1,4 +1,8 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin);
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
beforeModel: function() {
|
||||
this.transitionTo('compare');
|
||||
}
|
||||
});
|
||||
|
|
Reference in a new issue