/** @jsx React.DOM */
// FeatureList
// Feature
// - name
// - status
// - description
// - button-edit
// - button-delete
// - toggle-status
// FeatureForm
// StrategyList
// Strategy
// StrategyForm
var FeatureList = React.createClass({
getInitialState: function() {
return {
features: []
};
},
componentDidMount: function () {
reqwest('/features').then(this.setFeatures);
},
setFeatures: function (data) {
this.setState({features: data.features});
},
updateFeature: function (changeRequest) {
var newFeatures = this.state.features;
newFeatures.forEach(function(f){
if(f.name === changeRequest.name) {
f[changeRequest.field] = changeRequest.value;
}
});
console.log(changeRequest);
reqwest({
url: 'features/' + changeRequest.name,
method: 'patch',
type: 'json',
contentType: 'application/json',
data: JSON.stringify(changeRequest)
}).then(function() {
this.setState({features: newFeatures});
}.bind(this), function() {
alert("update failed");
}.bind(this));
},
render: function () {
var featureNodes = this.state.features.map(function (feature) {
return (
{this.props.feature.name}
{this.props.feature.description}