couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cml...@apache.org
Subject svn commit: r796548 - in /couchdb/trunk/share/www/script: futon.browse.js jquery.editinline.js
Date Tue, 21 Jul 2009 21:42:59 GMT
Author: cmlenz
Date: Tue Jul 21 21:42:59 2009
New Revision: 796548

URL: http://svn.apache.org/viewvc?rev=796548&view=rev
Log:
Fix for COUCHDB-318: when adding or renaming a field in Futon, check that a field with the
same name does not already exist.

Modified:
    couchdb/trunk/share/www/script/futon.browse.js
    couchdb/trunk/share/www/script/jquery.editinline.js

Modified: couchdb/trunk/share/www/script/futon.browse.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.browse.js?rev=796548&r1=796547&r2=796548&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/futon.browse.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.browse.js [utf-8] Tue Jul 21 21:42:59 2009
@@ -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);

Modified: couchdb/trunk/share/www/script/jquery.editinline.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/jquery.editinline.js?rev=796548&r1=796547&r2=796548&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/jquery.editinline.js (original)
+++ couchdb/trunk/share/www/script/jquery.editinline.js Tue Jul 21 21:42:59 2009
@@ -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;
       }



Mime
View raw message