diff options
author | Garren Smith <garren.smith@gmail.com> | 2013-12-03 12:46:19 +0200 |
---|---|---|
committer | Garren Smith <garren.smith@gmail.com> | 2013-12-03 17:26:11 +0200 |
commit | d2f1ec7af38d57fd248a49ebd64ba7b46b0828ff (patch) | |
tree | fcace03d0e101d28ee73064bc483378acf92671d | |
parent | 08cac68b26d95b90dedadbb5d162d082226ec5ca (diff) | |
download | couchdb-d2f1ec7af38d57fd248a49ebd64ba7b46b0828ff.tar.gz |
Fauxton: Add preview to edit index and fix preview bug
-rw-r--r-- | src/fauxton/app/modules/documents/views.js | 22 | ||||
-rw-r--r-- | src/fauxton/app/templates/documents/view_editor.html | 1 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js index ffbc1d158..cf939e26b 100644 --- a/src/fauxton/app/modules/documents/views.js +++ b/src/fauxton/app/modules/documents/views.js @@ -1164,7 +1164,7 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) { "click button.save": "saveView", "click button.delete": "deleteView", "change select#reduce-function-selector": "updateReduce", - + "click button.preview": "previewView", "click #db-views-tabs-nav": 'toggleIndexNav' }, @@ -1344,10 +1344,17 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) { previewView: function(event, paramsInfo) { + event.preventDefault(); var that = this, - mapVal = this.mapEditor.getValue(), + mapVal = this.mapVal(), reduceVal = this.reduceVal(), - paramsArr = paramsInfo.params; + paramsArr = []; + + console.log(mapVal); + + if (paramsInfo && paramsInfo.params) { + paramsArr = paramsInfo.params; + } var params = _.reduce(paramsArr, function (params, param) { params[param.name] = param.value; @@ -1390,6 +1397,15 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) { return $("#reduce-function-selector").val() == "CUSTOM"; }, + mapVal: function () { + + if (this.mapEditor) { + return this.mapEditor.getValue(); + } + + return this.$('#map-function').text(); + }, + reduceVal: function() { var reduceOption = this.$('#reduce-function-selector :selected').val(), reduceVal = ""; diff --git a/src/fauxton/app/templates/documents/view_editor.html b/src/fauxton/app/templates/documents/view_editor.html index f35b8abfe..bb6e0af0b 100644 --- a/src/fauxton/app/templates/documents/view_editor.html +++ b/src/fauxton/app/templates/documents/view_editor.html @@ -67,6 +67,7 @@ the License. <div class="control-group"> <button class="button green save fonticon-circle-check">Save</button> + <button class="button btn-info preview">Preview</button> <% if (!this.newView) { %> <button class="button delete outlineGray fonticon-circle-x">Delete</button> <% } %> |