From a1e4e03b8922abef5ed9deb405db21592eb73bb8 Mon Sep 17 00:00:00 2001
From: Matthew Dillon <mrdillon@alaska.edu>
Date: Mon, 12 Oct 2015 10:20:17 -0700
Subject: [PATCH] Delete characteristic

---
 app/pods/components/delete-button/component.js      | 13 +++++++++++++
 app/pods/components/delete-button/template.hbs      |  1 +
 .../protected/characteristics/show/controller.js    | 11 +++++++++++
 .../protected/characteristics/show/template.hbs     |  2 ++
 4 files changed, 27 insertions(+)
 create mode 100644 app/pods/components/delete-button/component.js
 create mode 100644 app/pods/components/delete-button/template.hbs
 create mode 100644 app/pods/protected/characteristics/show/controller.js

diff --git a/app/pods/components/delete-button/component.js b/app/pods/components/delete-button/component.js
new file mode 100644
index 0000000..2ceca5b
--- /dev/null
+++ b/app/pods/components/delete-button/component.js
@@ -0,0 +1,13 @@
+import Ember from 'ember';
+
+export default Ember.Component.extend({
+  tagName: 'button',
+  classNames: ["button-red", "smaller"],
+
+  click: function() {
+    if (window.confirm("Do you really want to delete this?")) {
+      this.attrs.delete();
+    }
+  },
+
+});
diff --git a/app/pods/components/delete-button/template.hbs b/app/pods/components/delete-button/template.hbs
new file mode 100644
index 0000000..4b2e04f
--- /dev/null
+++ b/app/pods/components/delete-button/template.hbs
@@ -0,0 +1 @@
+Delete
diff --git a/app/pods/protected/characteristics/show/controller.js b/app/pods/protected/characteristics/show/controller.js
new file mode 100644
index 0000000..cc45d06
--- /dev/null
+++ b/app/pods/protected/characteristics/show/controller.js
@@ -0,0 +1,11 @@
+import Ember from 'ember';
+
+export default Ember.Controller.extend({
+  actions: {
+    delete: function() {
+      this.get('model').destroyRecord()
+      this.transitionToRoute('protected.characteristics.index');
+    },
+  },
+
+});
diff --git a/app/pods/protected/characteristics/show/template.hbs b/app/pods/protected/characteristics/show/template.hbs
index de81623..010a8c5 100644
--- a/app/pods/protected/characteristics/show/template.hbs
+++ b/app/pods/protected/characteristics/show/template.hbs
@@ -26,6 +26,7 @@
         <dl class="span-2">
           <dt>Measurements</dt>
           <dd>
+            <p>To add/edit/remove a measurement, please visit the strain's page (links below)</p>
             {{protected/characteristics/show/measurements-table model=model}}
           </dd>
         </dl>
@@ -54,4 +55,5 @@
   {{#link-to 'protected.characteristics.edit' model.id class="button-gray smaller"}}
     Edit
   {{/link-to}}
+  {{delete-button delete=(action 'delete')}}
 {{/if}}