Repository: couchdb Updated Branches: refs/heads/Query-Options-UI cf93bbfc3 -> c567d85f1
Fix parse json Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/c567d85f Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/c567d85f Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/c567d85f Branch: refs/heads/Query-Options-UI Commit: c567d85f1544f988d65943ec04a7cc15d1e0cafa Parents: cf93bbf Author: Garren Smith <[email protected]> Authored: Thu Mar 20 15:01:06 2014 +0200 Committer: Garren Smith <[email protected]> Committed: Thu Mar 20 15:01:06 2014 +0200 ---------------------------------------------------------------------- src/fauxton/app/addons/documents/views.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/c567d85f/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 90460e2..ee6b253 100644 --- a/src/fauxton/app/addons/documents/views.js +++ b/src/fauxton/app/addons/documents/views.js @@ -1132,9 +1132,19 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum this.hasReduce = hasReduce; this.render(); }, + + parseJSON: function (value) { + try { + return JSON.parse(value); + } catch(e) { + return false; + } + }, + validateKeys: function(param){ - var parsedValue = JSON.parse(param.value); - if (!_.isArray(parsedValue)) { + var parsedValue = this.parseJSON(param.value); + if (!parsedValue || !_.isArray(parsedValue)) { + this.$('.js-keys-error').empty(); FauxtonAPI.addNotification({ type: "error", msg: "Keys values must be in an array. E.g [1,2,3]", @@ -1164,16 +1174,11 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum var keyParams = ["keys","startkey","endkey"]; var errorParams = _.filter(params, function(param) { if (_.contains(keyParams, param.name)) { - try { - JSON.parse(param.value); - return false; - } catch(e) { - return true; - } + return !!!this.parseJSON(param.value); } else { return false; } - }); + }, this); return {params: params, errorParams: errorParams}; },
