Merge pull request #702 from mewtaylor/issue/teacher-reg-fixes

Fix GH-[695, 694, 693, 691] – Add custom validation for organization and phone
This commit is contained in:
Matthew Taylor 2016-07-07 17:02:44 -04:00 committed by GitHub
commit b02f243e26
3 changed files with 38 additions and 6 deletions

View file

@ -286,6 +286,14 @@ module.exports = {
waiting: false waiting: false
}; };
}, },
onValidSubmit: function (formData, reset, invalidate) {
if (formData.phone.national_number.length !== formData.phone.country_code.format.length) {
return invalidate({
'phone': this.props.intl.formatMessage({id: 'teacherRegistration.validationPhoneNumber'})
});
}
return this.props.onNextStep(formData);
},
render: function () { render: function () {
var formatMessage = this.props.intl.formatMessage; var formatMessage = this.props.intl.formatMessage;
return ( return (
@ -299,7 +307,7 @@ module.exports = {
tipContent={formatMessage({id: 'teacherRegistration.nameStepTooltip'})} /> tipContent={formatMessage({id: 'teacherRegistration.nameStepTooltip'})} />
</p> </p>
<Card> <Card>
<Form onValidSubmit={this.props.onNextStep}> <Form onValidSubmit={this.onValidSubmit}>
<PhoneInput label={formatMessage({id: 'teacherRegistration.phoneNumber'})} <PhoneInput label={formatMessage({id: 'teacherRegistration.phoneNumber'})}
name="phone" name="phone"
defaultCountry={this.props.defaultCountry} defaultCountry={this.props.defaultCountry}
@ -354,6 +362,14 @@ module.exports = {
onChooseOrganization: function (name, values) { onChooseOrganization: function (name, values) {
this.setState({otherDisabled: values.indexOf(this.organizationL10nStems.indexOf('orgChoiceOther')) === -1}); this.setState({otherDisabled: values.indexOf(this.organizationL10nStems.indexOf('orgChoiceOther')) === -1});
}, },
onValidSubmit: function (formData, reset, invalidate) {
if (formData.organization.type.length < 1) {
return invalidate({
'organization.type': this.props.intl.formatMessage({id: 'teacherRegistration.validationRequired'})
});
}
return this.props.onNextStep(formData);
},
render: function () { render: function () {
var formatMessage = this.props.intl.formatMessage; var formatMessage = this.props.intl.formatMessage;
return ( return (
@ -367,7 +383,7 @@ module.exports = {
tipContent={formatMessage({id: 'teacherRegistration.nameStepTooltip'})} /> tipContent={formatMessage({id: 'teacherRegistration.nameStepTooltip'})} />
</p> </p>
<Card> <Card>
<Form onValidSubmit={this.props.onNextStep}> <Form onValidSubmit={this.onValidSubmit}>
<Input label={formatMessage({id: 'teacherRegistration.organization'})} <Input label={formatMessage({id: 'teacherRegistration.organization'})}
type="text" type="text"
name="organization.name" name="organization.name"

View file

@ -20,6 +20,7 @@
"teacherRegistration.phoneNumber": "Phone Number", "teacherRegistration.phoneNumber": "Phone Number",
"teacherRegistration.phoneStepDescription": "Your phone number will not be displayed publicly, and will be kept confidential and secure", "teacherRegistration.phoneStepDescription": "Your phone number will not be displayed publicly, and will be kept confidential and secure",
"teacherRegistration.phoneConsent": "Yes, the Scratch Team may call me to verify my Teacher Account if needed", "teacherRegistration.phoneConsent": "Yes, the Scratch Team may call me to verify my Teacher Account if needed",
"teacherRegistration.validationPhoneNumber": "Please enter a valid phone number",
"teacherRegistration.validationPhoneConsent": "You must consent to verification of your Teacher Account", "teacherRegistration.validationPhoneConsent": "You must consent to verification of your Teacher Account",
"teacherRegistration.orgStepTitle": "Organization", "teacherRegistration.orgStepTitle": "Organization",
"teacherRegistration.orgStepDescription": "Your information will not be displayed publicly, and will be kept confidential and secure", "teacherRegistration.orgStepDescription": "Your information will not be displayed publicly, and will be kept confidential and secure",
@ -52,5 +53,6 @@
"teacherRegistration.howUseScratch": "How do you plan to use Scratch at your organization?", "teacherRegistration.howUseScratch": "How do you plan to use Scratch at your organization?",
"teacherRegistration.emailStepTitle": "Email Address", "teacherRegistration.emailStepTitle": "Email Address",
"teacherRegistration.emailStepDescription": "We will send you a confirmation email that will allow you to access your Scratch Teacher Account.", "teacherRegistration.emailStepDescription": "We will send you a confirmation email that will allow you to access your Scratch Teacher Account.",
"teacherRegistration.validationEmailMatch": "The emails do not match" "teacherRegistration.validationEmailMatch": "The emails do not match",
"teacherRegistration.validationRequired": "This field is required"
} }

View file

@ -30,7 +30,7 @@ body {
.address-step, .address-step,
.email-step { .email-step {
.help-block { .help-block {
transform: translate(15.5rem, -4rem); transform: translate(15.75rem, -4rem);
} }
} }
@ -40,7 +40,7 @@ body {
} }
.help-block { .help-block {
transform: translate(14rem, -4rem); transform: translate(13rem, -2rem);
} }
.radio { .radio {
@ -65,7 +65,7 @@ body {
} }
.help-block { .help-block {
margin-top: .7rem; margin-top: .5rem;
} }
.checkbox-row { .checkbox-row {
@ -80,6 +80,12 @@ body {
transform: translate(16rem, -4rem); transform: translate(16rem, -4rem);
} }
.checkbox-group {
.help-block {
transform: translate(16rem, -16rem);
}
}
.organization-type, .organization-type,
.url-input { .url-input {
p { p {
@ -100,6 +106,14 @@ body {
} }
} }
.address-step {
.select {
.help-block {
transform: translate(0, .5rem);
}
}
}
.usescratch-step { .usescratch-step {
.form { .form {
.form-group { .form-group {