- {{#each measurementsTable as |row|}}
+ {{#each sortedMeasurements as |row|}}
{{#link-to 'protected.strains.show' row.strain.id}}
@@ -16,10 +21,10 @@
{{/link-to}}
|
- {{row.measurement.value}}
+ {{row.value}}
|
- {{row.measurement.notes}}
+ {{row.notes}}
|
{{/each}}
diff --git a/app/pods/protected/strains/show/measurements-table-row/component.js b/app/pods/protected/strains/show/measurements-table-row/component.js
index d17a831..9c151fb 100644
--- a/app/pods/protected/strains/show/measurements-table-row/component.js
+++ b/app/pods/protected/strains/show/measurements-table-row/component.js
@@ -36,6 +36,10 @@ export default Ember.Component.extend({
},
delete: function() {
+ let char = this.get('row.characteristic');
+ if (char.get('isNew')) {
+ char.destroyRecord();
+ }
this.get('row').destroyRecord();
}
diff --git a/app/pods/protected/strains/show/measurements-table-row/template.hbs b/app/pods/protected/strains/show/measurements-table-row/template.hbs
index 1c6cc07..a26fef4 100644
--- a/app/pods/protected/strains/show/measurements-table-row/template.hbs
+++ b/app/pods/protected/strains/show/measurements-table-row/template.hbs
@@ -1,4 +1,5 @@
{{#if isEditing}}
+ |
{{
select-2
@@ -28,6 +29,9 @@
|
{{/if}}
{{else}}
+
+ {{{row.characteristic.characteristicTypeName}}}
+ |
{{#link-to 'protected.characteristics.show' row.characteristic.id}}
{{{row.characteristic.characteristicName}}}
diff --git a/app/pods/protected/strains/show/measurements-table/component.js b/app/pods/protected/strains/show/measurements-table/component.js
index 8d8e31d..07d94c6 100644
--- a/app/pods/protected/strains/show/measurements-table/component.js
+++ b/app/pods/protected/strains/show/measurements-table/component.js
@@ -12,6 +12,8 @@ export default Ember.Component.extend({
}.on('didInsertElement'),
sortParams: ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName'],
+ sortAsc: true,
+ paramsChanged: false,
sortedMeasurements: Ember.computed.sort('model.measurements', 'sortParams'),
actions: {
@@ -24,6 +26,22 @@ export default Ember.Component.extend({
});
this.get('model.measurements').addObject(m);
},
+
+ changeSortParam: function(col) {
+ let sort = this.get('sortAsc') ? 'asc' : 'desc';
+ let sortCol = `${col}:${sort}`;
+ this.set('sortParams', [sortCol]);
+ this.set('paramsChanged', true);
+ this.toggleProperty('sortAsc');
+ return false;
+ },
+
+ resetSortParam: function() {
+ this.set('sortParams', ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName']);
+ this.set('paramsChanged', false);
+ this.set('sortAsc', true);
+ return false;
+ },
},
});
diff --git a/app/pods/protected/strains/show/measurements-table/template.hbs b/app/pods/protected/strains/show/measurements-table/template.hbs
index 2f30a9e..a9a45dd 100644
--- a/app/pods/protected/strains/show/measurements-table/template.hbs
+++ b/app/pods/protected/strains/show/measurements-table/template.hbs
@@ -7,24 +7,32 @@
{{/if}}
{{#if measurementsPresent}}
+{{#if paramsChanged}}
+
+{{/if}}
{{#if canEdit}}
-
+
+
{{else}}
-
+
+
{{/if}}
- Characteristic |
- Value |
- Notes |
+ Type |
+ Characteristic |
+ Value |
+ Notes |
{{#if canEdit}}
Edit |
{{/if}}
diff --git a/app/pods/protected/users/edit/route.js b/app/pods/protected/users/edit/route.js
index e11116f..3a943b8 100644
--- a/app/pods/protected/users/edit/route.js
+++ b/app/pods/protected/users/edit/route.js
@@ -7,7 +7,7 @@ export default Ember.Route.extend({
let user_id = transition.params['protected.users.edit'].user_id;
this.get('session.currentUser').then((user) => {
- if (user.get('id') !== user_id || user.get('isAdmin')) {
+ if (user.get('id') !== user_id && !user.get('isAdmin')) {
this.transitionTo('protected.users.index');
}
});
diff --git a/app/pods/protected/users/show/route.js b/app/pods/protected/users/show/route.js
index e812128..33eeba7 100644
--- a/app/pods/protected/users/show/route.js
+++ b/app/pods/protected/users/show/route.js
@@ -9,7 +9,7 @@ export default Ember.Route.extend({
if (!currentUser.get('isAdmin') && currentUser.get('id') !== user_id) {
this.transitionTo('protected.users.index');
}
- })
+ });
},
model: function(params) {
diff --git a/app/pods/protected/users/user-form/component.js b/app/pods/protected/users/user-form/component.js
index d5ce463..0a706f3 100644
--- a/app/pods/protected/users/user-form/component.js
+++ b/app/pods/protected/users/user-form/component.js
@@ -1,10 +1,6 @@
import Ember from 'ember';
export default Ember.Component.extend({
- isAdmin: Ember.computed('currentUser', function() {
- return this.get('currentUser.role') == 'A';
- }),
-
roles: Ember.String.w('A R W'),
actions: {
diff --git a/app/pods/protected/users/user-form/template.hbs b/app/pods/protected/users/user-form/template.hbs
index a872aae..c6209a9 100644
--- a/app/pods/protected/users/user-form/template.hbs
+++ b/app/pods/protected/users/user-form/template.hbs
@@ -16,7 +16,7 @@
- {{#if isAdmin}}
+ {{#if session.currentUser.isAdmin}}
|