Repository: couchdb-fauxton Updated Branches: refs/heads/secondary-indexes 5125c4f61 -> e850b2e41
Fixed pagination on indexes Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/e850b2e4 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/e850b2e4 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/e850b2e4 Branch: refs/heads/secondary-indexes Commit: e850b2e41aa2a31f317675398c50f519dace133b Parents: 5125c4f Author: deathbearbrown <deathbearbr...@gmail.com> Authored: Tue Aug 12 16:18:53 2014 -0400 Committer: deathbearbrown <deathbearbr...@gmail.com> Committed: Tue Aug 12 16:18:53 2014 -0400 ---------------------------------------------------------------------- app/addons/fauxton/components.js | 2 +- app/addons/indexes/routes-core.js | 53 +++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e850b2e4/app/addons/fauxton/components.js ---------------------------------------------------------------------- diff --git a/app/addons/fauxton/components.js b/app/addons/fauxton/components.js index 28a9070..3784b8d 100644 --- a/app/addons/fauxton/components.js +++ b/app/addons/fauxton/components.js @@ -747,7 +747,7 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) { className: "dropdown", initialize: function(options){ this.links = options.links; - this.icon = options.icon || "fonticon-plus-circled2"; + this.icon = options.icon || "fonticon-plus-circled"; _.bindAll(this); this.setUpEvents(); }, http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e850b2e4/app/addons/indexes/routes-core.js ---------------------------------------------------------------------- diff --git a/app/addons/indexes/routes-core.js b/app/addons/indexes/routes-core.js index 354afb0..ae21e03 100644 --- a/app/addons/indexes/routes-core.js +++ b/app/addons/indexes/routes-core.js @@ -45,9 +45,46 @@ function (app, FauxtonAPI, Databases, Views, Documents, Resources) { }, events: { - "route:updatePreviewDocs": "updateAllDocsFromPreview" + "route:updatePreviewDocs": "updateAllDocsFromPreview", + "route:perPageChange": "perPageChange", + "route:paginate": "paginate" }, + /* -------------------------------------------------- + Called when you change the # of items to show in the pagination footer + ----------------------------------------------------*/ + perPageChange: function (perPage) { + // We need to restore the collection parameters to the defaults (1st page) + // and update the page size + this.perPage = perPage; + this.leftheader.forceRender(); + this.documentsView.forceRender(); + this.documentsView.collection.pageSizeReset(perPage, {fetch: false}); + this.setDocPerPageLimit(perPage); + }, + + /* -------------------------------------------------- + Store the docs to show per page in local storage + ----------------------------------------------------*/ + setDocPerPageLimit: function (perPage) { + window.localStorage.setItem('fauxton:perpage', perPage); + }, + + /* -------------------------------------------------- + Triggers when you hit the paginate forward and backwards buttons + ----------------------------------------------------*/ + + paginate: function (options) { + var collection = this.documentsView.collection; + this.leftheader.forceRender(); + this.documentsView.forceRender(); + collection.paging.pageSize = options.perPage; + var promise = collection[options.direction]({fetch: false}); + }, + + /* -------------------------------------------------- + Get Design doc info + ----------------------------------------------------*/ ddocInfo: function (designDoc, designDocs, view) { return { id: "_design/" + designDoc, @@ -56,6 +93,9 @@ function (app, FauxtonAPI, Databases, Views, Documents, Resources) { }; }, + /* -------------------------------------------------- + URL params from Advanced/ Query options + ----------------------------------------------------*/ createParams: function (options) { var urlParams = app.getParams(options); var params = Documents.QueryParams.parse(urlParams); @@ -66,6 +106,9 @@ function (app, FauxtonAPI, Databases, Views, Documents, Resources) { }; }, + /* -------------------------------------------------- + Stored docs in preview + ----------------------------------------------------*/ getDocPerPageLimit: function (urlParams, perPage) { var storedPerPage = perPage; @@ -91,6 +134,10 @@ function (app, FauxtonAPI, Databases, Views, Documents, Resources) { return this.data.designDocs.fetch({reset: true}); }, + + /* -------------------------------------------------- + Docs that are returned from a view + ----------------------------------------------------*/ createViewDocumentsView: function (options) { return this.setView("#right-content", new Documents.Views.AllDocsList({ database: options.database, @@ -103,6 +150,10 @@ function (app, FauxtonAPI, Databases, Views, Documents, Resources) { })); }, + + /* -------------------------------------------------- + If Preview worked.... + ----------------------------------------------------*/ updateAllDocsFromPreview: function (event) { var view = event.view, rows = event.rows,