couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [17/34] couchdb commit: updated refs/heads/paginate-api-options to b63c791
Date Mon, 03 Mar 2014 16:58:29 GMT
More working


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

Branch: refs/heads/paginate-api-options
Commit: fa33d4d3e7c13ac99c4e79f69cc191cdb8091f9c
Parents: 9ccfdd9
Author: Garren Smith <garren.smith@gmail.com>
Authored: Wed Jan 29 17:44:49 2014 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Mon Mar 3 11:18:40 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/resources.js |  2 ++
 src/fauxton/app/addons/fauxton/components.js  | 11 +++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/fa33d4d3/src/fauxton/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/resources.js b/src/fauxton/app/addons/documents/resources.js
index 15d4d30..72cdb66 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -284,6 +284,8 @@ function(app, FauxtonAPI) {
       this.totalRowsToPaginate = 100;
       this.on("remove",this.decrementTotalRows , this);
       this.perPageLimit = options.perPageLimit || 20;
+
+      this.params.limit = this.perPageLimit; 
     },
 
     url: function(context) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/fa33d4d3/src/fauxton/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/components.js b/src/fauxton/app/addons/fauxton/components.js
index 225a21b..c755428 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -89,7 +89,6 @@ function(app, FauxtonAPI, ace, spin) {
         return false;
       }
 
-      console.log(this.pageStart() + this.perPage, this.docLimit);
       if ((this.pageStart() + this.perPage) >= this.docLimit) {
         return false;
       }
@@ -119,9 +118,16 @@ function(app, FauxtonAPI, ace, spin) {
       this.pageNumber = this.pageNumber + 1;
       this.incPageStart();
 
+      var documentsLeftToFetch = this.docLimit - (this.pageNumber * this.perPage),
+          limit = this.perPage;
+
+      if (documentsLeftToFetch < this.perPage) {
+        limit = documentsLeftToFetch;
+      }
+
       FauxtonAPI.triggerRouteEvent('paginate', {
        direction: 'next',
-       perPage: this.perPage
+       perPage: limit
       });
     },
 
@@ -163,6 +169,7 @@ function(app, FauxtonAPI, ace, spin) {
         return this.page() + this.collection.length;
       }
 
+      return this.page() + this.perPage;
     }
 
   });


Mime
View raw message