Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/33#discussion_r16407277
  
    --- Diff: app/addons/indexes/routes-core.js ---
    @@ -0,0 +1,227 @@
    +// Licensed under the Apache License, Version 2.0 (the "License"); you may 
not
    +// use this file except in compliance with the License. You may obtain a 
copy of
    +// the License at
    +//
    +//   http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing, software
    +// distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT
    +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    +// License for the specific language governing permissions and limitations 
under
    +// the License.
    +define([
    +  "app",
    +  "api",
    +  "addons/databases/base",
    +  "addons/indexes/views",
    +  "addons/documents/views",
    +  "addons/indexes/resources"
    +],
    +
    +function (app, FauxtonAPI, Databases, Views, Documents, Resources) {
    +
    +  var CoreIndexRouteObj =  FauxtonAPI.RouteObject.extend({
    +    layout: "two_pane",
    +
    +    initialize: function (route, masterLayout, options) {
    +      _.bindAll(this);
    +      var params = this.createParams(),
    +      urlParams = params.urlParams,
    +      docParams = params.docParams;
    +
    +      this.databaseName = options[0];
    +
    +      this.data = {
    +        database: new Databases.Model({id:this.databaseName})
    +      };
    +
    +      this.data.designDocs = new Documents.AllDocs(null, {
    +        database: this.data.database,
    +        paging: {
    +          pageSize: 500
    +        },
    +        params: {
    +          startkey: '_design',
    +          endkey: '_design1',
    +          include_docs: true,
    +          limit: 500
    +        }
    +      });
    +
    +
    +      /* --------------------------------------------------
    +        Set up right header
    +      ----------------------------------------------------*/
    +
    +      this.rightHeader = this.setView("#api-navbar", new 
Views.RightHeader({
    +        database: this.data.database,
    +        model: this.data.database,
    +        endpoint: this.data.designDocs.urlRef("apiurl", urlParams),
    +        documentation: "docs"
    +      }));
    +
    +    },
    +
    +    events: {
    +      "route:updatePreviewDocs": "updateAllDocsFromPreview",
    +      "route:perPageChange": "perPageChange",
    +      "route:paginate": "paginate",
    +      "route:updateAllDocs": "updateAllDocsFromView"
    +    },
    +
    +    /* --------------------------------------------------
    +      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.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.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,
    +        currView: view,
    +        designDocs: designDocs
    +      };
    +    },
    +
    +    /* --------------------------------------------------
    +      URL params from Advanced/ Query options
    +    ----------------------------------------------------*/
    +    createParams: function (options) {
    +      var urlParams = app.getParams(options);
    +      var params = Documents.QueryParams.parse(urlParams);
    +
    +      return {
    +        urlParams: urlParams,
    +        docParams: _.extend(params, {limit: 
this.getDocPerPageLimit(params, 20)})
    +      };
    +    },
    +
    +    /* --------------------------------------------------
    +      Stored docs in preview
    --- End diff --
    
    I don't think this comment is correct. This function just determines how 
many docs to display for the request.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to