couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deathb...@apache.org
Subject [32/48] fauxton commit: updated refs/heads/secondary-indexes to 8688d16
Date Mon, 25 Aug 2014 13:40:12 GMT
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/5187861b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/5187861b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/5187861b

Branch: refs/heads/secondary-indexes
Commit: 5187861b71247b53d5db1511fcfd57482af08145
Parents: 566ac34
Author: deathbearbrown <deathbearbrown@gmail.com>
Authored: Sun Aug 24 16:33:43 2014 +0200
Committer: deathbearbrown <deathbearbrown@gmail.com>
Committed: Mon Aug 25 09:37:36 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/5187861b/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/5187861b/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,


Mime
View raw message