{"size": 2779, "ext": "js", "max_stars_repo_path": "app/addons/documents/index-results/components/queryoptions/AdditionalParams.js", "max_stars_repo_name": "bean5/couchdb-fauxton", "max_stars_repo_stars_event_min_datetime": "2015-01-08T21:19:01.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T11:30:00.000Z", "max_issues_repo_path": "app/addons/documents/index-results/components/queryoptions/AdditionalParams.js", "max_issues_repo_name": "bean5/couchdb-fauxton", "max_issues_repo_issues_event_min_datetime": "2015-01-02T16:36:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-07T14:15:24.000Z", "max_forks_repo_path": "app/addons/documents/index-results/components/queryoptions/AdditionalParams.js", "max_forks_repo_name": "bean5/couchdb-fauxton", "max_forks_repo_forks_event_min_datetime": "2015-01-07T22:29:45.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-22T13:12:02.000Z"}
{"max_stars_count": 318, "max_issues_count": 915, "max_forks_count": 246, "avg_line_length": 35.1772151899, "max_line_length": 159, "alphanum_fraction": 0.6009355883}
// 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.

import React from 'react';
import FauxtonAPI from '../../../../../core/api';

export default class AdditionalParams extends React.Component {
  updateSkip (e) {
    e.preventDefault();
    let val = e.target.value;

    //check skip is only numbers
    if (!/^\d*$/.test(val)) {
      FauxtonAPI.addNotification({
        msg: 'Skip can only be a number',
        type: 'error'
      });
      val = this.props.skip;
    }

    this.props.updateSkip(val);
  }

  updateLimit (e) {
    e.preventDefault();
    this.props.updateLimit(e.target.value);
  }

  toggleDescending () {
    this.props.toggleDescending(this.props.descending);
  }

  render () {
    return (
      <div className="query-group" id="query-options-additional-params">
        <div className="add-on additionalParams">Additional Parameters</div>
        <div className="row-fluid fieldsets">
          <div className="dropdown inline">
            <label className="drop-down">
              Limit
              <select id="qoLimit" onChange={this.updateLimit.bind(this)} name="limit" value={this.props.limit} className="input-small">
                <option value="none">None</option>
                <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>
                <option value={500}>500</option>
              </select>
            </label>
          </div>
        </div>
        <div className="row-fluid fieldsets">
          <div className="checkbox inline">
            <input id="qoDescending" type="checkbox" onChange={this.toggleDescending.bind(this)} checked={this.props.descending} />
            <label htmlFor="qoDescending">Descending</label>
          </div>
          <div className="dropdown inline">
            <label htmlFor="qoSkip" className="drop-down">
              Skip
              <input value={this.props.skip} onChange={this.updateSkip.bind(this)} className="input-small" type="number" id="qoSkip" placeholder="# of rows" />
            </label>
          </div>
        </div>
      </div>
    );
  }
}
