1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

Add slider for strategy-type 'percentage'

This commit is contained in:
ivaosthu 2016-12-10 16:03:53 +01:00
parent 87fe8f5c66
commit 57565185b0
2 changed files with 37 additions and 12 deletions

View File

@ -1,6 +1,7 @@
import React, { PropTypes } from 'react';
import { Textfield, Button, Card, CardTitle, CardText, CardActions, CardMenu, IconButton } from 'react-mdl';
import { Link } from 'react-router';
import StrategyInputPersentage from './strategy-input-persentage';
const style = {
flex: '1',
@ -39,18 +40,27 @@ class StrategyConfigure extends React.Component {
if (keys.length === 0) {
return null;
}
return keys.map(field => (
<Textfield
floatingLabel
rows={2}
style={{ width: '100%' }}
key={field}
name={field}
label={field}
onChange={this.handleConfigChange.bind(this, field)}
value={this.props.strategy.parameters[field]}
/>
));
return keys.map(field => {
if (strategyDefinition.parametersTemplate[field] === 'percentage') {
return (<StrategyInputPersentage
field={field}
onChange={this.handleConfigChange.bind(this, field)}
value={this.props.strategy.parameters[field]} />);
} else {
return (
<Textfield
floatingLabel
rows={2}
style={{ width: '100%' }}
key={field}
name={field}
label={field}
onChange={this.handleConfigChange.bind(this, field)}
value={this.props.strategy.parameters[field]}
/>
);
}
});
}
return null;
}

View File

@ -0,0 +1,15 @@
import React from 'react';
import { Slider } from 'react-mdl';
const labelStyle = {
margin: '0',
color: '#3f51b5',
fontSize: '12px',
};
export default ({ field, value, onChange }) => (
<div>
<label style={labelStyle}>{field}: {value}%</label>
<Slider min={0} max={100} defaultValue={value} value={value} onChange={onChange} label={field} />
</div>
);