couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deathb...@apache.org
Subject couchdb commit: updated refs/heads/2129-config-edit-name to 9e1280d
Date Sat, 15 Mar 2014 01:45:05 GMT
Repository: couchdb
Updated Branches:
  refs/heads/2129-config-edit-name [created] 9e1280d3a


Edit Config name.  Needs validation.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/9e1280d3
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/9e1280d3
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/9e1280d3

Branch: refs/heads/2129-config-edit-name
Commit: 9e1280d3a6b586aa420b49c71d2f7d349d633cb2
Parents: a17bf86
Author: suelockwood <deathbear@apache.org>
Authored: Fri Mar 14 14:54:52 2014 -0400
Committer: suelockwood <deathbear@apache.org>
Committed: Fri Mar 14 21:44:52 2014 -0400

----------------------------------------------------------------------
 .../app/addons/config/templates/item.html       | 13 ++++++--
 src/fauxton/app/addons/config/views.js          | 35 +++++++++++++-------
 2 files changed, 34 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/9e1280d3/src/fauxton/app/addons/config/templates/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/templates/item.html b/src/fauxton/app/addons/config/templates/item.html
index 108fa58..8af9a50 100644
--- a/src/fauxton/app/addons/config/templates/item.html
+++ b/src/fauxton/app/addons/config/templates/item.html
@@ -17,13 +17,22 @@ the License.
 <% } else { %>
 <td></td>
 <% } %>
-<td > <%= option.name %> </td>
+<td class="js-edit-value"> 
+  <div class="js-show-value">
+    <%= option.name %>
+  </div>
+  <div class="js-edit-value-form js-hidden">
+    <input class="js-value-input" type="text" name="name" value="<%- option.name %>"
/>
+    <button class="js-save-value btn btn-success fonticon-circle-check btn-small">
</button>
+    <button class="js-cancel-value btn btn-small fonticon-circle-x"> </button>
+  </div>
+</td>
 <td class="js-edit-value">
   <div class="js-show-value">
     <%= option.value %>
   </div>
   <div class="js-edit-value-form js-hidden">
-    <input class="js-value-input" type="text" value="<%- option.value %>" />
+    <input class="js-value-input" type="text" name="value" value="<%- option.value
%>" />
     <button class="js-save-value btn btn-success fonticon-circle-check btn-small">
</button>
     <button class="js-cancel-value btn btn-small fonticon-circle-x"> </button>
   </div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9e1280d3/src/fauxton/app/addons/config/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/views.js b/src/fauxton/app/addons/config/views.js
index 0468cd1..6533c4e 100644
--- a/src/fauxton/app/addons/config/views.js
+++ b/src/fauxton/app/addons/config/views.js
@@ -45,38 +45,49 @@ function(app, FauxtonAPI, Config, Components) {
     },
 
     editValue: function (event) {
-      this.$(".js-show-value").addClass("js-hidden");
-      this.$(".js-edit-value-form").removeClass("js-hidden");
-      this.$(".js-value-input").focus();
+      this.$(event.currentTarget).find(".js-show-value").addClass("js-hidden");
+      this.$(event.currentTarget).find(".js-edit-value-form").removeClass("js-hidden");
+      this.$(event.currentTarget).find(".js-value-input").focus();
     },
 
     processKeyEvents: function (event) {
       // Enter key
       if (event.keyCode === 13) {
-        return this.saveAndRender();
+        return this.saveAndRender(event);
       }
       // Esc key
       if (event.keyCode === 27) {
-        return this.discardValue();
+        return this.discardValue(event);
       }
     },
 
     discardValue: function (event) {
-      this.$(".js-edit-value-form").addClass("js-hidden");
-      this.$(".js-show-value").removeClass("js-hidden");
+      this.$(event.currentTarget).parents('td').find(".js-edit-value-form").addClass("js-hidden");
+      this.$(event.currentTarget).parents('td').find(".js-show-value").removeClass("js-hidden");
     },
 
     cancelEdit: function (event) {
-      this.discardValue();
+      this.discardValue(event);
     },
 
     serialize: function () {
       return {option: this.model.toJSON()};
     },
-
-    saveAndRender: function () {
-      this.model.save({value: this.$(".js-value-input").val()});
-      this.render();
+    saveAndRender: function (event) {
+      var options = {};
+        $input = this.$(event.currentTarget).parents('td').find(".js-value-input");
+        options[$input.attr('name')] = $input.val();
+
+        if ($input.attr('name')==='name'){
+        var newModel = this.model.clone();
+          newModel.save(options);
+          this.model.destroy();
+          this.model = newModel;
+          this.render();
+        } else {
+        this.model.save(options);
+        this.render();
+        }
     }
 
   });


Mime
View raw message