mirror of
https://github.com/strapi/strapi.git
synced 2026-01-08 13:17:47 +00:00
specific imports for lodash
This commit is contained in:
parent
aa924aec70
commit
edd1b91f2b
@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { isEmpty, map, pick } from 'lodash';
|
||||
import styles from './styles.scss';
|
||||
|
||||
class InputNumber extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||||
@ -45,7 +46,7 @@ class InputNumber extends React.Component { // eslint-disable-line react/prefer-
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.errors !== nextProps.errors) {
|
||||
let errors = false;
|
||||
if (_.isEmpty(nextProps.errors)) {
|
||||
if (isEmpty(nextProps.errors)) {
|
||||
errors = nextProps.errors === true ? [] : false;
|
||||
} else {
|
||||
errors = nextProps.errors;
|
||||
@ -65,7 +66,7 @@ class InputNumber extends React.Component { // eslint-disable-line react/prefer-
|
||||
}
|
||||
|
||||
validate = (value) => {
|
||||
const errors = !_.isEmpty(_.pick(this.props.validations, 'required')) && value.length > 0 ?
|
||||
const errors = !isEmpty(pick(this.props.validations, 'required')) && value.length > 0 ?
|
||||
false : ['This field is required'];
|
||||
return errors;
|
||||
}
|
||||
@ -94,7 +95,7 @@ class InputNumber extends React.Component { // eslint-disable-line react/prefer-
|
||||
placeholder={placeholder}
|
||||
/>
|
||||
<small>{this.props.inputDescription}</small>
|
||||
{_.map(this.state.errors, (error, key) => (
|
||||
{map(this.state.errors, (error, key) => (
|
||||
<div key={key} className="form-control-feedback">{error}</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { isEmpty, includes, mapKeys, reject, map } from 'lodash';
|
||||
import styles from './styles.scss';
|
||||
|
||||
class InputText extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||||
@ -44,7 +45,7 @@ class InputText extends React.Component { // eslint-disable-line react/prefer-st
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.errors !== nextProps.errors) {
|
||||
let errors = false;
|
||||
if (_.isEmpty(nextProps.errors)) {
|
||||
if (isEmpty(nextProps.errors)) {
|
||||
errors = nextProps.errors === true ? [] : false;
|
||||
} else {
|
||||
errors = nextProps.errors;
|
||||
@ -67,7 +68,7 @@ class InputText extends React.Component { // eslint-disable-line react/prefer-st
|
||||
validate = (value) => {
|
||||
let errors = [];
|
||||
const requiredError = 'Field is required';
|
||||
_.mapKeys(this.props.validations, (validationValue, validationKey) => {
|
||||
mapKeys(this.props.validations, (validationValue, validationKey) => {
|
||||
switch (validationKey) {
|
||||
case 'maxLength':
|
||||
if (value.length > validationValue) {
|
||||
@ -94,10 +95,10 @@ class InputText extends React.Component { // eslint-disable-line react/prefer-st
|
||||
}
|
||||
});
|
||||
|
||||
if (_.isEmpty(errors)) {
|
||||
if (isEmpty(errors)) {
|
||||
errors = false;
|
||||
} else if (_.includes(errors, requiredError)) {
|
||||
errors = _.reject(errors, (error) => error !== requiredError);
|
||||
} else if (includes(errors, requiredError)) {
|
||||
errors = reject(errors, (error) => error !== requiredError);
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
@ -126,7 +127,7 @@ class InputText extends React.Component { // eslint-disable-line react/prefer-st
|
||||
placeholder={placeholder}
|
||||
/>
|
||||
<small>{this.props.inputDescription}</small>
|
||||
{_.map(this.state.errors, (error, key) => (
|
||||
{map(this.state.errors, (error, key) => (
|
||||
<div key={key} className="form-control-feedback">{error}</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { map } from 'lodash';
|
||||
import PluginLeftMenuSection from 'components/PluginLeftMenuSection';
|
||||
import styles from './styles.scss';
|
||||
|
||||
@ -17,7 +17,7 @@ class PluginLeftMenu extends React.Component { // eslint-disable-line react/pref
|
||||
render() {
|
||||
return (
|
||||
<div className={`${styles.pluginLeftMenu} col-md-3`}>
|
||||
{_.map(this.props.sections, (section, index) => (
|
||||
{map(this.props.sections, (section, index) => (
|
||||
<PluginLeftMenuSection key={index} section={section} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { takeLatest } from 'redux-saga';
|
||||
import { LOCATION_CHANGE } from 'react-router-redux';
|
||||
import { put, fork } from 'redux-saga/effects';
|
||||
|
||||
import { fetchMenuSucceeded } from './actions';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user