couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject fauxton commit: updated refs/heads/master to 235d544
Date Tue, 18 Nov 2014 12:06:20 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master e87539cc9 -> 235d54451


Fix bulk-delete on all-doc-page

On Couch 1.6 `/_bulk_docs` returned `ok: true` when the request was an
success. On 2.0 the ok property is missing:

Example success message on 2.0:
```
[{"id":"Brocket","rev":"6-b6fa9e703c3eb92aa9c3a49cedf1e8c2"}]
```

Example error message on 2.0:
```
[{"id":"Blaggie-System","error":"conflict",
  "reason":"Document update conflict."}]
```

Steps to reproduce the error in Fauxton:

 - select 1 document in the all_docs screen
 - click the trash icon to delete it
 - click ok to delete it
 - you are able to click the trash icon again and if you do, you
   get an error

Closes COUCHDB-2462


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

Branch: refs/heads/master
Commit: 235d544517f64941a796e382bbc67b520a241fed
Parents: e87539c
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Fri Nov 14 16:04:31 2014 +0100
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Tue Nov 18 13:05:33 2014 +0100

----------------------------------------------------------------------
 app/addons/documents/resources.js |  2 +-
 app/addons/documents/views.js     | 18 +++++++++++-------
 2 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/235d5445/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/resources.js b/app/addons/documents/resources.js
index 651ca37..b9337d2 100644
--- a/app/addons/documents/resources.js
+++ b/app/addons/documents/resources.js
@@ -344,7 +344,7 @@ function(app, FauxtonAPI, PagingCollection) {
           ids.errorIds.push(doc.id);
         }
 
-        if (doc.ok === true) {
+        if (!doc.error) {
           ids.successIds.push(doc.id);
         }
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/235d5445/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views.js b/app/addons/documents/views.js
index 683a05b..2b4fe1a 100644
--- a/app/addons/documents/views.js
+++ b/app/addons/documents/views.js
@@ -357,16 +357,17 @@ function(app, FauxtonAPI, Components, Documents, Databases, Views, QueryOptions)
     },
 
     removeDocuments: function (ids) {
-      _.each(ids, function (id) {
-        this.removeDocument(id);
-      }, this);
-
-      this.pagination.updatePerPage(parseInt(this.$('#select-per-page :selected').val(),
10));
-      FauxtonAPI.triggerRouteEvent('perPageChange', this.pagination.documentsLeftToFetch());
+      FauxtonAPI.when(ids.map(function (id) {
+        return this.removeDocument(id);
+      }.bind(this))).done(function () {
+        this.pagination.updatePerPage(parseInt(this.$('#select-per-page :selected').val(),
10));
+        FauxtonAPI.triggerRouteEvent('perPageChange', this.pagination.documentsLeftToFetch());
+      }.bind(this));
     },
 
     removeDocument: function (id) {
-      var that = this;
+      var that = this,
+          deferred = FauxtonAPI.Deferred();
 
       if (!this.rows[id]) {
         return;
@@ -374,7 +375,10 @@ function(app, FauxtonAPI, Components, Documents, Databases, Views, QueryOptions)
 
       this.rows[id].$el.fadeOut('slow', function () {
         that.rows[id].remove();
+        deferred.resolve();
       });
+
+      return deferred;
     },
 
     showError: function (ids) {


Mime
View raw message