From 806c9bcea7fbb36902c70cf5bbdc7b5e6c82f721 Mon Sep 17 00:00:00 2001 From: ivaosthu Date: Sat, 1 Nov 2014 17:17:07 +0100 Subject: [PATCH] CreateStrategy form now supports multiple params #34 --- .../js/components/strategy/CreateStrategy.jsx | 41 ++++++++++++++++--- .../components/strategy/StrategyComponent.jsx | 22 +++++----- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/public/js/components/strategy/CreateStrategy.jsx b/public/js/components/strategy/CreateStrategy.jsx index 5dd6e7ff20..3e61f4e6f7 100644 --- a/public/js/components/strategy/CreateStrategy.jsx +++ b/public/js/components/strategy/CreateStrategy.jsx @@ -2,21 +2,52 @@ var React = require('react'); var CreateStrategy = React.createClass({ + getInitialState: function() { + return { + parameters: [] + }; + }, + + + onSubmit: function(event) { + event.preventDefault(); + console.log(event); + }, + + handleAddParam: function(event) { + event.preventDefault(); + var id = this.state.parameters.length + 1; + var params = this.state.parameters.concat([{id:id, name: "param_" + id, label: "Parameter " +id}]); + this.setState({parameters: params}); + }, + render: function() { + var parameters = (this.state.parameters.map(function(param) { + return
+ +
+ +
+
+ })); + return ( -
+
-
+
- New strategy + Create strategy
-
+
+ + {parameters} +
diff --git a/public/js/components/strategy/StrategyComponent.jsx b/public/js/components/strategy/StrategyComponent.jsx index aa0a495f01..b72a38fbd1 100644 --- a/public/js/components/strategy/StrategyComponent.jsx +++ b/public/js/components/strategy/StrategyComponent.jsx @@ -43,21 +43,11 @@ var StrategyComponent = React.createClass({ render: function() { return (
-
-
-

Strategies

-
- -
- -
-
- -
+ {this.state.createView ? this.renderCreateView() : this.renderCreateButton()} - {this.state.createView ? this.renderCreateView() : null} +
@@ -66,6 +56,14 @@ var StrategyComponent = React.createClass({ renderCreateView: function() { return () + }, + + renderCreateButton: function() { + return ( +

+ +

+ ); } });