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() { computedValue: Ember.computed('textMeasurementType', 'txtValue', 'numValue', function() {
var val; var val;
if (this.get('computedType') == 'Fixed-text') { if (this.get('computedType') === 'Fixed-text') {
val = this.get('textMeasurementType'); val = this.get('textMeasurementType');
} else if (this.get('computedType') == 'Free-text') { } else if (this.get('computedType') === 'Free-text') {
val = this.get('txtValue'); val = this.get('txtValue');
} else if (this.get('computedType') == 'Numerical') { } else if (this.get('computedType') === 'Numerical') {
val = this.get('numValue'); val = this.get('numValue');
if (this.get('confidenceInterval')) { if (this.get('confidenceInterval')) {
val = val + ' ± ' + this.get('confidenceInterval'); val = val + ' ± ' + this.get('confidenceInterval');

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@ module.exports = function(app) {
{ {
id: 1, id: 1,
speciesName: "Species One", speciesName: "Species One",
strainName: "Strain One", strainName: "Strain 1",
strainType: "Test Type", strainType: "Test Type",
etymology: "Test Etymology", etymology: "Test Etymology",
accessionBanks: "Test Accession", accessionBanks: "Test Accession",
@ -21,7 +21,7 @@ module.exports = function(app) {
{ {
id: 2, id: 2,
speciesName: "Species Two", speciesName: "Species Two",
strainName: "Strain Two", strainName: "Strain 2",
strainType: "Test Type", strainType: "Test Type",
etymology: "Test Etymology", etymology: "Test Etymology",
accessionBanks: "Test Accession", accessionBanks: "Test Accession",
@ -36,7 +36,7 @@ module.exports = function(app) {
{ {
id: 3, id: 3,
speciesName: "Species Three", speciesName: "Species Three",
strainName: "Strain Three", strainName: "Strain 3",
strainType: "Test Type", strainType: "Test Type",
etymology: "Test Etymology", etymology: "Test Etymology",
accessionBanks: "Test Accession", accessionBanks: "Test Accession",
@ -51,7 +51,7 @@ module.exports = function(app) {
{ {
id: 4, id: 4,
speciesName: "Species Four", speciesName: "Species Four",
strainName: "Strain Four", strainName: "Strain 4",
strainType: "Test Type", strainType: "Test Type",
etymology: "Test Etymology", etymology: "Test Etymology",
accessionBanks: "Test Accession", accessionBanks: "Test Accession",

View file

@ -0,0 +1,15 @@
import {
moduleFor,
test
} from 'ember-qunit';
moduleFor('controller:measurements/index', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
// Replace this with your real tests.
test('it exists', function(assert) {
var controller = this.subject();
assert.ok(controller);
});

View file

@ -0,0 +1,15 @@
import {
moduleFor,
test
} from 'ember-qunit';
moduleFor('controller:sortable', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
// Replace this with your real tests.
test('it exists', function(assert) {
var controller = this.subject();
assert.ok(controller);
});

View file

@ -0,0 +1,15 @@
import {
moduleFor,
test
} from 'ember-qunit';
moduleFor('controller:strains/index', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
// Replace this with your real tests.
test('it exists', function(assert) {
var controller = this.subject();
assert.ok(controller);
});