diff --git a/app/controllers/measurements/index.js b/app/controllers/measurements/index.js new file mode 100644 index 0000000..56363a8 --- /dev/null +++ b/app/controllers/measurements/index.js @@ -0,0 +1,5 @@ +import SortableController from '../sortable'; + +export default SortableController.extend({ + sortBy: 'characteristicName' +}); diff --git a/app/controllers/sortable.js b/app/controllers/sortable.js new file mode 100644 index 0000000..dc16f15 --- /dev/null +++ b/app/controllers/sortable.js @@ -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; + } + } +}); diff --git a/app/controllers/strains/index.js b/app/controllers/strains/index.js new file mode 100644 index 0000000..09496c9 --- /dev/null +++ b/app/controllers/strains/index.js @@ -0,0 +1,5 @@ +import SortableController from '../sortable'; + +export default SortableController.extend({ + sortBy: 'strainName', +}); diff --git a/app/models/measurement.js b/app/models/measurement.js index c66bd10..aa0e80b 100644 --- a/app/models/measurement.js +++ b/app/models/measurement.js @@ -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'); diff --git a/app/styles/app.css b/app/styles/app.css index f160708..4995509 100644 --- a/app/styles/app.css +++ b/app/styles/app.css @@ -1,3 +1,7 @@ .measurements-container { padding: 2em 0em 0em 0em; } + +.flakes-table thead tr { + cursor: pointer; +} diff --git a/app/templates/measurements/index.hbs b/app/templates/measurements/index.hbs index 0aadbb5..8d43fb7 100644 --- a/app/templates/measurements/index.hbs +++ b/app/templates/measurements/index.hbs @@ -1,15 +1,15 @@ - - - - - + + + + + - {{#each model as |measurement|}} + {{#each controller as |measurement|}} {{measurements/measurement-row measurement=measurement}} {{/each}} diff --git a/app/templates/strains/index.hbs b/app/templates/strains/index.hbs index 7363f1c..10d5fd4 100644 --- a/app/templates/strains/index.hbs +++ b/app/templates/strains/index.hbs @@ -1,15 +1,15 @@ -

Strains

-

Total strains: {{model.length}}

+

Hymenobacter Strains

+

Total strains: {{controller.length}}

CharacteristicMeasurement TypeMeasurementNotesTest MethodCharacteristicMeasurement TypeMeasurementNotesTest Method
- - + + - {{#each strain in model}} + {{#each strain in controller}} diff --git a/server/mocks/strains.js b/server/mocks/strains.js index d33efaf..5c59054 100644 --- a/server/mocks/strains.js +++ b/server/mocks/strains.js @@ -6,7 +6,7 @@ module.exports = function(app) { { id: 1, speciesName: "Species One", - strainName: "Strain One", + strainName: "Strain 1", strainType: "Test Type", etymology: "Test Etymology", accessionBanks: "Test Accession", @@ -21,7 +21,7 @@ module.exports = function(app) { { id: 2, speciesName: "Species Two", - strainName: "Strain Two", + strainName: "Strain 2", strainType: "Test Type", etymology: "Test Etymology", accessionBanks: "Test Accession", @@ -36,7 +36,7 @@ module.exports = function(app) { { id: 3, speciesName: "Species Three", - strainName: "Strain Three", + strainName: "Strain 3", strainType: "Test Type", etymology: "Test Etymology", accessionBanks: "Test Accession", @@ -51,7 +51,7 @@ module.exports = function(app) { { id: 4, speciesName: "Species Four", - strainName: "Strain Four", + strainName: "Strain 4", strainType: "Test Type", etymology: "Test Etymology", accessionBanks: "Test Accession", diff --git a/tests/unit/controllers/measurements/index-test.js b/tests/unit/controllers/measurements/index-test.js new file mode 100644 index 0000000..a5ea689 --- /dev/null +++ b/tests/unit/controllers/measurements/index-test.js @@ -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); +}); diff --git a/tests/unit/controllers/sortable-test.js b/tests/unit/controllers/sortable-test.js new file mode 100644 index 0000000..92e3747 --- /dev/null +++ b/tests/unit/controllers/sortable-test.js @@ -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); +}); diff --git a/tests/unit/controllers/strains/index-test.js b/tests/unit/controllers/strains/index-test.js new file mode 100644 index 0000000..59cba90 --- /dev/null +++ b/tests/unit/controllers/strains/index-test.js @@ -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); +});
NameMeasurementsNameMeasurements
{{link-to strain.strainName 'measurements' strain}} {{strain.totalMeasurements}}