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/Query-UI-Cleanup to 39d42b1
Date Wed, 02 Apr 2014 18:19:24 GMT
Repository: couchdb
Updated Branches:
  refs/heads/Query-UI-Cleanup 49a9fb809 -> 39d42b113


Added Validation and cleaned up layout a little


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

Branch: refs/heads/Query-UI-Cleanup
Commit: 39d42b113c87d7285f36db9837b7361b7c5e5a5f
Parents: 49a9fb8
Author: suelockwood <deathbear@apache.org>
Authored: Wed Apr 2 14:19:10 2014 -0400
Committer: suelockwood <deathbear@apache.org>
Committed: Wed Apr 2 14:19:10 2014 -0400

----------------------------------------------------------------------
 .../addons/documents/assets/less/documents.less |  27 +++-
 .../documents/templates/advanced_options.html   | 158 +++++++++++--------
 src/fauxton/app/addons/documents/views.js       |  88 +++++++----
 3 files changed, 173 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/39d42b11/src/fauxton/app/addons/documents/assets/less/documents.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/assets/less/documents.less b/src/fauxton/app/addons/documents/assets/less/documents.less
index 36429ff..c797d6c 100644
--- a/src/fauxton/app/addons/documents/assets/less/documents.less
+++ b/src/fauxton/app/addons/documents/assets/less/documents.less
@@ -35,12 +35,12 @@ button.beautify {
   #select-per-page {
     margin-top: 10px;
   }
-  
+
 }
 
 
 #query div.controls-group.well{
-    height: 150px;
+    height: 180px;
 }
 
 /** used in all_docs_list.html **/
@@ -103,13 +103,30 @@ button.beautify {
 }
 
 #keys-input {
-  display: inline-block;
-  width: 35%;
+  width: 100%;
 }
 
 #keys-error {
   display: inline-block;
 }
 
-
+#dashboard-upper-content{
+  .js-query-keys-wrapper{
+    padding-top: 0;
+  }
+  /** used in advanced-options.html**/
+  .custom-inputs {
+    .row-fluid{
+      padding-top: 20px;
+      .radio, .checkbox{
+        padding-left: 0;
+      }
+      .checkbox.inline,
+      #skipRows {
+        margin-bottom: 0;
+        padding: 6px;
+      }
+    }
+  }
+}
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/39d42b11/src/fauxton/app/addons/documents/templates/advanced_options.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/advanced_options.html b/src/fauxton/app/addons/documents/templates/advanced_options.html
index 321cd09..aa6db7f 100644
--- a/src/fauxton/app/addons/documents/templates/advanced_options.html
+++ b/src/fauxton/app/addons/documents/templates/advanced_options.html
@@ -17,7 +17,7 @@ the License.
 <!-- tabs for choosing Keys or Start & end -->
 
   <div class="btn-group toggle-btns">
-    <label for="showKeys" class="drop-down btn active">
+    <label for="showKeys" class="drop-down btn">
      Specific Key(s)
     </label>
     <label for="showStartEnd" class="drop-down btn">
@@ -25,7 +25,7 @@ the License.
     </label>
   </div>
 
-  <div class="controls-group well">
+  <div class="controls-group well hide js-query-keys-wrapper">
     <div class="row-fluid" id="js-showKeys">
       <div class="controls controls-row">
         <label for="keys-input" class="drop-down">A key, or an array of keys.</label>
@@ -35,10 +35,14 @@ the License.
     </div>
     <div class="row-fluid hide" id="js-showStartEnd">
       <div class="controls controls-row">
-        <label for="startkey" class="drop-down">Start key</label>
-        <input name="startkey" id="startkey" class="span6" type="text" placeholder='e.g.,
"1234"' disabled>
-        <label for="endkey" class="drop-down">End key</label>
-        <input id="endkey" name="endkey" class="span6" type="text" placeholder='e.g.,
"1234"'>
+        <div class="span6">
+          <label for="startkey" class="drop-down">Start key</label>
+          <input name="startkey" id="startkey" type="text" placeholder='e.g., "1234"'
disabled>
+        </div>
+        <div class="span6">
+          <label for="endkey" class="drop-down">End key</label>
+          <input id="endkey" name="endkey" type="text" placeholder='e.g., "1234"'>
+        </div>
       </div>
       <div class="controls controls-row checkbox inline">
         <input id="check5" name="inclusive_end" type="checkbox" value="false" disabled>
@@ -50,82 +54,100 @@ the License.
 <!-- Limit and Skip are conditional -->
 
   <div class="controls-group">
-      <label class="drop-down inline">
-        Limit:
-        <select name="limit" class="input-small">
-          <option>5</option>
-          <option>10</option>
-          <option selected="selected">20</option>
-          <option>30</option>
-          <option>50</option>
-          <option>100</option>
-		  <option>500</option>
-        </select>
-      </label>
-      <label for="skipRows" class="inline drop-down">
-        # of rows to skip"
-        <input name="skip" class="input-small" type="text" id="skipRows">
-      </label>
-
-      <div class="checkbox inline">
-        <input id="check1" type="checkbox" name="include_docs" value="true">
-        <label name="include_docs" for="check1">Include Docs (show the entire doc body)</label>
+    <div class="row-fluid">
+      <div class="span6">
+        <label class="drop-down inline">
+          Limit:
+          <select name="limit" class="input-medium">
+            <option>5</option>
+            <option>10</option>
+            <option selected="selected">20</option>
+            <option>30</option>
+            <option>50</option>
+            <option>100</option>
+  		      <option>500</option>
+          </select>
+        </label>
       </div>
+      <div class="span6">
+        <label for="skipRows" class="inline drop-down">
+          <input name="skip" class="input-small" type="text" id="skipRows">
+          # of rows to skip
 
-      <% if (hasReduce) { %>
-      <div class="checkbox inline">
-        <input id="check2" name="reduce" type="checkbox" value="true">
-        <label for="check2">Reduce</label>
+        </label>
       </div>
-      <label id="select1" class="drop-down inline">
-        Group Level:
-        <select id="select1" disabled name="group_level" class="input-small">
-          <option value="0">None</option>
-          <option value="1">1</option>
-          <option value="2">2</option>
-          <option value="3">3</option>
-          <option value="4">4</option>
-          <option value="5">5</option>
-          <option value="6">6</option>
-          <option value="7">7</option>
-          <option value="8">8</option>
-          <option value="9">9</option>
-          <option value="999" selected="selected">Exact</option>
-        </select>
-      </label>
-      <% } %>
-
-      <label id="select2" class="drop-down inline">
-        Order:
-        <select id="select2" name="descending" class="input-large">
-          <option value="false">Ascending</option>
-          <option value="true">Descending</option>
-        </select>
-      </label>
-
-      <div class="checkbox inline">
-        <input id="check6" name="update_seq" type="checkbox" value="true">
-        <label for="check6">Update Sequence</label>
+    </div>
+    <div class="row-fluid">
+      <div class="span6">
+        <label id="select2" class="drop-down inline">
+          Order:
+          <select id="select2" name="descending" class="input-medium">
+            <option value="false">Ascending</option>
+            <option value="true">Descending</option>
+          </select>
+        </label>
       </div>
-
-      <% if (showPreview) { %>
-      <div class="checkbox inline">
-        <input id="check7" name="stale" type="checkbox" value="true">
-        <label for="check7">Stale</label>
+      <div class="span6">
+        <div class="checkbox inline">
+          <input id="check6" name="update_seq" type="checkbox" value="true">
+          <label for="check6">Update Sequence</label>
+        </div>
       </div>
-      <% } %>
+    </div>
+    <div class="row-fluid">
+      <div class="span6">
+        <div class="checkbox inline">
+          <input id="check1" type="checkbox" name="include_docs" value="true">
+          <label name="include_docs" for="check1">Include Docs <small>(show the
entire doc body)</small></label>
+        </div>
+      </div>
+      <div class="span6">
+        <% if (showPreview) { %>
+        <div class="checkbox inline">
+          <input id="check7" name="stale" type="checkbox" value="true">
+          <label for="check7">Stale</label>
+        </div>
+        <% } %>
+      </div>
+    </div>
+  <% if (hasReduce) { %>
+    <div class="row-fluid">
+      <div class="span6">
+        <div class="checkbox inline">
+          <input id="check2" name="reduce" type="checkbox" value="true">
+          <label for="check2">Reduce</label>
+        </div>
+      </div>
+      <div class="span6">
+        <label id="select1" class="drop-down inline">
+          Group Level:
+          <select id="select1" disabled name="group_level" class="input-small">
+            <option value="0">None</option>
+            <option value="1">1</option>
+            <option value="2">2</option>
+            <option value="3">3</option>
+            <option value="4">4</option>
+            <option value="5">5</option>
+            <option value="6">6</option>
+            <option value="7">7</option>
+            <option value="8">8</option>
+            <option value="9">9</option>
+            <option value="999" selected="selected">Exact</option>
+          </select>
+        </label>
+      </div>
+    </div>
+  <% } %>
   </div>
 
 
 
 
+
   <div class="controls-group">
     <div class="row-fluid">
       <div id="button-options" class="controls controls-row">
         <button type="submit" class="btn btn-success">Query</button>
-        <% if (showPreview) { %>
-        <button class="btn btn-info preview">Browser Preview</button>
-        <% } %>
       </div>
     </div>
   </div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/39d42b11/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index cc23e19..700a939 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -418,7 +418,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       this.newView = options.newView || false;
       this.pagination = options.pagination;
       _.bindAll(this);
-      
+
       this._perPage = options.perPageDefault || 20;
       this.listenTo(this.collection, 'totalRows:decrement', this.render);
     },
@@ -1088,17 +1088,17 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
       "change form.js-view-query-update input": "updateFilters",
       "change form.js-view-query-update select": "updateFilters",
       "submit form.js-view-query-update": "updateView",
-      "click button.preview": "previewView",
       "click .toggle-btns > label":  "toggleQuery"
     },
 
     toggleQuery: function(e){
       e.preventDefault();
+      this.$('.js-query-keys-wrapper').removeClass("hide");
       var showFunctionName =this.$(e.currentTarget).attr("for");
       //highlight current
       this.$(".toggle-btns > label").removeClass('active');
       this.$(e.currentTarget).addClass("active");
-      
+
       this.$("[id^='js-show']").hide();
 
       //show section & disable what needs to be disabled
@@ -1148,7 +1148,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
       if (_.isUndefined(parsedValue)) {
         errorMsg = "Keys must be valid json.";
       } else if (!_.isArray(parsedValue)) {
-        errorMsg =  "Keys values must be in an array. E.g [1,2,3]"; 
+        errorMsg =  "Keys values must be in an array. E.g [1,2,3]";
       }
 
       if (errorMsg) {
@@ -1157,12 +1157,30 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
           type: "error",
           msg: errorMsg,
           clear:  false,
-          selector: '.js-keys-error'
+          selector: '.advanced-options .errors-container'
         });
         return false;
       }
 
-      return true; 
+      return true;
+    },
+    validateFields: function(params){
+      var errors = false;
+      //so ghetto. Spaghetti code.
+      for (var i= 0; i <params.length; i++){
+        if (params[i].name === "skip"){
+          if (!(/^\d+$/).test(params[i].value)){
+            var notification = FauxtonAPI.addNotification({
+              msg: "Numbers only for skip",
+              type: "warn",
+              selector: ".advanced-options .errors-container",
+              clear:  true
+            });
+            errors = true
+          }
+        }
+      }
+      return errors;
     },
     queryParams: function () {
       var $form = this.$(".js-view-query-update"),
@@ -1179,6 +1197,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
 
       if (keysParam && !this.validateKeys(keysParam)) { return false; }
 
+      if (params && this.validateFields(params)){ return false; }
+
       // Validate *key* params to ensure they're valid JSON
       var keyParams = ["keys","startkey","endkey"];
       var errorParams = _.filter(params, function(param) {
@@ -1192,6 +1212,21 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
       return {params: params, errorParams: errorParams};
     },
 
+    //these are the saaaaameeeeeeee
+    updateView: function (event) {
+      event.preventDefault();
+      var params = this.queryParams();
+      if (!params) { return;}
+      this.updateViewFn(event, params);
+    },
+
+    // previewView: function (event) {
+    //   var params = this.queryParams();
+    //   if (!params) { return;}
+    //   this.previewFn(event, params);
+    // },
+
+
     updateFilters: function(event) {
       event.preventDefault();
       var $ele = $(event.currentTarget);
@@ -1212,17 +1247,27 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
             var notification = FauxtonAPI.addNotification({
               msg: "include_docs has been disabled as you cannot include docs on a reduced
view",
               type: "warn",
-              selector: ".view.show .all-docs-list.errors-container",
+              selector: ".advanced-options .errors-container",
               clear:  true
             });
           }
           $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("select[name=group_level]").val("999").prop("disabled", true);
           $form.find("input[name=include_docs]").prop("disabled", false);
         }
         break;
+        case "skip":
+          if (!(/^\d+$/).test($ele.val())){
+            var notification = FauxtonAPI.addNotification({
+                msg: "Numbers only for skip",
+                type: "warn",
+                selector: ".advanced-options .errors-container",
+                clear:  true
+              });
+          }
+        break;
         case "include_docs":
         break;
       }
@@ -1251,8 +1296,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
           }
           this.updateFiltersFor(key, $ele);
           break;
-          case "key": 
-          case "keys": 
+          case "key":
+          case "keys":
             $form.find("textarea[name='"+key+"']").val(val);
           break;
           default:
@@ -1262,18 +1307,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
       }, this);
     },
 
-    updateView: function (event) {
-      event.preventDefault();
-      var params = this.queryParams();
-      if (!params) { return;}
-      this.updateViewFn(event, params);
-    },
 
-    previewView: function (event) {
-      var params = this.queryParams();
-      if (!params) { return;}
-      this.previewFn(event, params);
-    },
 
     serialize: function () {
       return {
@@ -1653,7 +1687,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
 
     toggleIndexNav: function (event) {
       $('#dashboard-content').scrollTop(0); //scroll up
-      
+
       var $targetId = this.$(event.target).attr('id'),
           $previousTab = this.$(this.$('li.active a').attr('href')),
           $targetTab = this.$(this.$(event.target).attr('href'));
@@ -1662,7 +1696,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
         $previousTab.removeAttr('style');
       }
       //stop polling
-      this.ddocInfoView.stopRefreshInterval(); 
+      this.ddocInfoView.stopRefreshInterval();
 
       if ($targetId === 'index-nav') {
         if (this.newView) { return; }
@@ -1674,8 +1708,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
       } else if ($targetId === "meta-nav"){
         if (!$("#ddoc-info").is(":visible")){
           this.ddocInfoView.startRefreshInterval();
-        } 
-        $targetTab.toggle('slow'); 
+        }
+        $targetTab.toggle('slow');
       } else {
         $targetTab.toggle('slow');
       }
@@ -1722,7 +1756,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
     renderDdocInfo: function(){
       if(this.ddocInfoView){
         this.ddocInfoView.remove();
-      } 
+      }
 
       if (this.newView) { return; }
       this.ddocInfoView = this.setView('#ddoc-info', new Views.DdocInfo({model: this.ddocInfo
}));
@@ -1743,7 +1777,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
         var ddocDecode = decodeURIComponent(this.ddocID);
         this.model = this.ddocs.get(ddocDecode).dDocModel();
         this.reduceFunStr = this.model.viewHasReduce(this.viewName);
-        
+
       }
 
       this.designDocSelector = this.setView('.design-doc-group', new Views.DesignDocSelector({


Mime
View raw message