You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2014/12/10 12:13:07 UTC

[2/6] futon commit: updated refs/heads/master to 05f705f

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 <kx...@apache.org>
Authored: Wed Oct 29 19:01:17 2014 +0300
Committer: Alexander Shorin <kx...@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) {