2014-10-30 18:25:38 +01:00
|
|
|
var React = require('react');
|
2014-11-12 15:00:11 +01:00
|
|
|
var FeatureForm = require('./FeatureForm');
|
2014-10-30 18:25:38 +01:00
|
|
|
|
2014-11-03 13:54:06 +01:00
|
|
|
var Feature = React.createClass({
|
2014-11-12 15:00:11 +01:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
editMode: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
toggleEditMode: function() {
|
|
|
|
this.setState({editMode: !this.state.editMode});
|
|
|
|
},
|
|
|
|
|
|
|
|
saveFeature: function(feature) {
|
2014-10-30 18:25:38 +01:00
|
|
|
this.props.onChange({
|
2014-11-12 15:00:11 +01:00
|
|
|
name: feature.name,
|
2014-10-30 18:25:38 +01:00
|
|
|
field: 'enabled',
|
2014-11-12 15:00:11 +01:00
|
|
|
value: feature.enabled
|
2014-10-30 18:25:38 +01:00
|
|
|
});
|
2014-11-12 15:00:11 +01:00
|
|
|
this.toggleEditMode();
|
2014-10-30 18:25:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2014-11-12 15:00:11 +01:00
|
|
|
return (<div className='line mal'>
|
|
|
|
{this.state.editMode ? this.renderEditMode() : this.renderViewMode()}
|
|
|
|
</div>);
|
|
|
|
},
|
2014-10-31 10:30:23 +01:00
|
|
|
|
2014-11-12 15:00:11 +01:00
|
|
|
renderEditMode: function() {
|
|
|
|
return (<FeatureForm feature={this.props.feature} onSubmit={this.saveFeature} onCancel={this.toggleEditMode} />);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
renderViewMode: function() {
|
|
|
|
var strikeThrough = this.props.feature.enabled ? '' : 'strikethrough';
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div className={'unit r-size1of5 ' + strikeThrough}>
|
2014-10-31 10:30:23 +01:00
|
|
|
{this.props.feature.name}
|
|
|
|
</div>
|
|
|
|
|
2014-11-10 16:21:22 +01:00
|
|
|
<div className='unit r-size2of5 opaque smalltext truncate'>
|
|
|
|
{this.props.feature.description || '\u00a0'}
|
|
|
|
</div>
|
|
|
|
|
2014-11-12 15:00:11 +01:00
|
|
|
<div className='unit r-size1of5'>
|
2014-10-30 18:25:38 +01:00
|
|
|
{this.props.feature.strategy}
|
|
|
|
</div>
|
2014-11-12 15:00:11 +01:00
|
|
|
|
|
|
|
<div className='unit r-size1of5'>
|
|
|
|
<input type='button' value='Edit' onClick={this.toggleEditMode}/>
|
|
|
|
</div>
|
2014-10-30 18:25:38 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-11-03 13:54:06 +01:00
|
|
|
module.exports = Feature;
|