couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [2/6] futon commit: updated refs/heads/master to 05f705f
Date Wed, 10 Dec 2014 11:13:07 GMT
jquery.couch: fix document copying

To COPY a doc the client must specify the target doc id in Destination
header. Additionally, it may add the revision parameter if document
already exists and we want to copy over it.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-futon/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-futon/commit/e47b1ad2
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-futon/tree/e47b1ad2
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-futon/diff/e47b1ad2

Branch: refs/heads/master
Commit: e47b1ad2ff7207cd8cd0743ee35156d8e5cffede
Parents: 95bf167
Author: Alexander Shorin <kxepal@apache.org>
Authored: Wed Oct 29 19:01:17 2014 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Fri Oct 31 05:31:39 2014 +0300

----------------------------------------------------------------------
 script/jquery.couch.js | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-futon/blob/e47b1ad2/script/jquery.couch.js
----------------------------------------------------------------------
diff --git a/script/jquery.couch.js b/script/jquery.couch.js
index ffbad34..21b151e 100644
--- a/script/jquery.couch.js
+++ b/script/jquery.couch.js
@@ -734,6 +734,16 @@
          */
         copyDoc: function(docId, options, ajaxOptions) {
           ajaxOptions = $.extend(ajaxOptions, {
+            beforeSend: function(XMLHttpRequest) {
+              if (!options || !options.docid) {
+                  throw "Target docid required";
+              }
+              var header = options.docid;
+              if (options.rev) {
+                  header += '?rev=' + options.rev
+              }
+              XMLHttpRequest.setRequestHeader("Destination", header);
+            },
             complete: function(req) {
               var resp = $.parseJSON(req.responseText);
               if (req.status == 201) {


Mime
View raw message