Repository: couchdb Updated Branches: refs/heads/Query-Options-UI f0f3bd6fb -> 3a009855f
Change parseJSON to return undefined Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/3a009855 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/3a009855 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/3a009855 Branch: refs/heads/Query-Options-UI Commit: 3a009855fd0a6543f7d48eac3f913150bbb6695b Parents: f0f3bd6 Author: Garren Smith <[email protected]> Authored: Thu Mar 20 15:34:52 2014 +0200 Committer: Garren Smith <[email protected]> Committed: Thu Mar 20 15:34:52 2014 +0200 ---------------------------------------------------------------------- src/fauxton/app/addons/documents/views.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/3a009855/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 579c711..bba23af 100644 --- a/src/fauxton/app/addons/documents/views.js +++ b/src/fauxton/app/addons/documents/views.js @@ -1135,21 +1135,15 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum parseJSON: function (value) { try { - return { - value: JSON.parse(value), - error: null - }; + return JSON.parse(value); } catch(e) { - return { - error: e, - value: null - }; + return undefined; } }, validateKeys: function(param){ var parsedValue = this.parseJSON(param.value); - if (parsedValue.error || !_.isArray(parsedValue.value)) { + if (_.isUndefined(parsedValue) || !_.isArray(parsedValue)) { this.$('.js-keys-error').empty(); FauxtonAPI.addNotification({ type: "error", @@ -1179,11 +1173,11 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum // Validate *key* params to ensure they're valid JSON var keyParams = ["keys","startkey","endkey"]; var errorParams = _.filter(params, function(param) { - if (_.contains(keyParams, param.name)) { - return !!this.parseJSON(param.value).error; - } else { + if (_.contains(keyParams, param.name) && _.isUndefined(this.parseJSON(param.value))) { + return true; + } + return false; - } }, this); return {params: params, errorParams: errorParams};
