protected route
This commit is contained in:
parent
72c957f8dc
commit
eb1a8bb6e3
41 changed files with 56 additions and 43 deletions
47
app/pods/protected/compare/controller.js
Normal file
47
app/pods/protected/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);
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
11
app/pods/protected/compare/route.js
Normal file
11
app/pods/protected/compare/route.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
});
|
41
app/pods/protected/compare/template.hbs
Normal file
41
app/pods/protected/compare/template.hbs
Normal file
|
@ -0,0 +1,41 @@
|
|||
<h2>{{genus-name}} - Compare Strains</h2>
|
||||
|
||||
{{
|
||||
measurement-search-panel
|
||||
search='search'
|
||||
strainLabel='Select one or more strains'
|
||||
charLabel='Select one or more characteristics'
|
||||
}}
|
||||
|
||||
{{#if dataEmpty}}
|
||||
<div class="flakes-message information">
|
||||
Please select one or more strains and one or more characteristics.
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="overflow-div">
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Characteristic</th>
|
||||
{{#each strains as |strain|}}
|
||||
<th>
|
||||
{{#link-to 'protected.strains.show' strain.id classBinding="data.typeStrain:type-strain"}}
|
||||
{{strain.fullNameMU}}
|
||||
{{/link-to}}
|
||||
</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}}
|
Reference in a new issue