couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [12/15] fauxton commit: updated refs/heads/doc-design to 170fccf
Date Fri, 21 Nov 2014 10:57:18 GMT
fix paging bug with active select-all button


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

Branch: refs/heads/doc-design
Commit: f6995cd63b1517703507b34a63e7fe2e54945cf3
Parents: 8a650dc
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Wed Nov 19 18:15:36 2014 +0100
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Fri Nov 21 11:49:07 2014 +0100

----------------------------------------------------------------------
 .../documents/tests/nightwatch/bulkDelete.js    | 23 ++++++++++++++++++++
 app/addons/documents/views.js                   | 21 +++++++++++++++++-
 2 files changed, 43 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/f6995cd6/app/addons/documents/tests/nightwatch/bulkDelete.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/bulkDelete.js b/app/addons/documents/tests/nightwatch/bulkDelete.js
index abca9f6..15bd0c5 100644
--- a/app/addons/documents/tests/nightwatch/bulkDelete.js
+++ b/app/addons/documents/tests/nightwatch/bulkDelete.js
@@ -20,10 +20,15 @@ module.exports = {
 
     client
       .loginToGUI()
+      .createDocument(newDocumentName1, newDatabaseName)
+      .createDocument(newDocumentName2, newDatabaseName)
       .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
       .waitForElementPresent('.js-all', waitTime, false)
       .click('.js-all')
       .click('.js-bulk-delete')
+      .acceptAlert()
+      .waitForElementVisible('#global-notifications .alert.alert-info', waitTime)
+      .waitForElementNotPresent('[data-id="' + newDocumentName1 + '"]', waitTime)
       .getText('body', function (result) {
         var data = result.value,
             isPresentFirstDoc = data.indexOf(newDocumentName1) !== -1,
@@ -34,5 +39,23 @@ module.exports = {
           'Checking if documents were deleted');
       })
       .end();
+  },
+
+  'Select all works after changing the page': function (client) {
+    var waitTime = 10000,
+        newDatabaseName = client.globals.testDatabaseName,
+        baseUrl = client.globals.baseUrl;
+
+    client
+      .loginToGUI()
+      .createManyDocuments(25, newDatabaseName)
+      .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+      .waitForElementVisible('.js-all', waitTime, false)
+      .click('.js-all')
+      .click('#next')
+      .waitForElementPresent('#previous', waitTime)
+      .click('#previous')
+      .waitForElementPresent('.js-all.active', waitTime, false)
+      .end();
   }
 };

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/f6995cd6/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views.js b/app/addons/documents/views.js
index 903ca4e..4132339 100644
--- a/app/addons/documents/views.js
+++ b/app/addons/documents/views.js
@@ -177,7 +177,15 @@ function(app, FauxtonAPI, Components, Documents, Databases, Views, QueryOptions)
   Views.Document = FauxtonAPI.View.extend({
     template: "addons/documents/templates/all_docs_item",
 
-    className: 'all-docs-item doc-row',
+    className: function () {
+      var classNames = 'all-docs-item doc-row';
+
+      if (this.checked) {
+        classNames = classNames + ' js-to-delete';
+      }
+
+      return classNames;
+    },
 
     initialize: function (options) {
       this.checked = options.checked;
@@ -349,6 +357,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, Views, QueryOptions)
           docId = $row.attr('data-id'),
           rev = this.collection.get(docId).get('_rev'),
           data = {_id: docId, _rev: rev, _deleted: true};
+
       if (!$row.hasClass('js-to-delete')) {
         this.bulkDeleteDocsCollection.add(data);
         $row.find('.js-row-select').prop('checked', true);
@@ -371,6 +380,15 @@ function(app, FauxtonAPI, Components, Documents, Databases, Views, QueryOptions)
       }
     },
 
+    maybeHighlightAllButton: function () {
+      console.log(this.$('.js-to-delete').length , this.$('.all-docs-item').length);
+
+      if (this.$('.js-to-delete').length < this.$('.all-docs-item').length) {
+        return;
+      }
+      this.$('.js-all').addClass('active');
+    },
+
     openQueryOptionsTray: function(e) {
       e.preventDefault();
       FauxtonAPI.Events.trigger("QueryOptions:openTray");
@@ -555,6 +573,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, Views, QueryOptions)
       }
 
       this.toggleTrash();
+      this.maybeHighlightAllButton();
     },
 
     perPage: function () {


Mime
View raw message