Commit 6f9c16a7 authored by Ray Schamp's avatar Ray Schamp Committed by GitHub

Merge pull request #667 from rschamp/bugfix/647

Add style to general error messages
parents 0d239647 d990dee7
...@@ -2,7 +2,6 @@ var classNames = require('classnames'); ...@@ -2,7 +2,6 @@ var classNames = require('classnames');
var Formsy = require('formsy-react'); var Formsy = require('formsy-react');
var omit = require('lodash.omit'); var omit = require('lodash.omit');
var React = require('react'); var React = require('react');
var GeneralError = require('./general-error.jsx');
var validations = require('./validations.jsx').validations; var validations = require('./validations.jsx').validations;
for (var validation in validations) { for (var validation in validations) {
...@@ -32,8 +31,13 @@ var Form = React.createClass({ ...@@ -32,8 +31,13 @@ var Form = React.createClass({
); );
return ( return (
<Formsy.Form {... this.props} className={classes} ref="formsy" onChange={this.onChange}> <Formsy.Form {... this.props} className={classes} ref="formsy" onChange={this.onChange}>
<GeneralError name="all" value={this.state.allValues} /> {React.Children.map(this.props.children, function (child) {
{this.props.children} if (child.props.name === 'all') {
return React.cloneElement(child, {value: this.state.allValues});
} else {
return child;
}
}.bind(this))}
</Formsy.Form> </Formsy.Form>
); );
} }
......
var Formsy = require('formsy-react'); var Formsy = require('formsy-react');
var React = require('react'); var React = require('react');
require('./general-error.scss');
/* /*
* A special formsy-react component that only outputs * A special formsy-react component that only outputs
* error messages. If you want to display errors that * error messages. If you want to display errors that
...@@ -12,7 +14,7 @@ module.exports = Formsy.HOC(React.createClass({ ...@@ -12,7 +14,7 @@ module.exports = Formsy.HOC(React.createClass({
render: function () { render: function () {
if (!this.props.showError()) return null; if (!this.props.showError()) return null;
return ( return (
<p className="error"> <p className="general-error">
{this.props.getErrorMessage()} {this.props.getErrorMessage()}
</p> </p>
); );
......
@import "../../colors";
.general-error {
border: 1px solid $active-gray;
border-radius: 4px;
background-color: $ui-orange;
padding: 1rem;
color: $type-white;
}
...@@ -12,6 +12,7 @@ var CharCount = require('../../components/forms/charcount.jsx'); ...@@ -12,6 +12,7 @@ var CharCount = require('../../components/forms/charcount.jsx');
var Checkbox = require('../../components/forms/checkbox.jsx'); var Checkbox = require('../../components/forms/checkbox.jsx');
var CheckboxGroup = require('../../components/forms/checkbox-group.jsx'); var CheckboxGroup = require('../../components/forms/checkbox-group.jsx');
var Form = require('../../components/forms/form.jsx'); var Form = require('../../components/forms/form.jsx');
var GeneralError = require('../../components/forms/general-error.jsx');
var Input = require('../../components/forms/input.jsx'); var Input = require('../../components/forms/input.jsx');
var PhoneInput = require('../../components/forms/phone-input.jsx'); var PhoneInput = require('../../components/forms/phone-input.jsx');
var RadioGroup = require('../../components/forms/radio-group.jsx'); var RadioGroup = require('../../components/forms/radio-group.jsx');
...@@ -148,6 +149,7 @@ module.exports = { ...@@ -148,6 +149,7 @@ module.exports = {
onChange={this.onChangeShowPassword} onChange={this.onChangeShowPassword}
help={null} help={null}
name="showPassword" /> name="showPassword" />
<GeneralError name="all" />
<NextStepButton waiting={this.props.waiting || this.state.waiting} <NextStepButton waiting={this.props.waiting || this.state.waiting}
text={<intl.FormattedMessage id="teacherRegistration.nextStep" />} /> text={<intl.FormattedMessage id="teacherRegistration.nextStep" />} />
</Form> </Form>
...@@ -508,6 +510,7 @@ module.exports = { ...@@ -508,6 +510,7 @@ module.exports = {
type="text" type="text"
name="address.zip" name="address.zip"
required /> required />
<GeneralError name="all" />
<NextStepButton waiting={this.props.waiting || this.state.waiting} <NextStepButton waiting={this.props.waiting || this.state.waiting}
text={<intl.FormattedMessage id="teacherRegistration.nextStep" />} /> text={<intl.FormattedMessage id="teacherRegistration.nextStep" />} />
</Form> </Form>
...@@ -631,6 +634,7 @@ module.exports = { ...@@ -631,6 +634,7 @@ module.exports = {
equalsField: formatMessage({id: 'general.validationEmailMatch'}) equalsField: formatMessage({id: 'general.validationEmailMatch'})
}} }}
required /> required />
<GeneralError name="all" />
<NextStepButton waiting={this.props.waiting} <NextStepButton waiting={this.props.waiting}
text={<intl.FormattedMessage id="teacherRegistration.nextStep" />} /> text={<intl.FormattedMessage id="teacherRegistration.nextStep" />} />
</Form> </Form>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment