From 103c3d941fd8e240b9f118f99c73e48e0a94c176 Mon Sep 17 00:00:00 2001 From: ivaosthu Date: Tue, 7 May 2019 20:44:29 +0200 Subject: [PATCH] feat: boolean strategy paramters --- .../feature/form/strategy-configure.jsx | 38 ++++++++++++++++++- .../src/component/strategies/add-strategy.jsx | 1 + 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/frontend/src/component/feature/form/strategy-configure.jsx b/frontend/src/component/feature/form/strategy-configure.jsx index 0bd5397ec2..67bc688da3 100644 --- a/frontend/src/component/feature/form/strategy-configure.jsx +++ b/frontend/src/component/feature/form/strategy-configure.jsx @@ -1,6 +1,18 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { Textfield, Button, Card, CardTitle, CardText, CardActions, CardMenu, IconButton, Icon } from 'react-mdl'; +import { + Textfield, + Button, + Card, + CardTitle, + CardText, + CardActions, + CardMenu, + IconButton, + Icon, + Switch, + Tooltip, +} from 'react-mdl'; import { DragSource, DropTarget } from 'react-dnd'; import { Link } from 'react-router-dom'; import StrategyInputPercentage from './strategy-input-percentage'; @@ -60,6 +72,11 @@ class StrategyConfigure extends React.Component { this.setConfig(key, e.target.value); }; + handleSwitchChange = (key, currentValue) => { + const value = currentValue === 'false' ? 'true' : 'false'; + this.setConfig(key, value); + }; + setConfig = (key, value) => { const parameters = this.props.strategy.parameters || {}; parameters[key] = value; @@ -130,6 +147,25 @@ class StrategyConfigure extends React.Component { {description &&

{description}

} ); + } else if (type === 'boolean') { + if (!value) { + this.handleSwitchChange(name, value); + } + return ( +
+ + {name}{' '} + {description && ( + + + + )} + +
+ ); } else { return (
diff --git a/frontend/src/component/strategies/add-strategy.jsx b/frontend/src/component/strategies/add-strategy.jsx index ef6ca9b5f1..bbc1a35b6a 100644 --- a/frontend/src/component/strategies/add-strategy.jsx +++ b/frontend/src/component/strategies/add-strategy.jsx @@ -47,6 +47,7 @@ const Parameter = ({ set, input = {}, index }) => ( set({ type: 'percentage' })}>percentage set({ type: 'list' })}>list set({ type: 'number' })}>number + set({ type: 'boolean' })}>boolean