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 2014/03/20 11:21:48 UTC
[24/26] couchdb commit: updated refs/heads/Query-Options-UI to cf93bbf
Update Keys to be JSON instead of trying to configure that for the user
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/404afec3
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/404afec3
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/404afec3
Branch: refs/heads/Query-Options-UI
Commit: 404afec3dc9550500ec13fc9a79d85c3deeec906
Parents: 89e2f75
Author: suelockwood <de...@apache.org>
Authored: Tue Mar 18 12:36:32 2014 -0400
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Mar 20 10:33:47 2014 +0200
----------------------------------------------------------------------
.../documents/templates/advanced_options.html | 2 +-
src/fauxton/app/addons/documents/views.js | 44 ++------------------
2 files changed, 4 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/404afec3/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 8e78bcb..4ca8f12 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">
http://git-wip-us.apache.org/repos/asf/couchdb/blob/404afec3/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 a94a90c..1e7addf 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;