couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [1/6] futon commit: updated refs/heads/master to 05f705f
Date Wed, 10 Dec 2014 11:13:06 GMT
Repository: couchdb-futon
Updated Branches:
  refs/heads/master [created] 05f705fa0


Futon: support document copying

Based on Patrick Antivackis work. Thanks!

COUCHDB-241


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

Branch: refs/heads/master
Commit: ef3e74a2f5f4f354b9ff826769f3551b2f63dc78
Parents: fd26e03
Author: Alexander Shorin <kxepal@apache.org>
Authored: Thu Oct 30 18:02:31 2014 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Fri Oct 31 05:31:39 2014 +0300

----------------------------------------------------------------------
 dialog/_copy_document.html |  29 +++++++++++++++++++++++++++++
 document.html              |   2 ++
 image/copy.png             | Bin 0 -> 780 bytes
 script/futon.browse.js     |  31 +++++++++++++++++++++++++++++++
 style/layout.css           |   3 +++
 5 files changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-futon/blob/ef3e74a2/dialog/_copy_document.html
----------------------------------------------------------------------
diff --git a/dialog/_copy_document.html b/dialog/_copy_document.html
new file mode 100644
index 0000000..fe49e81
--- /dev/null
+++ b/dialog/_copy_document.html
@@ -0,0 +1,29 @@
+<!--
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License.  You may obtain a copy of the
+License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed
+under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations under the License.
+
+-->
+<form action="" method="post">
+  <h2>Copy Document</h2>
+  <fieldset>
+    <p class="help help-copy">
+      Please enter a unique ID of the document:
+    </p>
+    <table summary="" class="help-copy"><tbody><tr>
+      <td><input type="text" name="docid" size="32"></td>
+    </tr></table>
+  </fieldset>
+  <div class="buttons">
+    <button type="submit">Copy</button>
+    <button type="button" class="cancel">Cancel</button>
+  </div>
+</form>

http://git-wip-us.apache.org/repos/asf/couchdb-futon/blob/ef3e74a2/document.html
----------------------------------------------------------------------
diff --git a/document.html b/document.html
index e041cd9..1509475 100644
--- a/document.html
+++ b/document.html
@@ -55,6 +55,7 @@ specific language governing permissions and limitations under the License.
         $("#toolbar button.save").click(page.saveDocument);
         $("#toolbar button.add").click(page.addField);
         $("#toolbar button.load").click(page.uploadAttachment);
+        $("#toolbar button.copy").click(page.copyDocument);
         if (page.isNew) {
           $("#toolbar button.delete").hide();
         } else {
@@ -76,6 +77,7 @@ specific language governing permissions and limitations under the License.
         <li><button class="save">Save Document</button></li>
         <li><button class="add">Add Field</button></li>
         <li><button class="load">Upload Attachment…</button></li>
+        <li><button class="copy">Copy Document…</button></li>
         <li><button class="delete">Delete Document…</button></li>
       </ul>
 

http://git-wip-us.apache.org/repos/asf/couchdb-futon/blob/ef3e74a2/image/copy.png
----------------------------------------------------------------------
diff --git a/image/copy.png b/image/copy.png
new file mode 100644
index 0000000..07b4f79
Binary files /dev/null and b/image/copy.png differ

http://git-wip-us.apache.org/repos/asf/couchdb-futon/blob/ef3e74a2/script/futon.browse.js
----------------------------------------------------------------------
diff --git a/script/futon.browse.js b/script/futon.browse.js
index 241164c..75b1624 100644
--- a/script/futon.browse.js
+++ b/script/futon.browse.js
@@ -1094,6 +1094,37 @@
         });
       }
 
+      this.copyDocument = function() {
+        if (page.isDirty) {
+          alert("You need to save or revert any changes you have made to the " +
+                "document before you can copy it.");
+            return false;
+        }
+        $.showDialog("dialog/_copy_document.html", {
+          submit: function (data, callback) {
+            if (!data.docid || data.docid.length == 0) {
+              callback({docid: "Please enter a document ID."});
+              return;
+            }
+            db.copyDoc(
+              page.doc._id,
+              {
+                docid: data.docid
+              },
+              {
+                error: function (status, error, reason) {
+                  callback({docid: reason});
+              },
+                success: function (resp) {
+                  location.href = "document.html?"
+                                + encodeURIComponent(dbName)
+                                + "/" + $.couch.encodeDocId(resp.id);
+              }
+            });
+          }
+        });
+      };
+
       window.onbeforeunload = function() {
         if (page.isDirty) {
           return "You've made changes to this document that have not been " +

http://git-wip-us.apache.org/repos/asf/couchdb-futon/blob/ef3e74a2/style/layout.css
----------------------------------------------------------------------
diff --git a/style/layout.css b/style/layout.css
index 54a183a..055e791 100644
--- a/style/layout.css
+++ b/style/layout.css
@@ -246,6 +246,7 @@ body.fullwidth #wrap { margin-right: 0; }
 #toolbar button.run { background-image: url(../image/run.png); }
 #toolbar button.save { background-image: url(../image/save.png); }
 #toolbar button.share { background-image: url(../image/compact.png); }
+#toolbar button.copy { background-image: url(../image/copy.png); }
 
 /* Dialogs */
 
@@ -282,7 +283,9 @@ body.loading #dialog h2 {
   -webkit-border-bottom-right-radius: 7px;
 }
 #dialog p.help { color: #bbb; font-size: 95%; margin: 0 0 1em; }
+#dialog p.help-copy { margin-top: 1em; margin-bottom: 0; padding-left: 0.6em; }
 #dialog fieldset table { margin-top: 1em; }
+#dialog fieldset table.help-copy { margin-top: 0; }
 #dialog fieldset th, #dialog fieldset td { padding: .5em;
   vertical-align: top;
 }


Mime
View raw message