[deck_multi] fixing issues with deck_multi (#4754)

* [deck_multi] fixing issues with deck_multi

* removing eslint comment
This commit is contained in:
Maxime Beauchemin
2018-04-04 16:52:14 -07:00
committed by GitHub
parent adda30bf66
commit 68999b1407
5 changed files with 50 additions and 84 deletions

View File

@@ -2,6 +2,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import Select from '../../../components/AsyncSelect';
import ControlHeader from '../ControlHeader';
import { t } from '../../../locales';
const propTypes = {
@@ -26,24 +27,27 @@ const defaultProps = {
placeholder: t('Select ...'),
};
const SelectAsyncControl = ({ value, onChange, dataEndpoint,
multi, mutator, placeholder, onAsyncErrorMessage }) => {
const SelectAsyncControl = (props) => {
const { value, onChange, dataEndpoint, multi, mutator, placeholder, onAsyncErrorMessage } = props;
const onSelectionChange = (options) => {
const optionValues = options.map(option => option.value);
onChange(optionValues);
};
return (
<Select
dataEndpoint={dataEndpoint}
onChange={onSelectionChange}
onAsyncError={errorMsg => notify.error(onAsyncErrorMessage + ': ' + errorMsg)}
mutator={mutator}
multi={multi}
value={value}
placeholder={placeholder}
valueRenderer={v => (<div>{v.label}</div>)}
/>
<div>
<ControlHeader {...props} />
<Select
dataEndpoint={dataEndpoint}
onChange={onSelectionChange}
onAsyncError={errorMsg => notify.error(onAsyncErrorMessage + ': ' + errorMsg)}
mutator={mutator}
multi={multi}
value={value}
placeholder={placeholder}
valueRenderer={v => (<div>{v.label}</div>)}
/>
</div>
);
};