couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject [05/50] [abbrv] couchdb commit: updated refs/heads/1.6.x to d2ac597
Date Tue, 01 Apr 2014 17:41:47 GMT
Edit Config name with validation.
Fix for config modal height


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

Branch: refs/heads/1.6.x
Commit: bef40dc73c72410b6d3f75d1d19c71086109c24e
Parents: 3508a90
Author: suelockwood <deathbear@apache.org>
Authored: Wed Mar 19 10:16:29 2014 -0400
Committer: suelockwood <deathbear@apache.org>
Committed: Wed Mar 19 10:26:52 2014 -0400

----------------------------------------------------------------------
 .../app/addons/config/assets/less/config.less   |  3 ++
 .../app/addons/config/templates/item.html       | 13 ++++-
 src/fauxton/app/addons/config/views.js          | 51 +++++++++++++++-----
 src/fauxton/assets/less/bootstrap/modals.less   |  2 +-
 4 files changed, 54 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/bef40dc7/src/fauxton/app/addons/config/assets/less/config.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/assets/less/config.less b/src/fauxton/app/addons/config/assets/less/config.less
index 2807708..24bbab8 100644
--- a/src/fauxton/app/addons/config/assets/less/config.less
+++ b/src/fauxton/app/addons/config/assets/less/config.less
@@ -39,6 +39,9 @@ table.config {
   tr {
     th, td {
       vertical-align: middle;
+      .btn.btn-small {
+        padding: 10px 3px;
+      }
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/couchdb/blob/bef40dc7/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/bef40dc7/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..8453d90 100644
--- a/src/fauxton/app/addons/config/views.js
+++ b/src/fauxton/app/addons/config/views.js
@@ -44,39 +44,64 @@ function(app, FauxtonAPI, Config, Components) {
       this.remove();
     },
 
+    uniqueName: function(name){
+      var section = _.findWhere(this.collection.toJSON(), {"section":this.model.get("section")});
+      
+      return _.findWhere(section.options, {name: name});
+    },
+
     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'){
+          if (this.uniqueName($input.val())){
+            this.error = FauxtonAPI.addNotification({
+                msg: "This config already exists, enter a unique name",
+                type: "error",
+                clear: true
+            });
+          } else {
+            var newModel = this.model.clone();
+              newModel.save(options);
+              this.model.destroy();
+              this.model = newModel;
+              this.render();
+          }
+        } else {
+        this.model.save(options);
+        this.render();
+        }
     }
 
   });
@@ -103,10 +128,12 @@ function(app, FauxtonAPI, Config, Components) {
                     }));
 
       this.modal.render();
+      var collection = this.collection;
 
       this.collection.each(function(config) {
         _.each(config.get("options"), function (option, index) {
           this.insertView("table.config tbody", new Views.TableRow({
+            collection: collection,
             model: new Config.OptionModel({
               section: config.get("section"),
               name: option.name,

http://git-wip-us.apache.org/repos/asf/couchdb/blob/bef40dc7/src/fauxton/assets/less/bootstrap/modals.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/modals.less b/src/fauxton/assets/less/bootstrap/modals.less
index 8e272d4..ca8f2dc 100644
--- a/src/fauxton/assets/less/bootstrap/modals.less
+++ b/src/fauxton/assets/less/bootstrap/modals.less
@@ -60,7 +60,7 @@
 .modal-body {
   position: relative;
   overflow-y: auto;
-  max-height: 400px;
+  max-height: 600px;
   padding: 15px;
 }
 // Remove bottom margin if need be


Mime
View raw message