You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2014/02/11 16:25:45 UTC

[18/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

fix previous paginate


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

Branch: refs/heads/paginate-api-options
Commit: 0959288fa7dfb8ff2f5165183d52a2a2f584034a
Parents: 4a8b5f7
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Feb 3 15:08:20 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Feb 11 10:14:25 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/resources.js | 7 ++++++-
 src/fauxton/app/addons/documents/routes.js    | 8 ++++++--
 src/fauxton/app/addons/documents/views.js     | 1 -
 src/fauxton/app/addons/fauxton/components.js  | 8 ++++++--
 4 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/0959288f/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 4028cb1..c2f9a70 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -281,7 +281,6 @@ function(app, FauxtonAPI) {
       this.database = options.database;
       this.params = _.clone(options.params);
       this.skipFirstItem = false;
-      this.totalRowsToPaginate = 100;
       this.on("remove",this.decrementTotalRows , this);
       this.perPageLimit = options.perPageLimit || 20;
 
@@ -426,6 +425,12 @@ function(app, FauxtonAPI) {
       this.view = options.view;
       this.design = options.design.replace('_design/','');
       this.skipFirstItem = false;
+      this.perPageLimit = options.perPageLimit || 20;
+
+      if (this.params.limit > this.perPageLimit) {
+        this.params.limit = this.perPageLimit; 
+      }
+
     },
 
     url: function(context) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0959288f/src/fauxton/app/addons/documents/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/routes.js b/src/fauxton/app/addons/documents/routes.js
index f9500b2..06db528 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -356,8 +356,12 @@ function(app, FauxtonAPI, Documents, Databases) {
         this.documentsView.collection.skipFirstItem = true;
         this.documentsView.collection.nextPage(options.perPage);
       } else {
-        this.documentsView.collection.skipFirstItem = false;
-        this.documentsView.collection.previousPage(options.perPage);
+        if (options.params && options.params.startkey) {
+          this.documentsView.collection.skipFirstItem = true;
+        } else {
+          this.documentsView.collection.skipFirstItem = false;
+        }
+        this.documentsView.collection.previousPage(options.perPage, options.params);
       }
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0959288f/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index eb99139..d864c64 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -456,7 +456,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         pageEnd =  this.pagination.pageEnd();
       }
 
-      console.log('t', totalRows, this.collection);
       return {
         database: app.utils.safeURLName(this.collection.database.id),
         updateSeq: updateSeq,

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0959288f/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 fd45aa2..130d3c7 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -75,6 +75,7 @@ function(app, FauxtonAPI, ace, spin) {
       this._pageStart = 1;
       this.perPage = 20;
       this.docLimit = options.docLimit || 100;
+      this.paramsHistory = [];
     },
 
     canShowPreviousfn: function () {
@@ -106,7 +107,8 @@ function(app, FauxtonAPI, ace, spin) {
 
       FauxtonAPI.triggerRouteEvent('paginate', {
        direction: 'previous',
-       perPage: this.perPage
+       perPage: this.perPage,
+       params: this.paramsHistory.pop()
       });
     },
 
@@ -114,7 +116,8 @@ function(app, FauxtonAPI, ace, spin) {
       event.preventDefault();
       event.stopPropagation();
       if (!this.canShowNextfn()) { return; }
-      
+
+      this.paramsHistory.push(_.clone(this.collection.params));
       this.pageNumber = this.pageNumber + 1;
       this.incPageStart();
 
@@ -129,6 +132,7 @@ function(app, FauxtonAPI, ace, spin) {
        direction: 'next',
        perPage: limit
       });
+
     },
 
     serialize: function () {