Commit e791c0a8 authored by Matthew Taylor's avatar Matthew Taylor

Merge branch 'issue/gh-835' of https://github.com/mewtaylor/scratch-www-1 into develop

* 'issue/gh-835' of https://github.com/mewtaylor/scratch-www-1:
  Switch ordering
  Remove `option` warning in console
  Add `maxLength` validations where needed

# Conflicts:
#	src/components/registration/steps.jsx
parents 2db7097b 61ef3c2c
...@@ -27,9 +27,16 @@ var Tooltip = require('../../components/tooltip/tooltip.jsx'); ...@@ -27,9 +27,16 @@ var Tooltip = require('../../components/tooltip/tooltip.jsx');
require('./steps.scss'); require('./steps.scss');
var DEFAULT_COUNTRY = 'us'; var DEFAULT_COUNTRY = 'us';
var getCountryOptions = function (defaultCountry) {
/**
* Return a list of options to give to frc select
* @param {Object} intl react-intl, used to localize strings
* @param {String} defaultCountry optional string of default country to put at top of list
* @return {Object} ordered set of county options formatted for frc select
*/
var getCountryOptions = function (intl, defaultCountry) {
var options = countryData.countryOptions.concat({ var options = countryData.countryOptions.concat({
label: <intl.FormattedMessage id="registration.selectCountry" />, label: intl.formatMessage({id: 'registration.selectCountry'}),
disabled: true, disabled: true,
selected: true selected: true
}); });
...@@ -351,13 +358,21 @@ module.exports = { ...@@ -351,13 +358,21 @@ module.exports = {
<div className="gender-input"> <div className="gender-input">
<Input name="user.genderOther" <Input name="user.genderOther"
type="text" type="text"
validations={{
maxLength: 25
}}
validationErrors={{
maxLength: formatMessage({
id: 'registration.validationMaxLength'
})
}}
disabled={this.state.otherDisabled} disabled={this.state.otherDisabled}
required={!this.state.otherDisabled} required={!this.state.otherDisabled}
help={null} /> help={null} />
</div> </div>
<Select label={formatMessage({id: 'general.country'})} <Select label={formatMessage({id: 'general.country'})}
name="user.country" name="user.country"
options={getCountryOptions(DEFAULT_COUNTRY)} options={getCountryOptions(this.props.intl, DEFAULT_COUNTRY)}
required /> required />
<Checkbox className="demographics-checkbox-is-robot" <Checkbox className="demographics-checkbox-is-robot"
label="I'm a robot!" label="I'm a robot!"
...@@ -394,10 +409,26 @@ module.exports = { ...@@ -394,10 +409,26 @@ module.exports = {
<Input label={formatMessage({id: 'teacherRegistration.firstName'})} <Input label={formatMessage({id: 'teacherRegistration.firstName'})}
type="text" type="text"
name="user.name.first" name="user.name.first"
validations={{
maxLength: 50
}}
validationErrors={{
maxLength: formatMessage({
id: 'registration.validationMaxLength'
})
}}
required /> required />
<Input label={formatMessage({id: 'teacherRegistration.lastName'})} <Input label={formatMessage({id: 'teacherRegistration.lastName'})}
type="text" type="text"
name="user.name.last" name="user.name.last"
validations={{
maxLength: 50
}}
validationErrors={{
maxLength: formatMessage({
id: 'registration.validationMaxLength'
})
}}
required /> required />
<NextStepButton waiting={this.props.waiting} <NextStepButton waiting={this.props.waiting}
text={<intl.FormattedMessage id="registration.nextStep" />} /> text={<intl.FormattedMessage id="registration.nextStep" />} />
...@@ -508,10 +539,26 @@ module.exports = { ...@@ -508,10 +539,26 @@ module.exports = {
<Input label={formatMessage({id: 'teacherRegistration.organization'})} <Input label={formatMessage({id: 'teacherRegistration.organization'})}
type="text" type="text"
name="organization.name" name="organization.name"
validations={{
maxLength: 50
}}
validationErrors={{
maxLength: formatMessage({
id: 'registration.validationMaxLength'
})
}}
required /> required />
<Input label={formatMessage({id: 'teacherRegistration.orgTitle'})} <Input label={formatMessage({id: 'teacherRegistration.orgTitle'})}
type="text" type="text"
name="organization.title" name="organization.title"
validations={{
maxLength: 50
}}
validationErrors={{
maxLength: formatMessage({
id: 'registration.validationMaxLength'
})
}}
required /> required />
<div className="organization-type"> <div className="organization-type">
<b><intl.FormattedMessage id="teacherRegistration.orgType" /></b> <b><intl.FormattedMessage id="teacherRegistration.orgType" /></b>
...@@ -535,6 +582,14 @@ module.exports = { ...@@ -535,6 +582,14 @@ module.exports = {
<div className="other-input"> <div className="other-input">
<Input name="organization.other" <Input name="organization.other"
type="text" type="text"
validations={{
maxLength: 50
}}
validationErrors={{
maxLength: formatMessage({
id: 'registration.validationMaxLength'
})
}}
disabled={this.state.otherDisabled} disabled={this.state.otherDisabled}
required={!this.state.otherDisabled} required={!this.state.otherDisabled}
help={null} help={null}
...@@ -547,6 +602,14 @@ module.exports = { ...@@ -547,6 +602,14 @@ module.exports = {
</p> </p>
<Input type="url" <Input type="url"
name="organization.url" name="organization.url"
validations={{
maxLength: 200
}}
validationErrors={{
maxLength: formatMessage({
id: 'registration.validationMaxLength'
})
}}
required="isFalse" required="isFalse"
placeholder={'http://'} /> placeholder={'http://'} />
</div> </div>
...@@ -623,21 +686,45 @@ module.exports = { ...@@ -623,21 +686,45 @@ module.exports = {
<Form onValidSubmit={this.onValidSubmit}> <Form onValidSubmit={this.onValidSubmit}>
<Select label={formatMessage({id: 'general.country'})} <Select label={formatMessage({id: 'general.country'})}
name="address.country" name="address.country"
options={getCountryOptions()} options={getCountryOptions(this.props.intl)}
value={this.props.defaultCountry} value={this.props.defaultCountry}
onChange={this.onChangeCountry} onChange={this.onChangeCountry}
required /> required />
<Input label={formatMessage({id: 'teacherRegistration.addressLine1'})} <Input label={formatMessage({id: 'teacherRegistration.addressLine1'})}
type="text" type="text"
name="address.line1" name="address.line1"
validations={{
maxLength: 100
}}
validationErrors={{
maxLength: formatMessage({
id: 'registration.validationMaxLength'
})
}}
required /> required />
<Input label={formatMessage({id: 'teacherRegistration.addressLine2'})} <Input label={formatMessage({id: 'teacherRegistration.addressLine2'})}
type="text" type="text"
name="address.line2" name="address.line2"
validations={{
maxLength: 100
}}
validationErrors={{
maxLength: formatMessage({
id: 'registration.validationMaxLength'
})
}}
required="isFalse" /> required="isFalse" />
<Input label={formatMessage({id: 'teacherRegistration.city'})} <Input label={formatMessage({id: 'teacherRegistration.city'})}
type="text" type="text"
name="address.city" name="address.city"
validations={{
maxLength: 50
}}
validationErrors={{
maxLength: formatMessage({
id: 'registration.validationMaxLength'
})
}}
required /> required />
{stateOptions.length > 2 ? {stateOptions.length > 2 ?
<Select label={formatMessage({id: 'teacherRegistration.stateProvince'})} <Select label={formatMessage({id: 'teacherRegistration.stateProvince'})}
...@@ -649,6 +736,14 @@ module.exports = { ...@@ -649,6 +736,14 @@ module.exports = {
<Input label={formatMessage({id: 'teacherRegistration.zipCode'})} <Input label={formatMessage({id: 'teacherRegistration.zipCode'})}
type="text" type="text"
name="address.zip" name="address.zip"
validations={{
maxLength: 10
}}
validationErrors={{
maxLength: formatMessage({
id: 'registration.validationMaxLength'
})
}}
required /> required />
<GeneralError name="all" /> <GeneralError name="all" />
<NextStepButton waiting={this.props.waiting || this.state.waiting} <NextStepButton waiting={this.props.waiting || this.state.waiting}
......
...@@ -140,6 +140,7 @@ ...@@ -140,6 +140,7 @@
"registration.studentUsernameFieldHelpText": "For safety, don't use your real name!", "registration.studentUsernameFieldHelpText": "For safety, don't use your real name!",
"registration.usernameStepTitle": "Request a Teacher Account", "registration.usernameStepTitle": "Request a Teacher Account",
"registration.usernameStepTitleScratcher": "Create a Scratch Account", "registration.usernameStepTitleScratcher": "Create a Scratch Account",
"registration.validationMaxLength": "Sorry, that is too many characters for us.",
"registration.validationPasswordLength": "Passwords must be at least six characters", "registration.validationPasswordLength": "Passwords must be at least six characters",
"registration.validationPasswordNotEquals": "Your password may not be \"password\"", "registration.validationPasswordNotEquals": "Your password may not be \"password\"",
"registration.validationPasswordNotUsername": "Your password may not be your username", "registration.validationPasswordNotUsername": "Your password may not be your username",
......
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