You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/12/03 16:26:37 UTC

[3/3] git commit: updated refs/heads/master to 862d8ae

Fauxton: hide reduce options for no reduce


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

Branch: refs/heads/master
Commit: 862d8ae43ff1f44e910669031945b40c6073a01a
Parents: 5825fe6
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Dec 3 16:54:12 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Dec 3 17:26:12 2013 +0200

----------------------------------------------------------------------
 src/fauxton/app/modules/documents/views.js | 28 ++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/862d8ae4/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 cf939e2..1fe4cb7 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -965,10 +965,11 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) {
       this.viewName = options.viewName;
       this.updateViewFn = options.updateViewFn;
       this.previewFn = options.previewFn;
-      this.hadReduce = options.hasReduce || true;
+      //this.hadReduce = options.hasReduce || true;
 
       if (typeof(options.hasReduce) === 'undefined') {
         this.hasReduce = true;
+        console.log('set true');
       } else {
         this.hasReduce = options.hasReduce;
       }
@@ -997,6 +998,11 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) {
       }
     },
 
+    renderOnUpdatehasReduce: function (hasReduce) {
+      this.hasReduce = hasReduce;
+      this.render();
+    },
+
     queryParams: function () {
       var $form = this.$(".view-query-update");
       // Ignore params without a value
@@ -1216,6 +1222,7 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) {
       var $reduceContainer = $(".control-group.reduce-function");
       if ($ele.val() == "CUSTOM") {
         this.createReduceEditor();
+        this.reduceEditor.setValue(this.langTemplates.javascript.reduce);
         $reduceContainer.show();
       } else {
         $reduceContainer.hide();
@@ -1286,6 +1293,11 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) {
             that.newView = false;
           }
 
+          if (that.reduceFunStr !== reduceVal) {
+            that.reduceFunStr = reduceVal;
+            that.advancedOptions.renderOnUpdatehasReduce(that.hasReduce()); 
+          }
+
           FauxtonAPI.triggerRouteEvent('updateAllDocs', {ddoc: ddocName, view: viewName});
 
         }, function(xhr) {
@@ -1350,8 +1362,6 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) {
       reduceVal = this.reduceVal(),
       paramsArr = [];
 
-      console.log(mapVal);
-      
       if (paramsInfo && paramsInfo.params) {
         paramsArr = paramsInfo.params;
       }
@@ -1398,7 +1408,6 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) {
     },
 
     mapVal: function () {
-
       if (this.mapEditor) {
         return this.mapEditor.getValue();
       }
@@ -1419,6 +1428,7 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) {
       return reduceVal;
     },
 
+
     hasValidCode: function() {
       return _.every(["mapEditor", "reduceEditor"], function(editorName) {
         var editor = this[editorName];
@@ -1456,7 +1466,6 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) {
         ddocName: this.model.id,
         viewName: this.viewName,
         reduceFunStr: this.reduceFunStr,
-        hasReduce: this.reduceFunStr,
         isCustomReduce: this.hasCustomReduce(),
         newView: this.newView,
         langTemplates: this.langTemplates.javascript
@@ -1467,6 +1476,10 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) {
       return this.reduceFunStr && ! _.contains(this.builtinReduces, this.reduceFunStr);
     },
 
+    hasReduce: function () {
+      return this.reduceFunStr || false;
+    },
+
     createReduceEditor: function () {
       if (this.reduceEditor) {
         this.reduceEditor.remove();
@@ -1501,13 +1514,14 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) {
         ddocName: this.model.id,
         database: this.database
       }));
-
+      
       this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({
         updateViewFn: this.updateView,
         previewFn: this.previewView,
         database: this.database,
         viewName: this.viewName,
-        ddocName: this.model.id
+        ddocName: this.model.id,
+        hasReduce: this.hasReduce
       }));
     },