Set view limit on pagination
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/5d2a6f9c Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/5d2a6f9c Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/5d2a6f9c Branch: refs/heads/paginate-api-options Commit: 5d2a6f9c9a212965d2f9972c07eae6ce7d3d509f Parents: 5c7b312 Author: Garren Smith <[email protected]> Authored: Mon Feb 3 12:10:08 2014 +0200 Committer: Garren Smith <[email protected]> Committed: Mon Feb 3 12:10:08 2014 +0200 ---------------------------------------------------------------------- src/fauxton/app/addons/documents/resources.js | 4 ++- src/fauxton/app/addons/documents/routes.js | 5 ++- .../documents/templates/all_docs_layout.html | 4 --- .../documents/templates/all_docs_number.html | 2 +- .../addons/documents/templates/view_editor.html | 2 -- src/fauxton/app/addons/documents/views.js | 36 +++++++++++--------- 6 files changed, 26 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d2a6f9c/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 f3e5043..ad4daca 100644 --- a/src/fauxton/app/addons/documents/resources.js +++ b/src/fauxton/app/addons/documents/resources.js @@ -285,7 +285,9 @@ function(app, FauxtonAPI) { this.on("remove",this.decrementTotalRows , this); this.perPageLimit = options.perPageLimit || 20; - this.params.limit = this.perPageLimit; + if (this.params.limit > this.perPageLimit) { + this.params.limit = this.perPageLimit; + } }, url: function(context) { http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d2a6f9c/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 9ef8837..3ec640f 100644 --- a/src/fauxton/app/addons/documents/routes.js +++ b/src/fauxton/app/addons/documents/routes.js @@ -275,9 +275,8 @@ function(app, FauxtonAPI, Documents, Databases) { newViewEditor: function () { var params = app.getParams(); - if (this.toolsView) { - this.toolsView.remove(); - } + this.toolsView && this.toolsView.remove(); + this.documentsView && this.documentsView.remove(); this.viewEditor = this.setView("#dashboard-upper-content", new Documents.Views.ViewEditor({ ddocs: this.data.designDocs, http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d2a6f9c/src/fauxton/app/addons/documents/templates/all_docs_layout.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/templates/all_docs_layout.html b/src/fauxton/app/addons/documents/templates/all_docs_layout.html index b6428c9..1bbe59d 100644 --- a/src/fauxton/app/addons/documents/templates/all_docs_layout.html +++ b/src/fauxton/app/addons/documents/templates/all_docs_layout.html @@ -12,10 +12,6 @@ License for the specific language governing permissions and limitations under the License. --> -<ul class="nav nav-tabs window-resizeable" id="db-views-tabs-nav"> - <li><a id="toggle-query" href="#query" data-bypass="true" data-toggle="tab"> - <i class="fonticon fonticon-plus"></i> Query Options</a></li> -</ul> <div class="tab-content"> <div id="query-options-wrapper"></div> <div class="tab-pane" id="query"> http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d2a6f9c/src/fauxton/app/addons/documents/templates/all_docs_number.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/templates/all_docs_number.html b/src/fauxton/app/addons/documents/templates/all_docs_number.html index 4c9130b..fb9ea11 100644 --- a/src/fauxton/app/addons/documents/templates/all_docs_number.html +++ b/src/fauxton/app/addons/documents/templates/all_docs_number.html @@ -11,7 +11,7 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -<% if (totalRows === "unknown"){ %> +<% if (totalRows === "unknown" || totalRows === 0){ %> Showing 0 documents. <a href="#/database/<%=database%>/new"> Create your first document.</a> <% } else { %> Showing <%=pageStart%> - <%= pageEnd %> http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d2a6f9c/src/fauxton/app/addons/documents/templates/view_editor.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/templates/view_editor.html b/src/fauxton/app/addons/documents/templates/view_editor.html index 3a2c564..86802ec 100644 --- a/src/fauxton/app/addons/documents/templates/view_editor.html +++ b/src/fauxton/app/addons/documents/templates/view_editor.html @@ -17,8 +17,6 @@ the License. <i class="fonticon-wrench fonticon"></i> <% if (newView) { %>Create Index <% } else { %>Edit Index <% } %></a></li> <% if (!newView) { %> - <li><a data-bypass="true" id="query-nav" href="#query" data-toggle="tab"> - <i class="fonticon-plus fonticon"></i> Query Options</a></li> <li><a data-bypass="true" id="meta-nav" href="#metadata" data-toggle="tab">Design Doc Metadata</a></li> <% } %> </ul> http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d2a6f9c/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 1af8183..33bdeb4 100644 --- a/src/fauxton/app/addons/documents/views.js +++ b/src/fauxton/app/addons/documents/views.js @@ -446,7 +446,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum pageEnd = 20; if (!this.newView) { - totalRows = this.collection.totalRows(); + totalRows = this.collection.length; updateSeq = this.collection.updateSeq(); } @@ -456,6 +456,7 @@ 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, @@ -1698,27 +1699,30 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum database: this.database })); - this.eventer = _.extend({}, Backbone.Events); - this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({ - updateViewFn: this.updateView, - previewFn: this.previewView, - database: this.database, - viewName: this.viewName, - ddocName: this.model.id, - hasReduce: this.hasReduce(), - eventer: this.eventer - })); + if (!this.newView) { + this.eventer = _.extend({}, Backbone.Events); + + this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({ + updateViewFn: this.updateView, + previewFn: this.previewView, + database: this.database, + viewName: this.viewName, + ddocName: this.model.id, + hasReduce: this.hasReduce(), + eventer: this.eventer + })); - this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({ - hasReduce: this.hasReduce(), - eventer: this.eventer - })); + this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({ + hasReduce: this.hasReduce(), + eventer: this.eventer + })); + } }, afterRender: function() { - if (this.params) { + if (this.params && !this.newView) { this.advancedOptions.updateFromParams(this.params); this.advancedOptionsMenu.updateFromParams(this.params); }
