diff --git a/public/js/components/strategy/CreateStrategy.jsx b/public/js/components/strategy/CreateStrategy.jsx new file mode 100644 index 0000000000..5dd6e7ff20 --- /dev/null +++ b/public/js/components/strategy/CreateStrategy.jsx @@ -0,0 +1,33 @@ +var React = require('react'); + +var CreateStrategy = React.createClass({ + + render: function() { + return ( +
+
+
+
+ New strategy +
+ +
+ +
+
+
+ + Add required parameter +
+
+ + +
+
+
+
+
+ ); + } +}); + +module.exports = CreateStrategy; \ No newline at end of file diff --git a/public/js/components/strategy/Strategy.jsx b/public/js/components/strategy/Strategy.jsx index 8a0e40d92f..d1fb019740 100644 --- a/public/js/components/strategy/Strategy.jsx +++ b/public/js/components/strategy/Strategy.jsx @@ -1,17 +1,19 @@ var React = require('react'); -var StrategyList = React.createClass({ +var Strategy = React.createClass({ propTypes: { - strategies: React.PropTypes.array.isRequired + strategy: React.PropTypes.object.isRequired }, render: function() { - return (
- - {JSON.stringify(this.props.strategies)} + return ( +
+
+ {this.props.strategy.name}
- ); +
+ ); } }); -module.exports = StrategyList; \ No newline at end of file +module.exports = Strategy; \ No newline at end of file diff --git a/public/js/components/strategy/StrategyComponent.jsx b/public/js/components/strategy/StrategyComponent.jsx index 9ed0893a0b..aa0a495f01 100644 --- a/public/js/components/strategy/StrategyComponent.jsx +++ b/public/js/components/strategy/StrategyComponent.jsx @@ -1,27 +1,71 @@ var React = require('react'), - strategyStore = require('../../stores/StrategyStore'); + StrategyList = require('./StrategyList'), + CreateStrategy = require('./CreateStrategy'), + strategyStore = require('../../stores/StrategyStore'), + ErrorMessages = require('../ErrorMessages'); var StrategyComponent = React.createClass({ getInitialState: function() { return { createView: false, - strategies: [] + strategies: [], + errors: [] }; }, componentDidMount: function () { strategyStore.getStrategies().then(function(res) { this.setState({strategies: res.strategies}); - }.bind(this)); + }.bind(this), this.initError); + }, + + initError: function() { + this.handleError("Could not load inital strategies from server"); + }, + + clearErrors: function() { + this.setState({errors: []}); + }, + + handleError: function(error) { + var errors = this.state.errors.concat([error]); + this.setState({errors: errors}); + }, + + handleNewStrategy: function() { + this.setState({createView: true}); + }, + + handleCancelNewStrategy: function() { + this.setState({createView: false}); }, render: function() { return (
-

Strategies

- {JSON.stringify(this.state.strategies)} +
+
+

Strategies

+
+ +
+ +
+
+ + + +
+ + {this.state.createView ? this.renderCreateView() : null} + +
); + }, + + renderCreateView: function() { + return () } }); diff --git a/public/js/components/strategy/StrategyList.jsx b/public/js/components/strategy/StrategyList.jsx index e69de29bb2..1d07d21698 100644 --- a/public/js/components/strategy/StrategyList.jsx +++ b/public/js/components/strategy/StrategyList.jsx @@ -0,0 +1,19 @@ +var React = require('react'), + Strategy = require('./Strategy'); + +var StrategyList = React.createClass({ + propTypes: { + strategies: React.PropTypes.array.isRequired + }, + + render: function() { + var strategyNodes = this.props.strategies.map(function(strategy) { + return ; + }); + return ( +
{strategyNodes}
+ ); + } +}); + +module.exports = StrategyList; \ No newline at end of file