From 1f16d6f5d9cc28427eec50651aaf80ff710f87bd Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Sun, 11 Oct 2015 21:11:27 -0700 Subject: [PATCH] Add required fields to job form --- common/app/routes/Jobs/components/NewJob.jsx | 18 +++++++++++++----- common/app/routes/Jobs/components/ShowJob.jsx | 3 ++- common/app/routes/Jobs/flux/Actions.js | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/common/app/routes/Jobs/components/NewJob.jsx b/common/app/routes/Jobs/components/NewJob.jsx index 4c369411f0..ed4aca7276 100644 --- a/common/app/routes/Jobs/components/NewJob.jsx +++ b/common/app/routes/Jobs/components/NewJob.jsx @@ -58,6 +58,10 @@ function isValidPhone(data) { return isMobilePhone(data, 'en-US'); } +function makeRequired(validator) { + return (val) => !!val && validator(val); +} + export default contain({ actions: 'jobActions', store: 'jobsStore', @@ -74,14 +78,14 @@ export default contain({ highlight } = form; return { - position: formatValue(position, isAscii), - locale: formatValue(locale, isAscii), - description: formatValue(description, isAscii), - email: formatValue(email, isEmail), + position: formatValue(position, makeRequired(isAscii)), + locale: formatValue(locale, makeRequired(isAscii)), + description: formatValue(description, makeRequired(isAscii)), + email: formatValue(email, makeRequired(isEmail)), phone: formatValue(phone, isValidPhone), url: formatValue(url, isValidURL), logo: formatValue(logo, isValidURL), - name: formatValue(name, isAscii), + name: formatValue(name, makeRequired(isAscii)), highlight: formatValue(highlight, null, 'bool') }; }, @@ -209,6 +213,7 @@ export default contain({ labelClassName={ labelClass } onChange={ (e) => handleChange('position', e) } placeholder='Position' + required={ true } type='text' value={ position.value } wrapperClassName={ inputClass } /> @@ -218,6 +223,7 @@ export default contain({ labelClassName={ labelClass } onChange={ (e) => handleChange('locale', e) } placeholder='Location' + required={ true } type='text' value={ locale.value } wrapperClassName={ inputClass } /> @@ -227,6 +233,7 @@ export default contain({ labelClassName={ labelClass } onChange={ (e) => handleChange('description', e) } placeholder='Description' + required={ true } rows='10' type='textarea' value={ description.value } @@ -250,6 +257,7 @@ export default contain({ labelClassName={ labelClass } onChange={ (e) => handleChange('email', e) } placeholder='Email' + required={ true } type='email' value={ email.value } wrapperClassName={ inputClass } /> diff --git a/common/app/routes/Jobs/components/ShowJob.jsx b/common/app/routes/Jobs/components/ShowJob.jsx index 80b0242a2e..b89d2b681a 100644 --- a/common/app/routes/Jobs/components/ShowJob.jsx +++ b/common/app/routes/Jobs/components/ShowJob.jsx @@ -40,6 +40,7 @@ export default React.createClass({ city, company, state, + locale, email, phone, postedOn, @@ -57,7 +58,7 @@ export default React.createClass({ Position: { position || 'N/A' }
- Location: { city || '' }, { state || 'N/A' } + Location: { locale ? locale : `${city}, ${state}` }
Contact: { email || phone || 'N/A' }
diff --git a/common/app/routes/Jobs/flux/Actions.js b/common/app/routes/Jobs/flux/Actions.js index 5900e6dda1..db7d84d8c9 100644 --- a/common/app/routes/Jobs/flux/Actions.js +++ b/common/app/routes/Jobs/flux/Actions.js @@ -57,6 +57,7 @@ export default Actions({ saveForm: null, getSavedForm: null, setForm(form) { + form.locale = form.location; return { form }; } })