From 8276f8df5743e268981d297401e584cd5c16fb13 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 15 Jun 2015 15:24:37 -0800 Subject: [PATCH] For now just use ember-table (revisit this) --- app/models/strain.js | 3 ++- app/pods/application/view.js | 1 + app/pods/measurements/controller.js | 36 +++++++++++++++++++++++++++++ app/pods/measurements/template.hbs | 29 +++++++++-------------- bower.json | 5 +++- package.json | 1 + 6 files changed, 55 insertions(+), 20 deletions(-) diff --git a/app/models/strain.js b/app/models/strain.js index 73c9d6c..a1f86b6 100644 --- a/app/models/strain.js +++ b/app/models/strain.js @@ -1,4 +1,5 @@ import DS from 'ember-data'; +import Ember from 'ember'; export default DS.Model.extend({ measurements : DS.hasMany('measurements', { async: true }), @@ -27,6 +28,6 @@ export default DS.Model.extend({ }.property('species', 'strainName').readOnly(), fullNameMU: function() { - return `${this.get('species.speciesName')} ${this.get('strainNameMU')}`; + return Ember.String.htmlSafe(`${this.get('species.speciesName')} ${this.get('strainNameMU')}`); }.property('species', 'strainNameMU').readOnly(), }); diff --git a/app/pods/application/view.js b/app/pods/application/view.js index f5d92cd..7da9eeb 100644 --- a/app/pods/application/view.js +++ b/app/pods/application/view.js @@ -1,4 +1,5 @@ import Ember from 'ember'; +/* global FlakesFrame */ export default Ember.View.extend({ classNames: ['flakes-frame'], diff --git a/app/pods/measurements/controller.js b/app/pods/measurements/controller.js index a8c8cd0..173da75 100644 --- a/app/pods/measurements/controller.js +++ b/app/pods/measurements/controller.js @@ -1,6 +1,42 @@ import Ember from 'ember'; +import ColumnDefinition from 'ember-table/models/column-definition'; export default Ember.Controller.extend({ + measurements: [], + + measurementsEmpty: function() { + return this.get('measurements').length === 0; + }.property('measurements'), + + tableColumns: Ember.computed(function() { + let strainCol = ColumnDefinition.create({ + savedWidth: 200, + textAlign: 'text-align-left', + headerCellName: 'Strain', + contentPath: 'strain.fullNameMU', + }); + + let charCol = ColumnDefinition.create({ + savedWidth: 200, + textAlign: 'text-align-left', + headerCellName: 'Characteristic', + contentPath: 'characteristic.characteristicName', + }); + + let valCol = ColumnDefinition.create({ + savedWidth: 150, + textAlign: 'text-align-left', + headerCellName: 'Value', + contentPath: 'value', + }); + + return [strainCol, charCol, valCol]; + }), + + tableContent: Ember.computed('measurements', function() { + return this.get('measurements'); + }), + actions: { search: function() { this.store.find('measurement', { diff --git a/app/pods/measurements/template.hbs b/app/pods/measurements/template.hbs index 671e7e0..6f0d79d 100644 --- a/app/pods/measurements/template.hbs +++ b/app/pods/measurements/template.hbs @@ -41,21 +41,14 @@ - - - - - - - - - - {{#each measurements as |measurement|}} - - - - - - {{/each}} - -
StrainCharacteristicValue
{{{measurement.strain.fullNameMU}}}{{measurement.characteristic.characteristicName}}{{{measurement.value}}}
+{{#if measurementsEmpty}} + No results +{{else}} + {{ + ember-table + columns=tableColumns + content=tableContent + columnMode='fluid' + hasFooter=false + }} +{{/if}} diff --git a/bower.json b/bower.json index 6b573d8..6aa21fe 100644 --- a/bower.json +++ b/bower.json @@ -15,6 +15,9 @@ "flakes": "~1.0.0", "ember-simple-auth": "~0.8.0-beta.3", "moment": "~2.9.0", - "select2": "3.5.2" + "select2": "3.5.2", + "antiscroll": "git://github.com/azirbel/antiscroll.git#90391fb371c7be769bc32e7287c5271981428356", + "jquery-mousewheel": "~3.1.4", + "jquery-ui": "~1.11.4" } } diff --git a/package.json b/package.json index d2dc24b..daa4961 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "ember-disable-proxy-controllers": "^1.0.0", "ember-export-application-global": "^1.0.2", "ember-select-2": "1.3.0", + "ember-table": "0.5.0", "express": "^4.12.4", "glob": "^4.5.3", "jsonwebtoken": "^5.0.0",