couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [30/50] [abbrv] git commit: Initial view filter constraints
Date Mon, 11 Feb 2013 11:12:14 GMT
Initial view filter constraints


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

Branch: refs/heads/fauxton
Commit: f25958be0589248a6656810ebee188314ff6ede2
Parents: 73e69b3
Author: Russell Branca <chewbranca@gmail.com>
Authored: Tue Jan 29 12:19:56 2013 -0800
Committer: Russell Branca <chewbranca@gmail.com>
Committed: Tue Jan 29 12:19:56 2013 -0800

----------------------------------------------------------------------
 src/fauxton/app/modules/documents/views.js         |   39 ++++++++++++++-
 .../app/templates/documents/all_docs_list.html     |    6 +-
 2 files changed, 40 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f25958be/src/fauxton/app/modules/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
index f6ce4e9..c4107c4 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -216,6 +216,8 @@ function(app, FauxtonAPI, Codemirror, JSHint) {
     events: {
       "click button.all": "selectAll",
       "click button.bulk-delete": "bulkDelete",
+      "change form.view-query-update input": "updateFilters",
+      "change form.view-query-update select": "updateFilters",
       "submit form.view-query-update": "updateView"
     },
 
@@ -288,6 +290,34 @@ function(app, FauxtonAPI, Codemirror, JSHint) {
       FauxtonAPI.navigate(fragment);
     },
 
+    updateFilters: function(event) {
+      event.preventDefault();
+      var $ele = $(event.currentTarget);
+      var name = $ele.attr('name');
+      this.updateFiltersFor(name, $ele);
+    },
+
+    updateFiltersFor: function(name, $ele) {
+      var $form = $ele.parents("form.view-query-update:first");
+      switch (name) {
+        // Reduce constraints
+        //   - Can't include_docs for reduce=true
+        //   - can't include group_level for reduce=false
+        case "reduce":
+          if ($ele.prop('checked') === true) {
+            $form.find("input[name=include_docs]").prop("checked", false);
+            $form.find("input[name=include_docs]").prop("disabled", true);
+            $form.find("select[name=group_level]").prop("disabled", false);
+          } else {
+            $form.find("select[name=group_level]").prop("disabled", true);
+            $form.find("input[name=include_docs]").prop("disabled", false);
+          }
+          break;
+        case "include_docs":
+          break;
+      }
+    },
+
     /*
      * TODO: this should be reconsidered
      * This currently performs delete operations on the model level,
@@ -335,22 +365,27 @@ function(app, FauxtonAPI, Codemirror, JSHint) {
       if (this.params) {
         var $form = this.$el.find("form.view-query-update");
         _.each(this.params, function(val, key) {
+          var $ele;
           switch (key) {
             case "limit":
             case "group_level":
               $form.find("select[name='"+key+"']").val(val);
               break;
             case "include_docs":
+              $form.find("input[name='"+key+"']").prop('checked', true);
+              break;
             case "reduce":
+              $ele = $form.find("input[name='"+key+"']");
               if (val == "true") {
-                $form.find("input[name='"+key+"']").prop('checked', true);
+                $ele.prop('checked', true);
               }
+              this.updateFiltersFor(key, $ele);
               break;
             default:
               $form.find("input[name='"+key+"']").val(val);
               break;
           }
-        });
+        }, this);
       }
     }
   });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/f25958be/src/fauxton/app/templates/documents/all_docs_list.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_list.html b/src/fauxton/app/templates/documents/all_docs_list.html
index e987dff..a3536e0 100644
--- a/src/fauxton/app/templates/documents/all_docs_list.html
+++ b/src/fauxton/app/templates/documents/all_docs_list.html
@@ -33,15 +33,15 @@
                   </select>
                 </label>
                 <label class="span3 checkbox inline">
-                  <input name="include_docs" type="checkbox" id="inlineCheckbox1" value="true">
Include Docs
+                  <input name="include_docs" type="checkbox" value="true"> Include
Docs
                 </label>
                 <% if (hasReduce) { %>
                   <label class="span2 checkbox inline">
-                    <input name="reduce" type="checkbox" id="inlineCheckbox1" value="true">
Reduce
+                    <input name="reduce" type="checkbox" value="true"> Reduce
                   </label>
                   <label class="span4 inline">
                     Group Level:
-                    <select name="group_level" class="input-small">
+                    <select disabled name="group_level" class="input-small">
                       <option value="0">None</option>
                       <option value="1">1</option>
                       <option value="2">2</option>


Mime
View raw message