Finish StudentLoginModal implementation

This commit is contained in:
Scott Erickson 2015-11-20 13:59:43 -08:00
parent 70a3a199a0
commit f8a5baa4f6
2 changed files with 21 additions and 7 deletions

View file

@ -22,9 +22,11 @@ block modal-body-content
.input-border .input-border
input#password.input-large.form-control(name="password", type="password", value=view.formValues.password) input#password.input-large.form-control(name="password", type="password", value=view.formValues.password)
.text-center #errors-alert.alert.alert-danger.hide
button#log-in-btn.btn.btn-default(data-i18n="login.log_in")
p .text-center
a#create-new-account-link(data-i18n="login.signup_switch") input#log-in-btn.btn.btn-default(data-i18n="login.log_in", type="submit")
p
a#create-new-account-link(data-i18n="login.signup_switch")
block modal-footer-content block modal-footer-content

View file

@ -13,11 +13,23 @@ module.exports = class StudentSignInModal extends ModalView
events: events:
'click #log-in-btn': 'onClickLogInButton' 'click #log-in-btn': 'onClickLogInButton'
'submit form': 'onSubmitForm'
onSubmitForm: (e) ->
e.preventDefault()
@login()
onClickLogInButton: -> onClickLogInButton: ->
forms.clearFormAlerts(@$el) @login()
login: ->
userObject = forms.formToObject @$el userObject = forms.formToObject @$el
res = tv4.validateMultiple userObject, User.schema res = tv4.validateMultiple userObject, User.schema
return forms.applyErrorsToForm(@$el, res.errors) unless res.valid return forms.applyErrorsToForm(@$el, res.errors) unless res.valid
@enableModalInProgress(@$el) # TODO: part of forms @enableModalInProgress(@$el)
loginUser userObject, null, window.nextURL auth.loginUser userObject, (jqxhr) =>
error = jqxhr.responseJSON[0]
message = error.property + ' ' + error.message
@disableModalInProgress(@$el)
@$('#errors-alert').text(message).removeClass('hide')