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
* overrides the default input validations
* - errors : array
* prevent from siplaying errors messages
* prevent from displaying errors messages
*
* Required
* - name : string
* - handleChange : function
* - target : string
* - value : string
* - 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>
<input
type="number"
name={this.props.name}
name={this.props.target}
id={this.props.name}
value={inputValue}
onBlur={handleBlur}
@ -124,6 +125,7 @@ InputNumber.propTypes = {
name: React.PropTypes.string.isRequired,
noErrorsDescription: React.PropTypes.bool,
placeholder: React.PropTypes.string,
target: React.PropTypes.string.isRequired,
validations: React.PropTypes.object.isRequired,
value: React.PropTypes.oneOfType([
React.PropTypes.number.isRequired,

View File

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

View File

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

View File

@ -8,7 +8,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { createStructuredSelector } from 'reselect';
import { findKey, includes } from 'lodash';
import { findKey, includes, get } from 'lodash';
import Helmet from 'react-helmet';
import { router } from 'app';
@ -30,6 +30,7 @@ export class Home extends React.Component { // eslint-disable-line react/prefer-
this.customComponents = config.customComponents;
this.components = {
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;
this.props.configFetch(apiUrl);
} 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);
} else {
// 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) {
// get data if params env updated