client/src/components/Note.js
changeset 82 6f2999873343
parent 80 b3a02ea6d097
child 84 bf35a7737f94
--- a/client/src/components/Note.js	Fri Jun 23 15:21:43 2017 +0200
+++ b/client/src/components/Note.js	Fri Jun 23 15:57:35 2017 +0200
@@ -42,6 +42,13 @@
     this.setState({ edit: false })
   }
 
+  onClickClose = (e) => {
+    e.preventDefault();
+    e.stopPropagation();
+
+    this.setState({ edit: false })
+  }
+
   renderNoteContent() {
     if (this.state.edit) {
       return (
@@ -58,6 +65,22 @@
     )
   }
 
+  renderNoteRight() {
+    if (this.state.edit) {
+      return (
+        <a onClick={this.onClickClose}>
+          <span className="material-icons">close</span>
+        </a>
+      );
+    }
+
+    return (
+      <a onClick={this.onClickDelete}>
+        <span className="material-icons">delete</span>
+      </a>
+    )
+  }
+
   render() {
     return (
       <div id={"note-" + this.props.note._id} className="note" onClick={ this.enterEditMode }>
@@ -67,9 +90,7 @@
         <div className="note-margin-comment">
           <small className="text-muted">{ this.props.note.marginComment }</small>
         </div>
-        <a onClick={this.onClickDelete}>
-          <span className="material-icons">delete</span>
-        </a>
+        { this.renderNoteRight() }
       </div>
     );
   };