Sort by strains and measurements

This commit is contained in:
Matthew Dillon 2015-03-19 13:01:43 -08:00
parent 86b3fb46d7
commit 37becad20a
11 changed files with 95 additions and 18 deletions

View file

@ -0,0 +1,5 @@
import SortableController from '../sortable';
export default SortableController.extend({
sortBy: 'characteristicName'
});

View file

@ -0,0 +1,18 @@
import Ember from 'ember';
export default Ember.ArrayController.extend({
queryParams: ['sortBy', 'sortAscending'],
sortAscending: true,
sortBy: null, // Set in subclass
// Make sortProperties computed so that we have a nice URL using sortBy
sortProperties: Ember.computed('sortBy', function() {
return [this.get('sortBy')];
}),
actions: {
setSortBy: function(fieldName) {
this.set('sortBy', fieldName);
this.toggleProperty('sortAscending');
return false;
}
}
});

View file

@ -0,0 +1,5 @@
import SortableController from '../sortable';
export default SortableController.extend({
sortBy: 'strainName',
});

View file

@ -26,11 +26,11 @@ export default DS.Model.extend({
}),
computedValue: Ember.computed('textMeasurementType', 'txtValue', 'numValue', function() {
var val;
if (this.get('computedType') == 'Fixed-text') {
if (this.get('computedType') === 'Fixed-text') {
val = this.get('textMeasurementType');
} else if (this.get('computedType') == 'Free-text') {
} else if (this.get('computedType') === 'Free-text') {
val = this.get('txtValue');
} else if (this.get('computedType') == 'Numerical') {
} else if (this.get('computedType') === 'Numerical') {
val = this.get('numValue');
if (this.get('confidenceInterval')) {
val = val + ' ± ' + this.get('confidenceInterval');

View file

@ -1,3 +1,7 @@
.measurements-container {
padding: 2em 0em 0em 0em;
}
.flakes-table thead tr {
cursor: pointer;
}

View file

@ -1,15 +1,15 @@
<table class="flakes-table">
<thead>
<tr>
<th>Characteristic</th>
<th>Measurement Type</th>
<th>Measurement</th>
<th>Notes</th>
<th>Test Method</th>
<th {{action "setSortBy" "characteristicName"}}>Characteristic</th>
<th {{action "setSortBy" "computedType"}}>Measurement Type</th>
<th {{action "setSortBy" "computedValue"}}>Measurement</th>
<th {{action "setSortBy" "notes"}}>Notes</th>
<th {{action "setSortBy" "testMethod"}}>Test Method</th>
</tr>
</thead>
<tbody>
{{#each model as |measurement|}}
{{#each controller as |measurement|}}
{{measurements/measurement-row measurement=measurement}}
{{/each}}
</tbody>

View file

@ -1,15 +1,15 @@
<h2>Strains</h2>
<h3>Total strains: {{model.length}}</h3>
<h2>Hymenobacter Strains</h2>
<h3>Total strains: {{controller.length}}</h3>
<table class="flakes-table">
<thead>
<tr>
<th>Name</th>
<th>Measurements</th>
<th {{action "setSortBy" "strainName"}}>Name</th>
<th {{action "setSortBy" "totalMeasurements"}}>Measurements</th>
</tr>
</thead>
<tbody>
{{#each strain in model}}
{{#each strain in controller}}
<tr>
<td>{{link-to strain.strainName 'measurements' strain}}</td>
<td>{{strain.totalMeasurements}}</td>