diff --git a/app/pods/protected/characteristics/show/characteristic-card/component.js b/app/pods/protected/characteristics/show/characteristic-card/component.js
new file mode 100644
index 0000000..9f24911
--- /dev/null
+++ b/app/pods/protected/characteristics/show/characteristic-card/component.js
@@ -0,0 +1,14 @@
+import Ember from 'ember';
+
+const { Component } = Ember;
+
+export default Component.extend({
+ characteristic: null,
+ "on-delete": null,
+
+ actions: {
+ deleteCharacteristic: function() {
+ return this.attrs['on-delete']();
+ },
+ },
+});
diff --git a/app/pods/protected/characteristics/show/characteristic-card/template.hbs b/app/pods/protected/characteristics/show/characteristic-card/template.hbs
new file mode 100644
index 0000000..e404106
--- /dev/null
+++ b/app/pods/protected/characteristics/show/characteristic-card/template.hbs
@@ -0,0 +1,55 @@
+
+
+
+
+
+{{#if characteristic.canEdit}}
+
+ {{#link-to 'protected.characteristics.edit' characteristic.id class="button-gray smaller"}}
+ Edit
+ {{/link-to}}
+ {{delete-button delete=(action 'deleteCharacteristic')}}
+{{/if}}
diff --git a/app/pods/protected/characteristics/show/controller.js b/app/pods/protected/characteristics/show/controller.js
index 044b783..1a9315c 100644
--- a/app/pods/protected/characteristics/show/controller.js
+++ b/app/pods/protected/characteristics/show/controller.js
@@ -1,12 +1,9 @@
import Ember from 'ember';
+import DeleteModel from '../../../../mixins/delete-model';
-export default Ember.Controller.extend({
- actions: {
- delete: function() {
- this.get('model').destroyRecord().then(() => {
- this.transitionToRoute('protected.characteristics.index');
- });
- },
- },
+const { Controller } = Ember;
+export default Controller.extend(DeleteModel, {
+ // Required for DeleteModel mixin
+ transitionRoute: 'protected.characteristics.index',
});
diff --git a/app/pods/protected/characteristics/show/measurements-table/component.js b/app/pods/protected/characteristics/show/measurements-table/component.js
index 1ca9d17..96b79fc 100644
--- a/app/pods/protected/characteristics/show/measurements-table/component.js
+++ b/app/pods/protected/characteristics/show/measurements-table/component.js
@@ -1,19 +1,24 @@
import Ember from 'ember';
-export default Ember.Component.extend({
- measurementsPresent: function() {
- return this.get('model.measurements.length') > 0;
- }.property('model.measurements'),
+const { Component, computed } = Ember;
+const { sort } = computed;
+
+export default Component.extend({
+ characteristic: null,
+
+ measurementsPresent: computed('characteristic', function() {
+ return this.get('characteristic.measurements.length') > 0;
+ }),
sortParams: ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName'],
sortAsc: true,
paramsChanged: false,
- sortedMeasurements: Ember.computed.sort('model.measurements', 'sortParams'),
+ sortedMeasurements: sort('characteristic.measurements', 'sortParams'),
actions: {
changeSortParam: function(col) {
- let sort = this.get('sortAsc') ? 'asc' : 'desc';
- let sortCol = `${col}:${sort}`;
+ const sort = this.get('sortAsc') ? 'asc' : 'desc';
+ const sortCol = `${col}:${sort}`;
this.set('sortParams', [sortCol]);
this.set('paramsChanged', true);
this.toggleProperty('sortAsc');
diff --git a/app/pods/protected/characteristics/show/route.js b/app/pods/protected/characteristics/show/route.js
index f66a9c7..0f50705 100644
--- a/app/pods/protected/characteristics/show/route.js
+++ b/app/pods/protected/characteristics/show/route.js
@@ -1,8 +1,10 @@
import Ember from 'ember';
-export default Ember.Route.extend({
+const { Route } = Ember;
+
+export default Route.extend({
model: function(params) {
- return this.store.findRecord('characteristic', params.characteristic_id, { reload: true });
+ return this.store.findRecord('characteristic', params.characteristic_id);
},
});
diff --git a/app/pods/protected/characteristics/show/template.hbs b/app/pods/protected/characteristics/show/template.hbs
index c0206ee..ad4299b 100644
--- a/app/pods/protected/characteristics/show/template.hbs
+++ b/app/pods/protected/characteristics/show/template.hbs
@@ -1,55 +1,5 @@
-
-
-
-
-
-{{#if model.canEdit}}
-
- {{#link-to 'protected.characteristics.edit' model.id class="button-gray smaller"}}
- Edit
- {{/link-to}}
- {{delete-button delete=(action 'delete')}}
-{{/if}}
+{{
+ protected/characteristics/show/characteristic-card
+ characteristic=model
+ on-delete=(action 'delete')
+}}