add target props to inputs

This commit is contained in:
cyril lopez 2017-07-19 09:51:23 +02:00
parent bb72051202
commit c1d955beb4
4 changed files with 13 additions and 10 deletions

View File

@ -9,11 +9,12 @@
* - handleBlur: function * - handleBlur: function
* overrides the default input validations * overrides the default input validations
* - errors : array * - errors : array
* prevent from siplaying errors messages * prevent from displaying errors messages
* *
* Required * Required
* - name : string * - name : string
* - handleChange : function * - handleChange : function
* - target : string
* - value : string * - value : string
* - validations : object * - validations : object
* *
@ -94,7 +95,7 @@ class InputNumber extends React.Component { // eslint-disable-line react/prefer-
<label htmlFor={this.props.name}>{this.props.name}</label> <label htmlFor={this.props.name}>{this.props.name}</label>
<input <input
type="number" type="number"
name={this.props.name} name={this.props.target}
id={this.props.name} id={this.props.name}
value={inputValue} value={inputValue}
onBlur={handleBlur} onBlur={handleBlur}
@ -124,6 +125,7 @@ InputNumber.propTypes = {
name: React.PropTypes.string.isRequired, name: React.PropTypes.string.isRequired,
noErrorsDescription: React.PropTypes.bool, noErrorsDescription: React.PropTypes.bool,
placeholder: React.PropTypes.string, placeholder: React.PropTypes.string,
target: React.PropTypes.string.isRequired,
validations: React.PropTypes.object.isRequired, validations: React.PropTypes.object.isRequired,
value: React.PropTypes.oneOfType([ value: React.PropTypes.oneOfType([
React.PropTypes.number.isRequired, React.PropTypes.number.isRequired,

View File

@ -10,14 +10,14 @@
* overrides the default input validations * overrides the default input validations
* - errors : array * - errors : array
* - noErrorsDescription : bool * - noErrorsDescription : bool
* prevent from siplaying errors messages * prevent from displaying errors messages
* *
* Required * Required
* - name : string * - name : string
* - handleChange : function * - handleChange : function
* - value : string * - value : string
* - validations : object
* - target : string * - target : string
* - validations : object
* *
* Optionnal * Optionnal
* - description : input description * - description : input description

View File

@ -7,7 +7,7 @@
* *
* Required * Required
* - handleChange: function * - handleChange: function
* - name: string * - target: string
* - isChecked: bool * - isChecked: bool
*/ */
@ -37,7 +37,7 @@ class InputToggle extends React.Component { // eslint-disable-line react/prefer-
isChecked = false; isChecked = false;
} }
const target = { const target = {
name: this.props.name, name: this.props.target,
value: isChecked, value: isChecked,
}; };
this.setState({ isChecked }); this.setState({ isChecked });
@ -63,7 +63,7 @@ InputToggle.propTypes = {
customBootstrapClass: React.PropTypes.string, customBootstrapClass: React.PropTypes.string,
handleChange: React.PropTypes.func.isRequired, handleChange: React.PropTypes.func.isRequired,
isChecked: React.PropTypes.bool.isRequired, isChecked: React.PropTypes.bool.isRequired,
name: React.PropTypes.string.isRequired, target: React.PropTypes.string.isRequired,
} }
export default InputToggle; export default InputToggle;

View File

@ -8,7 +8,7 @@ import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { createStructuredSelector } from 'reselect'; import { createStructuredSelector } from 'reselect';
import { findKey, includes } from 'lodash'; import { findKey, includes, get } from 'lodash';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import { router } from 'app'; import { router } from 'app';
@ -30,6 +30,7 @@ export class Home extends React.Component { // eslint-disable-line react/prefer-
this.customComponents = config.customComponents; this.customComponents = config.customComponents;
this.components = { this.components = {
editForm: EditForm, editForm: EditForm,
div: EditForm, // TODO change to default
}; };
} }
@ -38,7 +39,7 @@ export class Home extends React.Component { // eslint-disable-line react/prefer-
const apiUrl = this.props.params.env ? `${this.props.params.slug}/${this.props.params.env}` : this.props.params.slug; const apiUrl = this.props.params.env ? `${this.props.params.slug}/${this.props.params.env}` : this.props.params.slug;
this.props.configFetch(apiUrl); this.props.configFetch(apiUrl);
} else { } else {
router.push(`/plugins/settings-manager/${this.props.sections[0].items[0].slug}`); router.push(`/plugins/settings-manager/${get(this.props.sections, ['0', 'items', '0', 'slug'])}`);
} }
} }
@ -52,7 +53,7 @@ export class Home extends React.Component { // eslint-disable-line react/prefer-
this.props.configFetch(apiUrl); this.props.configFetch(apiUrl);
} else { } else {
// redirect user if no params slug provided // redirect user if no params slug provided
router.push(`/plugins/settings-manager/${this.props.sections[0].items[0].slug}`); router.push(`/plugins/settings-manager/${get(this.props.sections, ['0', 'items', '0', 'slug'])}`);
} }
} else if (this.props.params.env !== nextProps.params.env && nextProps.params.env) { } else if (this.props.params.env !== nextProps.params.env && nextProps.params.env) {
// get data if params env updated // get data if params env updated