You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by cm...@apache.org on 2009/12/11 21:17:41 UTC

svn commit: r889795 - in /couchdb/trunk/share/www: database.html script/futon.browse.js style/layout.css

Author: cmlenz
Date: Fri Dec 11 20:17:40 2009
New Revision: 889795

URL: http://svn.apache.org/viewvc?rev=889795&view=rev
Log:
Futon: Allow control over the group and group_level options on reduce views.

Modified:
    couchdb/trunk/share/www/database.html
    couchdb/trunk/share/www/script/futon.browse.js
    couchdb/trunk/share/www/style/layout.css

Modified: couchdb/trunk/share/www/database.html
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/database.html?rev=889795&r1=889794&r2=889795&view=diff
==============================================================================
--- couchdb/trunk/share/www/database.html [utf-8] (original)
+++ couchdb/trunk/share/www/database.html [utf-8] Fri Dec 11 20:17:40 2009
@@ -71,6 +71,7 @@
 
         // Restore preferences/state
         $("#documents thead th.key").toggleClass("desc", $.futon.storage.get("desc"));
+        $("#grouplevel select").val($.futon.storage.get("group_level"));
         $("#reduce :checkbox")[0].checked = $.futon.storage.get("reduce");
         $("#perpage").val($.futon.storage.get("per_page"));
 
@@ -87,12 +88,20 @@
           location.href = "?" + encodeURIComponent(page.db.name) +
             (viewName ? "/" + viewName  : "");
         });
-        $("#documents thead th.key").click(function() {
-          $(this).toggleClass("desc");
+        $("#documents thead th.key span").click(function() {
+          $(this).closest("th").toggleClass("desc");
           page.updateDocumentListing();
         });
+        $("#grouplevel select").change(function() {
+          page.updateDocumentListing();
+          $.futon.storage.set("group_level", this.value);
+        });
         $("#reduce :checkbox").click(function() {
           page.updateDocumentListing();
+          var cb = this;
+          $("#grouplevel").toggleClass("disabled", !cb.checked).find("select").each(function() {
+            this.disabled = !cb.checked;
+          });
           $.futon.storage.set("reduce", this.checked);
         });
         $("#perpage").change(function() {
@@ -188,7 +197,24 @@
         <caption>Documents</caption>
         <thead>
           <tr>
-            <th class="key"><div>Key</div></th>
+            <th class="key">
+              <label id="grouplevel">
+                Grouping: <select>
+                  <option value="0">none</option>
+                  <option value="1">level 1</option>
+                  <option value="2">level 2</option>
+                  <option value="3">level 3</option>
+                  <option value="4">level 4</option>
+                  <option value="5">level 5</option>
+                  <option value="6">level 6</option>
+                  <option value="7">level 7</option>
+                  <option value="8">level 8</option>
+                  <option value="9">level 9</option>
+                  <option value="100" selected>exact</option>
+                </select>
+              </label>
+              <span>Key</span>
+            </th>
             <th class="value">
               <label id="reduce"><input type="checkbox" autocomplete="off" checked> Reduce</label>
               Value
@@ -215,12 +241,6 @@
           </tr>
         </tbody>
       </table>
-      <p id="grouptruenotice">
-        <strong>Note</strong>: Views with a reduce function will return a single row of reduced values.
-        If you are looking for the same results that you can see here in Futon,
-        add a <code>?group=true</code> parameter to your view query. Futon does
-        this automatically.
-      </p>
     </div>
   </div></body>
 </html>

Modified: couchdb/trunk/share/www/script/futon.browse.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.browse.js?rev=889795&r1=889794&r2=889795&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/futon.browse.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.browse.js [utf-8] Fri Dec 11 20:17:40 2009
@@ -104,6 +104,7 @@
         map_fun: {},
         reduce_fun: {},
         reduce: {},
+        group_level: {defaultValue: 100},
         per_page: {defaultValue: 10},
         view: {defaultValue: ""}
       });
@@ -192,14 +193,19 @@
               clearTimeout(dirtyTimeout);
               dirtyTimeout = setTimeout(function() {
                 var buttons = $("#viewcode button.save, #viewcode button.revert");
-                page.isDirty = ($("#viewcode_map").val() != page.storedViewCode.map)
-                  || ($("#viewcode_reduce").val() != (page.storedViewCode.reduce || ""))
+                var viewCode = {
+                  map: $("#viewcode_map").val(),
+                  reduce: $("#viewcode_reduce").val()
+                };
+                page.isDirty = (viewCode.map != page.storedViewCode.map)
+                  || (viewCode.reduce != (page.storedViewCode.reduce || ""))
                   || page.viewLanguage != page.storedViewLanguage;
                 if (page.isDirty) {
                   buttons.removeAttr("disabled");
                 } else {
                   buttons.attr("disabled", "disabled");
                 }
+                $("#reduce, #grouplevel").toggle(!!viewCode.reduce);
               }, 100);
             }
             $("#viewcode textarea").enableTabInsertion()
@@ -215,16 +221,14 @@
             $("#language").change(updateDirtyState);
             page.updateDocumentListing();
           });
-          $("#grouptruenotice").show();
         } else if (viewName == "_temp_view") {
           page.viewLanguage = $.futon.storage.get("language");
           page.updateViewEditor(
             $.futon.storage.get("map", templates[page.viewLanguage]),
             $.futon.storage.get("reduce")
           );
-          $("#grouptruenotice").show();
         } else {
-          $("#reduce").hide();
+          $("#grouplevel, #reduce").hide();
           page.updateDocumentListing();
         }
         page.populateLanguagesMenu();
@@ -363,7 +367,7 @@
           mapFun.split("\n").length,
           reduceFun.split("\n").length
         );
-        $("#reduce").toggle(!!reduceFun);
+        $("#reduce, #grouplevel").toggle(!!reduceFun);
         $("#viewcode textarea").attr("rows", Math.min(15, Math.max(3, lines)));
       }
 
@@ -532,7 +536,7 @@
         }
         $("#paging a").unbind();
         $("#documents").find("tbody.content").empty().end().show();
-        this.updateDesignDocLink();
+        page.updateDesignDocLink();
 
         options.success = function(resp) {
           if (resp.offset === undefined) {
@@ -659,7 +663,11 @@
             if (reduceFun) {
               $.futon.storage.set("reduce_fun", reduceFun);
               if ($("#reduce :checked").length) {
-                options.group = true;
+                var level = parseInt($("#grouplevel select").val(), 10);
+                options.group = level > 0;
+                if (options.group && level < 100) {
+                  options.group_level = level;
+                }
               } else {
                 options.reduce = false;
               }
@@ -679,7 +687,11 @@
             var currentReduceCode = $.trim($("#viewcode_reduce").val()) || null;
             if (currentReduceCode) {
               if ($("#reduce :checked").length) {
-                options.group = true;
+                var level = parseInt($("#grouplevel select").val(), 10);
+                options.group = level > 0;
+                if (options.group && level < 100) {
+                  options.group_level = level;
+                }
               } else {
                 options.reduce = false;
               }

Modified: couchdb/trunk/share/www/style/layout.css
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/style/layout.css?rev=889795&r1=889794&r2=889795&view=diff
==============================================================================
--- couchdb/trunk/share/www/style/layout.css (original)
+++ couchdb/trunk/share/www/style/layout.css Fri Dec 11 20:17:40 2009
@@ -79,18 +79,18 @@
 table.listing thead th { background: #dadada url(../image/thead.gif) repeat-x;
   border: 1px solid #a7a7a7; border-width: 0 0 1px 1px; color: #333;
   font-size: 95%; font-weight: normal; text-align: left;
-  text-shadow: #999 2px 1px 2px; text-transform: capitalize;
-  white-space: nowrap;
+  text-shadow: #999 2px 1px 2px; white-space: nowrap;
 }
 table.listing thead th:first-child { border-left: none; }
 table.listing thead th.key {
   background: #a7afb6 url(../image/thead-key.gif) 0 0 repeat-x;
   padding-top: 2px;
 }
-table.listing thead th.key div {
+table.listing thead th.key span {
   background: url(../image/order-asc.gif) 100% 3px no-repeat; cursor: pointer;
+  padding-right: 20px;
 }
-table.listing thead th.desc div {
+table.listing thead th.desc span {
   background-image: url(../image/order-desc.gif);
 }
 table.listing tbody tr th, table.listing tbody tr td { background: #feffea; }
@@ -375,10 +375,14 @@
 
 /* Documents table */
 
-#documents thead th { width: 50%; }
-#documents thead th.value label { float: right; font-size: 90%;
+#documents thead th { line-height: 150%; width: 50%; }
+#documents thead th label { color: #333; float: right; font-size: 90%;
   text-shadow: none;
 }
+#documents thead th label.disabled { color: #777; }
+#documents thead th label input { vertical-align: middle; }
+#documents thead th label input[type=range] { width: 7em; }
+#documents thead th label output { width: 4em; display: inline-block; }
 #documents tbody.content td { color: #999;
   font: normal 11px "DejaVu Sans Mono",Menlo,Courier,monospace;
 }