couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [21/34] couchdb commit: updated refs/heads/paginate-api-options to b63c791
Date Mon, 03 Mar 2014 16:58:33 GMT
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/2cf0f413
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/2cf0f413
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/2cf0f413

Branch: refs/heads/paginate-api-options
Commit: 2cf0f41324b5332e0b60690be669deec234c395e
Parents: 55b6ea6
Author: Garren Smith <garren.smith@gmail.com>
Authored: Mon Feb 3 15:08:20 2014 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Mon Mar 3 11:18:41 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/2cf0f413/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/2cf0f413/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 3ec640f..a0edc07 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/2cf0f413/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 674b21b..8fa426a 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/2cf0f413/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 c755428..b31c623 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 () {


Mime
View raw message