'use strict'; const React = require('react'); const TextInput = require('../form/TextInput'); const StrategyForm = React.createClass({ getDefaultProps () { return { maxParams: 4, }; }, getInitialState () { return { parameters: [], }; }, onSubmit (evt) { evt.preventDefault(); const strategy = {}; strategy.name = this.refs.name.getValue(); strategy.description = this.refs.description.getValue(); strategy.parametersTemplate = {}; this.state.parameters.forEach(parameter => { const value = this.refs[parameter.name].getDOMNode().value.trim(); if (value) { strategy.parametersTemplate[value] = 'string'; } }); this.props.onSave(strategy); }, onCancel (evt) { evt.preventDefault(); this.props.onCancelNewStrategy(); }, onAddParam (evt) { evt.preventDefault(); const id = this.state.parameters.length + 1; const params = this.state.parameters.concat([{ id, name: `param_${id}`, label: `Parameter ${id}` }]); this.setState({ parameters: params }); }, onRemoveParam (evt) { evt.preventDefault(); const params = this.state.parameters.slice(0, -1); this.setState({ parameters: params }); }, render () { return (