Merge branch 'master' into fix/welcome-dashboard

This commit is contained in:
Jim LAURIE 2018-04-13 16:36:03 +02:00 committed by GitHub
commit 4a8ab72a55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 22 deletions

View File

@ -185,7 +185,7 @@ export default FooPage;
*** ***
## Input ## InputsIndex
Strapi provides a built-in input library which includes : Strapi provides a built-in input library which includes :
- All kind of inputs - All kind of inputs
@ -193,7 +193,6 @@ Strapi provides a built-in input library which includes :
- Error highlight - Error highlight
- i18n - i18n
> This component is likely to be deprecated in favor of InputsWithIndex
### Usage ### Usage
@ -202,6 +201,7 @@ Strapi provides a built-in input library which includes :
| `addon` | string | no | Allows to add a string addon in your input, based on [Bootstrap](https://v4-alpha.getbootstrap.com/components/input-group/#basic-example). Ex: `<Input {...this.props} addon="@" />` | | `addon` | string | no | Allows to add a string addon in your input, based on [Bootstrap](https://v4-alpha.getbootstrap.com/components/input-group/#basic-example). Ex: `<Input {...this.props} addon="@" />` |
| `addRequiredInputDesign` | bool | no | Allows to add an asterix on the input. Ex: `<Input {...this.props} addRequiredInputDesign />` | | `addRequiredInputDesign` | bool | no | Allows to add an asterix on the input. Ex: `<Input {...this.props} addRequiredInputDesign />` |
| `customBootstrapClass` | string | no | Allows to override the input bootstrap col system. Ex: `<Input {...this.props} customBootstrapClass="col-md-6 offset-md-6 pull-md-6" />` | | `customBootstrapClass` | string | no | Allows to override the input bootstrap col system. Ex: `<Input {...this.props} customBootstrapClass="col-md-6 offset-md-6 pull-md-6" />` |
| customInputs | Object | no | Allows to add a new input type |
| `deactivateErrorHighlight` | bool | no | Prevents from displaying error highlight in the input: Ex: `<Input {...this.props} deactivateErrorHighlight />` | | `deactivateErrorHighlight` | bool | no | Prevents from displaying error highlight in the input: Ex: `<Input {...this.props} deactivateErrorHighlight />` |
| `didCheckErrors` | bool | no | Use this props to display errors after submitting a form. Ex: `<Input {...this.props} didCheckErrors={this.state.error} />` | | `didCheckErrors` | bool | no | Use this props to display errors after submitting a form. Ex: `<Input {...this.props} didCheckErrors={this.state.error} />` |
| `disabled` | bool | no | Disable the input. Ex: `<Input {...this.props} disabled />` | | `disabled` | bool | no | Disable the input. Ex: `<Input {...this.props} disabled />` |
@ -228,7 +228,15 @@ Strapi provides a built-in input library which includes :
import React from 'react'; import React from 'react';
// Make sure you don't have a component called Input inside your ./components folder // Make sure you don't have a component called Input inside your ./components folder
// It will import the one in your components folder instead. // It will import the one in your components folder instead.
import Input from 'components/Input'; import Input from 'components/InputsIndex';
const CustomInput = (props) => {
return (
<div>
Some custom input
</div>
);
}
class FooPage extends React.Component { class FooPage extends React.Component {
constructor(props) { constructor(props) {
@ -256,17 +264,32 @@ class FooPage extends React.Component {
} }
render() { render() {
const inputs = [
{
label: 'This is a string input',
name: 'foo',
type: 'string',
validations: { required: true },
value: this.state.data.foo,
},
{
label: 'This is a custom input',
name: 'custom',
type: 'newType',
validations: {},
value: '',
}
]
return ( return (
<div className={styles.fooPage}> <div className={styles.fooPage}>
<Input {inputs.map(input => (
type="string" <Input
value={this.state.data.foo} key={input.name}
label="This is a string input" didCheckErrors={this.state.error}
name="foo" onChange={this.handleChange}
onChange={this.handleChange} {...input}
validations={{ required: true }} />
didCheckErrors={this.state.error} ))}
/>
</div> </div>
); );
} }

View File

@ -6,7 +6,7 @@
/* eslint-disable react/require-default-props */ /* eslint-disable react/require-default-props */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { isEmpty } from 'lodash'; import { isEmpty, merge } from 'lodash';
import Loadable from 'react-loadable'; import Loadable from 'react-loadable';
// Design // Design
import InputAddonWithErrors from 'components/InputAddonWithErrors'; import InputAddonWithErrors from 'components/InputAddonWithErrors';
@ -65,6 +65,8 @@ function InputsIndex(props) {
inputValue = props.value || ''; inputValue = props.value || '';
} }
merge(inputs, props.customInputs);
const Input = inputs[type] ? inputs[type] : DefaultInputError; const Input = inputs[type] ? inputs[type] : DefaultInputError;
return <Input {...props} value={inputValue} />; return <Input {...props} value={inputValue} />;
@ -76,6 +78,7 @@ DefaultInputError.propTypes = {
InputsIndex.defaultProps = { InputsIndex.defaultProps = {
addon: false, addon: false,
customInputs: {},
}; };
InputsIndex.propTypes = { InputsIndex.propTypes = {
@ -83,6 +86,7 @@ InputsIndex.propTypes = {
PropTypes.bool, PropTypes.bool,
PropTypes.string, PropTypes.string,
]), ]),
customInputs: PropTypes.object,
type: PropTypes.string.isRequired, type: PropTypes.string.isRequired,
value: PropTypes.any, value: PropTypes.any,
}; };

View File

@ -32,6 +32,14 @@
"policies": [] "policies": []
} }
}, },
{
"method": "GET",
"path": "/files/count",
"handler": "Upload.count",
"config": {
"policies": []
}
},
{ {
"method": "GET", "method": "GET",
"path": "/files", "path": "/files",
@ -48,14 +56,6 @@
"policies": [] "policies": []
} }
}, },
{
"method": "GET",
"path": "/files/count",
"handler": "Upload.count",
"config": {
"policies": []
}
},
{ {
"method": "GET", "method": "GET",
"path": "/search/:id", "path": "/search/:id",