summaryrefslogtreecommitdiff
path: root/share/www/script
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@apache.org>2009-07-21 21:42:59 +0000
committerChristopher Lenz <cmlenz@apache.org>2009-07-21 21:42:59 +0000
commitf4aa228848f8b465ae5ea3088ef02a04051feeac (patch)
treed0514181c6fc286ad2e2862a4066121c0bd31c42 /share/www/script
parentd82348e48cfbed9542613863d053fcd3ef981ff4 (diff)
Fix for COUCHDB-318: when adding or renaming a field in Futon, check that a field with the same name does not already exist.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@796548 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r--share/www/script/futon.browse.js12
-rw-r--r--share/www/script/jquery.editinline.js2
2 files changed, 12 insertions, 2 deletions
diff --git a/share/www/script/futon.browse.js b/share/www/script/futon.browse.js
index e9a6ff98..538a747b 100644
--- a/share/www/script/futon.browse.js
+++ b/share/www/script/futon.browse.js
@@ -885,6 +885,15 @@
if (keyCode == 9) { // tab, move to editing the value
row.find("td").dblclick();
}
+ },
+ validate: function(newName, oldName) {
+ $("div.error", this).remove();
+ if (newName != oldName && doc[newName] !== undefined) {
+ $("<div class='error'>Already have field with that name.</div>")
+ .appendTo(this);
+ return false;
+ }
+ return true;
}
});
}
@@ -918,12 +927,13 @@
return $.futon.formatJSON(doc[row.data("name")]);
},
validate: function(value) {
+ $("div.error", this).remove();
try {
JSON.parse(value);
return true;
} catch (err) {
var msg = err.message;
- if (msg == "parseJSON") {
+ if (msg == "parseJSON" || msg == "JSON.parse") {
msg = "Please enter a valid JSON value (for example, \"string\").";
}
$("<div class='error'></div>").text(msg).appendTo(this);
diff --git a/share/www/script/jquery.editinline.js b/share/www/script/jquery.editinline.js
index e3a33155..e677b982 100644
--- a/share/www/script/jquery.editinline.js
+++ b/share/www/script/jquery.editinline.js
@@ -50,7 +50,7 @@
return true;
}
if ((!options.allowEmpty && !newText.length) ||
- !options.validate.apply(elem, [newText])) {
+ !options.validate.apply(elem, [newText, origText])) {
input.addClass("invalid");
return false;
}