summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsuelockwood <deathbear@apache.org>2014-03-18 12:36:32 -0400
committerGarren Smith <garren.smith@gmail.com>2014-03-20 10:33:47 +0200
commit404afec3dc9550500ec13fc9a79d85c3deeec906 (patch)
tree44d190f042e648038bcf01faeab0c7d865835cb1
parent89e2f752985d6eb5e09848d85b5e91ef4bf77ce9 (diff)
downloadcouchdb-404afec3dc9550500ec13fc9a79d85c3deeec906.tar.gz
Update Keys to be JSON instead of trying to configure that for the user
-rw-r--r--src/fauxton/app/addons/documents/templates/advanced_options.html2
-rw-r--r--src/fauxton/app/addons/documents/views.js44
2 files changed, 4 insertions, 42 deletions
diff --git a/src/fauxton/app/addons/documents/templates/advanced_options.html b/src/fauxton/app/addons/documents/templates/advanced_options.html
index 8e78bcba7..4ca8f12a4 100644
--- a/src/fauxton/app/addons/documents/templates/advanced_options.html
+++ b/src/fauxton/app/addons/documents/templates/advanced_options.html
@@ -28,7 +28,7 @@ the License.
<div class="controls-group well">
<div class="row-fluid" id="js-showKeys">
<div class="controls controls-row">
- <input name="keys" class="input-xxlarge" type="text" placeholder="Enter a key, or list of keys seperated by a comma.">
+ <input name="keys" class="input-xxlarge" type="text" placeholder="Enter a key, an array of keys. This must be valid JSON.">
</div>
</div>
<div class="row-fluid hide" id="js-showStartEnd">
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index a94a90c61..1e7addf9d 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1132,42 +1132,15 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
this.hasReduce = hasReduce;
this.render();
},
- getKeys: function(val){
- var keys = val.value.replace(/\s/g,"");
-
- var regKeys = keys.match(/(\[.*?\])/g);
- if (regKeys) {
- keys = regKeys;
- } else {
- keys = keys.split(',');
- }
-
- keys = _.map(keys, function (key) { return JSON.parse(key); });
-
- if (_.isArray(keys)){
- return {
- name: "keys",
- value: JSON.stringify(keys)
- };
- } else if (keys.length === 1) {
- return {
- name: "key",
- value: keys[0]
- };
- }
+ validateKeys: function(val){
+ return JSON.parse(val);
},
queryParams: function () {
- var $form = this.$(".js-view-query-update"),
- getKeys = this.getKeys;
+ var $form = this.$(".js-view-query-update");
var params = _.reduce($form.serializeArray(), function(params, param) {
if (!param.value) { return params; }
if (param.name === "limit" && param.value === 'None') { return params; }
-
- if (param.name === "keys"){
- param = getKeys(param);
- }
-
params.push(param);
return params;
}, []);
@@ -1249,17 +1222,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
}
this.updateFiltersFor(key, $ele);
break;
- case "keys":
- val = JSON.parse(val);
- var processVal = val;
- if (_.isArray(val)) {
- processVal = _.map(val, function (arr) {
- return JSON.stringify(arr);
- }).join(', ');
- }
-
- $form.find("input[name='keys']").val(processVal);
- break;
default:
$form.find("input[name='"+key+"']").val(val);
break;