update profile edit view

This commit is contained in:
Michael Q Larson
2015-01-07 16:10:40 -08:00
parent 22ed592134
commit f9337c57ea
3 changed files with 151 additions and 134 deletions

View File

@@ -243,12 +243,6 @@ exports.updateProgress = function(req, res) {
exports.postUpdateProfile = function(req, res, next) { exports.postUpdateProfile = function(req, res, next) {
User.findById(req.user.id, function(err, user) { User.findById(req.user.id, function(err, user) {
if (err) return next(err); if (err) return next(err);
req.assert('email', 'Email is required').notEmpty();
req.assert('email', 'Please enter a valid email address.').isEmail();
req.assert('username', 'Your username cannot be longer than 20 characters').len(1, 20);
req.assert('username', 'Your username can only use letters, numbers or underscores').matchRegex(/^[A-z0-9_]+$/);
req.assert('githubProfile', 'Please enter a valid URL (www.example.com)').matchRegex(/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/);
var errors = req.validationErrors(); var errors = req.validationErrors();
if (errors) { if (errors) {
req.flash('errors', errors); req.flash('errors', errors);

View File

@@ -391,4 +391,8 @@ thead {
} }
.ng-valid.ng-dirty { .ng-valid.ng-dirty {
border-color: #78FA89; border-color: #78FA89;
}
.twitter-input {
} }

View File

@@ -3,134 +3,153 @@ block content
link(href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css", rel="stylesheet") link(href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css", rel="stylesheet")
.panel(ng-controller="profileValidationController") .panel(ng-controller="profileValidationController")
.container.text-center .container.text-center
h1 Update your profile here: h1 Update your profile here:
form.form-horizontal(action='/account/profile', method='POST', novalidate='novalidate', name='profileForm') form.form-horizontal(action='/account/profile', method='POST', novalidate='novalidate', name='profileForm')
input(type='hidden', name='_csrf', value=_csrf) input(type='hidden', name='_csrf', value=_csrf)
.form-group .col-sm-4.col-sm-offset-5
label.col-sm-3.col-sm-offset-2.control-label(for='name') Name h2 Bio
.col-sm-4 .form-group
input.form-control(type='text', placeholder='Name', name='name', ng-model='user.profile.name', ng-minlength='3', ng-maxlength='20', required='required', ng-focus='ng-focus', id='name') label.col-sm-3.col-sm-offset-2.control-label(for='name') Name
.col-sm-4.col-sm-offset-5(ng-show="profileForm.name.$invalid && !profileForm.name.$pristine && profileForm.name.$error.required") .col-sm-4
alert(type='danger') input.form-control(type='text', placeholder='Name', name='name', ng-model='user.profile.name', ng-minlength='3', ng-maxlength='50', required='required', ng-focus='ng-focus', id='name')
span.ion-close-circled .col-sm-4.col-sm-offset-5(ng-show="profileForm.name.$invalid && !profileForm.name.$pristine && profileForm.name.$error.required")
| Your name is required. alert(type='danger')
.col-sm-4.col-sm-offset-5(ng-show='profileForm.name.$error.minlength && !profileForm.name.$pristine') span.ion-close-circled
alert(type='danger') | Your name is required.
span.ion-close-circled .col-sm-4.col-sm-offset-5(ng-show='profileForm.name.$error.minlength && !profileForm.name.$pristine')
| Your name must be at least 3 characters. alert(type='danger')
.col-sm-4.col-sm-offset-5(ng-show='profileForm.name.$error.maxlength && !profileForm.name.$pristine') span.ion-close-circled
alert(type='danger') | Your name must be at least 3 characters.
span.ion-close-circled .col-sm-4.col-sm-offset-5(ng-show='profileForm.name.$error.maxlength && !profileForm.name.$pristine')
| Your name must be under 20 characters. alert(type='danger')
.form-group span.ion-close-circled
label.col-sm-3.col-sm-offset-2.control-label(for='username') Username (use letters, numbers, underscore) * | Your name must be under 20 characters.
.col-sm-4 .form-group
input.form-control(type='text', placeholder='username' name='username', id='username', ng-model='user.profile.username', required='required', ng-minlength='5', ng-maxlength='20') label.col-sm-3.col-sm-offset-2.control-label(for='username') Username (path to public profile) *
.col-sm-4.col-sm-offset-5(ng-show="profileForm.username.$error.required && !profileForm.username.$pristine") .col-sm-4
alert(type='danger') input.form-control(type='text', placeholder='username' name='username', id='username', ng-model='user.profile.username', required='required', ng-minlength='5', ng-maxlength='20')
span.ion-close-circled .col-sm-4.col-sm-offset-5(ng-show="profileForm.username.$error.required && !profileForm.username.$pristine")
| Please enter a username. alert(type='danger')
.col-sm-4.col-sm-offset-5(ng-show="profileForm.username.$error.minlength && !profileForm.username.$pristine") span.ion-close-circled
alert(type='danger') | Please enter a username.
span.ion-close-circled .col-sm-4.col-sm-offset-5(ng-show="profileForm.username.$error.minlength && !profileForm.username.$pristine")
| Your username must be at least 5 characters. alert(type='danger')
.col-sm-4.col-sm-offset-5(ng-show="profileForm.username.$error.maxlength && !profileForm.username.$pristine") span.ion-close-circled
alert(type='danger') | Your username must be at least 5 characters.
span.ion-close-circled .col-sm-4.col-sm-offset-5(ng-show="profileForm.username.$error.maxlength && !profileForm.username.$pristine")
| Your username must be less than 20 characters. alert(type='danger')
.form-group span.ion-close-circled
label.col-sm-3.col-sm-offset-2.control-label(for='email') Email * | Your username must be less than 20 characters.
.col-sm-4 .form-group
input.form-control(type='email', placeholder='iluv@microsoft.com', name='email', id='email', ng-model='user.email', required='required') label.col-sm-3.col-sm-offset-2.control-label(for='email') Email *
.col-sm-4.col-sm-offset-5(ng-show="profileForm.email.$error.required && !profileForm.email.$pristine") .col-sm-4
alert(type='danger') input.form-control(type='email', placeholder='iluv@microsoft.com', name='email', id='email', ng-model='user.email', required='required')
span.ion-close-circled .col-sm-4.col-sm-offset-5(ng-show="profileForm.email.$error.required && !profileForm.email.$pristine")
| An email address is required. alert(type='danger')
.col-sm-4.col-sm-offset-5(ng-show="profileForm.$error.email && !profileForm.email.$pristine") span.ion-close-circled
alert(type='danger') | An email address is required.
span.ion-close-circled .col-sm-4.col-sm-offset-5(ng-show="profileForm.$error.email && !profileForm.email.$pristine")
| Please enter a valid email format. alert(type='danger')
.form-group span.ion-close-circled
label.col-sm-3.col-sm-offset-2.control-label(for='location') Location | Please enter a valid email format.
.col-sm-4 .form-group
input.form-control(type='text', name='location', id='location', ng-model='user.profile.location') label.col-sm-3.col-sm-offset-2.control-label(for='location') Location
.form-group .col-sm-4
label.col-sm-3.col-sm-offset-2.control-label(for='email') Twitter Handle input.form-control(type='text', name='location', id='location', ng-model='user.profile.location')
.col-sm-4 .form-group
input.form-control(type='text', name='twitterHandle', id='twitterHandle', ng-model='user.profile.twitterHandle') .col-sm-offset-5.col-sm-4
.form-group button.btn.btn-primary.btn-block(type='submit', ng-disabled='profileForm.$invalid')
label.col-sm-3.col-sm-offset-2.control-label(for='email') Github Profile Link span.ion-edit
.col-sm-4 | Update my Bio
input.form-control(type='url', name='githubProfile', id='githubProfile', ng-model='user.profile.githubProfile', placeholder='http://') .col-sm-4.col-sm-offset-5
.col-sm-4.col-sm-offset-5(ng-show="profileForm.githubProfile.$error.url && !profileForm.githubProfile.$pristine") h2 Social
alert(type='danger') .form-group
span.ion-close-circled label.col-sm-3.col-sm-offset-2.control-label(for='email') Twitter Handle
| Please enter a valid URL format (http://www.example.com). .col-sm-4
.form-group .input-group.twitter-input
label.col-sm-3.col-sm-offset-2.control-label(for='email') CodePen Profile Link span.input-group-addon @
.col-sm-4 input.form-control(type='text', name='twitterHandle', id='twitterHandle', ng-model='user.profile.twitterHandle')
input.form-control(type='url', name='codepenProfile', id='codepenProfile', ng-model='user.profile.codepenProfile', placeholder='http://') .form-group
.col-sm-4.col-sm-offset-5(ng-show="profileForm.codepenProfile.$error.url && !profileForm.codepenProfile.$pristine") label.col-sm-3.col-sm-offset-2.control-label(for='email') Github Profile Link
alert(type='danger') .col-sm-4
span.ion-close-circled input.form-control(type='url', name='githubProfile', id='githubProfile', ng-model='user.profile.githubProfile', placeholder='http://')
| Please enter a valid URL format (http://www.example.com). .col-sm-4.col-sm-offset-5(ng-show="profileForm.githubProfile.$error.url && !profileForm.githubProfile.$pristine")
.form-group alert(type='danger')
label.col-sm-3.col-sm-offset-2.control-label(for='email') CoderByte Profile Link span.ion-close-circled
.col-sm-4 | Please enter a valid URL format (http://www.example.com).
input.form-control(type='url', name='coderbyteProfile', id='coderbyteProfile', ng-model='user.profile.coderbyteProfile', placeholder='http://') .form-group
.col-sm-4.col-sm-offset-5(ng-show="profileForm.coderbyteProfile.$error.url && !profileForm.coderbyteProfile.$pristine") label.col-sm-3.col-sm-offset-2.control-label(for='email') CodePen Profile Link
alert(type='danger') .col-sm-4
span.ion-close-circled input.form-control(type='url', name='codepenProfile', id='codepenProfile', ng-model='user.profile.codepenProfile', placeholder='http://')
| Please enter a valid URL format (http://www.example.com). .col-sm-4.col-sm-offset-5(ng-show="profileForm.codepenProfile.$error.url && !profileForm.codepenProfile.$pristine")
.form-group alert(type='danger')
label.col-sm-3.col-sm-offset-2.control-label(for='email') LinkedIn Profile Link span.ion-close-circled
.col-sm-4 | Please enter a valid URL format (http://www.example.com).
input.form-control(type='url', name='linkedinProfile', id='linkedinProfile', ng-model='user.profile.linkedinProfile', placeholder='http://') .form-group
.col-sm-4.col-sm-offset-5(ng-show="profileForm.linkedinProfile.$error.url && !profileForm.linkedinProfile.$pristine") label.col-sm-3.col-sm-offset-2.control-label(for='email') CoderByte Profile Link
alert(type='danger') .col-sm-4
span.ion-close-circled input.form-control(type='url', name='coderbyteProfile', id='coderbyteProfile', ng-model='user.profile.coderbyteProfile', placeholder='http://')
| Please enter a valid URL format (http://www.example.com). .col-sm-4.col-sm-offset-5(ng-show="profileForm.coderbyteProfile.$error.url && !profileForm.coderbyteProfile.$pristine")
.form-group alert(type='danger')
label.col-sm-3.col-sm-offset-2.control-label(for='website1Title') 1st Portfolio Website Title span.ion-close-circled
.col-sm-4 | Please enter a valid URL format (http://www.example.com).
input.form-control(type='text', name='website1Title', id='website1Title', ng-model='user.profile.website1Title') .form-group
.form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') LinkedIn Profile Link
label.col-sm-3.col-sm-offset-2.control-label(for='website1Link') 1st Portfolio Website Link .col-sm-4
.col-sm-4 input.form-control(type='url', name='linkedinProfile', id='linkedinProfile', ng-model='user.profile.linkedinProfile', placeholder='http://')
input.form-control(type='text', name='website1Link', id='website1Link', ng-model='user.profile.website1Link') .col-sm-4.col-sm-offset-5(ng-show="profileForm.linkedinProfile.$error.url && !profileForm.linkedinProfile.$pristine")
.form-group alert(type='danger')
label.col-sm-3.col-sm-offset-2.control-label(for='website1Image') 1st Portfolio Website Image Link span.ion-close-circled
.col-sm-4 | Please enter a valid URL format (http://www.example.com).
input.form-control(type='text', name='website1Image', id='website1Image', ng-model='website1Image') .form-group
.form-group .col-sm-offset-5.col-sm-4
label.col-sm-3.col-sm-offset-2.control-label(for='website2Title') 2nd Portfolio Website Title button.btn.btn-primary.btn-block(type='submit', ng-disabled='profileForm.$invalid')
.col-sm-4 span.ion-edit
input.form-control(type='text', name='website2Title', id='website2Title', ng-model='user.profile.website2Title') | Update my Social Links
.form-group .col-sm-4.col-sm-offset-5
label.col-sm-3.col-sm-offset-2.control-label(for='website2Link') 2nd Portfolio Website Link h2 Portfolio
.col-sm-4 .form-group
input.form-control(type='text', name='website2Link', id='website2Link', ng-model='user.profile.website2Link') label.col-sm-3.col-sm-offset-2.control-label(for='website1Title') 1st Portfolio Website Title
.form-group .col-sm-4
label.col-sm-3.col-sm-offset-2.control-label(for='website2Image') 2nd Portfolio Website Image Link input.form-control(type='text', name='website1Title', id='website1Title', ng-model='user.profile.website1Title')
.col-sm-4 .form-group
input.form-control(type='text', name='website2Image', id='website2Image', ng-model='user.profile.website2Image') label.col-sm-3.col-sm-offset-2.control-label(for='website1Link') 1st Portfolio Website Link
.form-group .col-sm-4
label.col-sm-3.col-sm-offset-2.control-label(for='website3Title') 3rd Portfolio Website Title input.form-control(type='text', name='website1Link', id='website1Link', ng-model='user.profile.website1Link', placeholder='http://')
.col-sm-4 .form-group
input.form-control(type='text', name='website3Title', id='website3Title', ng-model='user.profile.website3Title') label.col-sm-3.col-sm-offset-2.control-label(for='website1Image') 1st Portfolio Website Image Link
.form-group .col-sm-4
label.col-sm-3.col-sm-offset-2.control-label(for='website3Link') 3rd Portfolio Website Link input.form-control(type='text', name='website1Image', id='website1Image', ng-model='website1Image', placeholder='http://')
.col-sm-4 .form-group
input.form-control(type='text', name='website3Link', id='website3Link', ng-model='user.profile.website3Link') label.col-sm-3.col-sm-offset-2.control-label(for='website2Title') 2nd Portfolio Website Title
.form-group .col-sm-4
label.col-sm-3.col-sm-offset-2.control-label(for='website3Image') 3rd Portfolio Website Image Link input.form-control(type='text', name='website2Title', id='website2Title', ng-model='user.profile.website2Title')
.col-sm-4 .form-group
input.form-control(type='text', name='website3Image', id='website3Image', ng-model='user.profile.website3Image') label.col-sm-3.col-sm-offset-2.control-label(for='website2Link') 2nd Portfolio Website Link
.form-group .col-sm-4
.col-sm-offset-2.col-sm-4 input.form-control(type='text', name='website2Link', id='website2Link', ng-model='user.profile.website2Link', placeholder='http://')
button.btn.btn.btn-primary(type='submit', ng-disabled='profileForm.$invalid') .form-group
span.ion-edit label.col-sm-3.col-sm-offset-2.control-label(for='website2Image') 2nd Portfolio Website Image Link
| Update my profile .col-sm-4
input.form-control(type='text', name='website2Image', id='website2Image', ng-model='user.profile.website2Image', placeholder='http://')
.form-group
label.col-sm-3.col-sm-offset-2.control-label(for='website3Title') 3rd Portfolio Website Title
.col-sm-4
input.form-control(type='text', name='website3Title', id='website3Title', ng-model='user.profile.website3Title')
.form-group
label.col-sm-3.col-sm-offset-2.control-label(for='website3Link') 3rd Portfolio Website Link
.col-sm-4
input.form-control(type='text', name='website3Link', id='website3Link', ng-model='user.profile.website3Link', placeholder='http://')
.form-group
label.col-sm-3.col-sm-offset-2.control-label(for='website3Image') 3rd Portfolio Website Image Link
.col-sm-4
input.form-control(type='text', name='website3Image', id='website3Image', ng-model='user.profile.website3Image', placeholder='http://')
.form-group
.col-sm-offset-5.col-sm-4
button.btn.btn-primary.btn-block(type='submit', ng-disabled='profileForm.$invalid')
span.ion-edit
| Update my Portfolio
br
.panel .panel
.big-break .big-break
.container.text-center .container.text-center