diff options
author | Garren Smith <garren.smith@gmail.com> | 2014-02-03 12:10:08 +0200 |
---|---|---|
committer | Garren Smith <garren.smith@gmail.com> | 2014-03-03 11:18:41 +0200 |
commit | 55b6ea67ac7e3b0180b216007c2018cd140e5703 (patch) | |
tree | cc6f5f628b489e8748b42a8238422f2f0f42f975 | |
parent | fa33d4d3e7c13ac99c4e79f69cc191cdb8091f9c (diff) | |
download | couchdb-55b6ea67ac7e3b0180b216007c2018cd140e5703.tar.gz |
Set view limit on pagination
6 files changed, 26 insertions, 27 deletions
diff --git a/src/fauxton/app/addons/documents/resources.js b/src/fauxton/app/addons/documents/resources.js index 72cdb6692..4028cb168 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) { diff --git a/src/fauxton/app/addons/documents/routes.js b/src/fauxton/app/addons/documents/routes.js index 9ef88373f..3ec640f89 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, 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 b6428c9dd..1bbe59d86 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"> 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 4c9130b31..fb9ea11cf 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 %> diff --git a/src/fauxton/app/addons/documents/templates/view_editor.html b/src/fauxton/app/addons/documents/templates/view_editor.html index b1364dfb5..36451e8d3 100644 --- a/src/fauxton/app/addons/documents/templates/view_editor.html +++ b/src/fauxton/app/addons/documents/templates/view_editor.html @@ -16,8 +16,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> diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js index a33bd47db..674b21ba6 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, @@ -1697,27 +1698,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); } |