Working on doc limit
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d6f6d229 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d6f6d229 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d6f6d229 Branch: refs/heads/paginate-api-options Commit: d6f6d229d337817f0be6b7ea3b8e49b0ca66e20c Parents: 344f372 Author: Garren Smith <[email protected]> Authored: Wed Jan 29 15:48:34 2014 +0200 Committer: Garren Smith <[email protected]> Committed: Mon Feb 3 10:27:38 2014 +0200 ---------------------------------------------------------------------- src/fauxton/app/addons/documents/resources.js | 5 ++++- src/fauxton/app/addons/documents/routes.js | 3 ++- src/fauxton/app/addons/documents/views.js | 4 +++- src/fauxton/app/addons/fauxton/components.js | 7 +++++++ 4 files changed, 16 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/d6f6d229/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 cf1b4aa..1824da0 100644 --- a/src/fauxton/app/addons/documents/resources.js +++ b/src/fauxton/app/addons/documents/resources.js @@ -279,10 +279,11 @@ function(app, FauxtonAPI) { }, initialize: function(_models, options) { this.database = options.database; - this.params = options.params; + this.params = _.clone(options.params); this.skipFirstItem = false; this.totalRowsToPaginate = 100; this.on("remove",this.decrementTotalRows , this); + this.perPageLimit = options.perPageLimit || 20; }, url: function(context) { @@ -315,6 +316,8 @@ function(app, FauxtonAPI) { }, updateLimit: function (limit) { + this.perPageLimit = limit; + if (this.params.startkey_docid && this.params.startkey) { //we are paginating so set limit + 1 this.params.limit = limit + 1; http://git-wip-us.apache.org/repos/asf/couchdb/blob/d6f6d229/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 0c95bcf..9ef8837 100644 --- a/src/fauxton/app/addons/documents/routes.js +++ b/src/fauxton/app/addons/documents/routes.js @@ -211,7 +211,8 @@ function(app, FauxtonAPI, Documents, Databases) { })); this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({ - collection: this.data.database.allDocs + collection: this.data.database.allDocs, + docLimit: parseInt(docOptions.limit, 10) })); this.crumbs = [ http://git-wip-us.apache.org/repos/asf/couchdb/blob/d6f6d229/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 8b8b7b3..1af8183 100644 --- a/src/fauxton/app/addons/documents/views.js +++ b/src/fauxton/app/addons/documents/views.js @@ -583,6 +583,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum this.ddocID = options.ddocInfo.id; } this.newView = options.newView || false; + this.docLimit = options.docLimit; this.expandDocs = true; }, @@ -668,7 +669,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum this.pagination = new Components.IndexPagination({ collection: this.collection, - scrollToSelector: '#dashboard-content' + scrollToSelector: '#dashboard-content', + docLimit: this.docLimit }); }, http://git-wip-us.apache.org/repos/asf/couchdb/blob/d6f6d229/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 4f69412..d5ba7a6 100644 --- a/src/fauxton/app/addons/fauxton/components.js +++ b/src/fauxton/app/addons/fauxton/components.js @@ -74,6 +74,7 @@ function(app, FauxtonAPI, ace, spin) { this.pageNumber = 0; this._pageStart = 1; this.perPage = 20; + this.docLimit = options.docLimit || 100; }, canShowPreviousfn: function () { @@ -87,6 +88,12 @@ function(app, FauxtonAPI, ace, spin) { if (this.collection.length < (this.perPage -1)) { return false; } + + console.log(this.pageStart() + this.perPage, this.docLimit); + if ((this.pageStart() + this.perPage) >= this.docLimit) { + return false; + } + return true; },
