couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowalski <...@git.apache.org>
Subject [GitHub] couchdb-fauxton pull request: Reactify AllDocNumbers
Date Wed, 18 Feb 2015 14:24:49 GMT
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/275#discussion_r24903614
  
    --- Diff: app/addons/documents/docs-list/components.react.jsx ---
    @@ -0,0 +1,119 @@
    +// 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([
    +  "api",
    +  "react",
    +  'addons/documents/docs-list/stores',
    +  'addons/documents/docs-list/actions'
    +  ], function (FauxtonAPI, React, Stores, Actions) {
    +    var allDocsListStore = Stores.allDocsListStore;
    +
    +    var PerPageSelector = React.createClass({
    +
    +      perPageChange: function (e) {
    +        var perPage = parseInt(e.target.value, 10);
    +        this.props.perPageChange(perPage);
    +      },
    +
    +      render: function () {
    +        return (
    +          <div id="per-page">
    +            <label htmlFor="select-per-page" className="drop-down inline">
    +              Per page:
    +              <select id="select-per-page" onChange={this.perPageChange} value={this.props.perPage.toString()}
className="input-small">
    +                <option value="5">5</option>
    +                <option value="10">10</option>
    +                <option value="20">20</option>
    +                <option value="30">30</option>
    +                <option value="50">50</option>
    +                <option value="100">100</option>
    +              </select>
    +            </label>
    +          </div>
    +        );
    +      }
    +
    +    });
    +
    +    var AllDocsNumber = React.createClass({
    +
    +      getStoreState: function () {
    +        return {
    +          totalRows: allDocsListStore.getTotalRows(),
    +          pageStart: allDocsListStore.getPageStart(),
    +          pageEnd: allDocsListStore.getPageEnd(),
    +          updateSeq: allDocsListStore.getUpdateSeq(),
    +          perPage: allDocsListStore.getPerPage()
    +        };
    +      },
    +
    +      getInitialState: function () {
    +        return this.getStoreState();
    +      },
    +
    +      componentDidMount: function() {
    +        allDocsListStore.on('change', this.onChange, this);
    +      },
    +
    +      componentWillUnmount: function() {
    +        allDocsListStore.off('change', this.onChange);
    +      },
    +
    +      onChange: function () {
    +        this.setState(this.getStoreState());
    +      },
    +
    +      pageNumber: function () {
    +        if (this.state.totalRows === 0) {
    +          return <p> Showing 0 documents. </p>;
    +          } else {
    +            return <p>Showing {this.state.pageStart} - {this.state.pageEnd}</p>;
    +            }
    --- End diff --
    
    the else got a bit unformatted and as you are returning early, you can even omit the else


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message