import React from 'react';
export default class extends React.Component {
isValidated() {
return typeof this.props.validation !== "undefined";
}
getClassName() {
let className = 'form-group';
if (this.isValidated()) {
className += ' has-feedback';
if (this.props.validation === null) {
className += ' has-success';
} else {
className += ' has-error';
}
}
return className;
}
getFeedback() {
if (this.props.validation) {
/* jshint ignore:start */
return
{this.props.validation.map((error, i) => {
return
{error}
;
})}
;
/* jshint ignore:end */
} else {
return null;
}
}
getFeedbackIcon() {
if (this.isValidated()) {
/* jshint ignore:start */
return
{this.props.validation ? 'clear' : 'check'}
;
/* jshint ignore:end */
} else {
return null;
}
}
getFeedbackDescription() {
if (this.isValidated()) {
/* jshint ignore:start */
return
{this.props.validation ? gettext('(error)') : gettext('(success)')}
;
/* jshint ignore:end */
} else {
return null;
}
}
getHelpText() {
if (this.props.helpText) {
/* jshint ignore:start */
return {this.props.helpText}
;
/* jshint ignore:end */
} else {
return null;
}
}
render() {
/* jshint ignore:start */
return
{this.props.children}
{this.getFeedbackIcon()}
{this.getFeedbackDescription()}
{this.getFeedback()}
{this.getHelpText()}
{this.props.extra || null}
/* jshint ignore:end */
}
}