fix: deprecate inconsistent config param case (#4172)

This commit is contained in:
andreascm
2020-08-31 19:25:48 +08:00
committed by GitHub
parent f1376aa5c3
commit 88a5a8098e
31 changed files with 409 additions and 144 deletions

View File

@ -69,7 +69,7 @@ export default class NumberControl extends React.Component {
};
handleChange = e => {
const valueType = this.props.field.get('valueType');
const valueType = this.props.field.get('value_type');
const { onChange } = this.props;
const value = valueType === 'float' ? parseFloat(e.target.value) : parseInt(e.target.value, 10);
@ -99,7 +99,7 @@ export default class NumberControl extends React.Component {
const { field, value, classNameWrapper, forID, setActiveStyle, setInactiveStyle } = this.props;
const min = field.get('min', '');
const max = field.get('max', '');
const step = field.get('step', field.get('valueType') === 'int' ? 1 : '');
const step = field.get('step', field.get('value_type') === 'int' ? 1 : '');
return (
<input
type="number"

View File

@ -10,7 +10,7 @@ const fieldSettings = {
min: -20,
max: 20,
step: 1,
valueType: 'int',
value_type: 'int',
};
class NumberController extends React.Component {
@ -120,7 +120,7 @@ describe('Number widget', () => {
});
it('should parse float numbers as float', () => {
const field = fromJS({ ...fieldSettings, valueType: 'float' });
const field = fromJS({ ...fieldSettings, value_type: 'float' });
const testValue = (Math.random() * (20 - -20 + 1) + -20).toFixed(2);
const { input, onChangeSpy } = setup({ field });

View File

@ -1,7 +1,7 @@
export default {
properties: {
step: { type: 'number' },
valueType: { type: 'string' },
value_type: { type: 'string' },
min: { type: 'number' },
max: { type: 'number' },
},