mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
Add start of StudentLoginModal
This commit is contained in:
parent
1a4a143340
commit
bcb869594d
5 changed files with 68 additions and 2 deletions
7
app/styles/courses/student-log-in-modal.sass
Normal file
7
app/styles/courses/student-log-in-modal.sass
Normal file
|
@ -0,0 +1,7 @@
|
|||
#student-log-in-modal
|
||||
#log-in-btn
|
||||
min-width: 30%
|
||||
margin-bottom: 10px
|
||||
|
||||
.form
|
||||
margin: 0 25%
|
|
@ -15,7 +15,7 @@ block content
|
|||
p - OR -
|
||||
|
||||
p
|
||||
button.btn.btn-default Sign In
|
||||
button#log-in-btn.btn.btn-default(data-i18n="login.log_in")
|
||||
|
||||
else
|
||||
.well.text-center
|
||||
|
@ -35,7 +35,7 @@ block content
|
|||
p - OR -
|
||||
|
||||
p
|
||||
button.btn.btn-default Sign In
|
||||
button#log-in-btn.btn.btn-default(data-i18n="login.log_in")
|
||||
|
||||
#begin-hoc-area.hide
|
||||
h2.text-center(data-i18n="common.loading")
|
||||
|
|
30
app/templates/courses/student-log-in-modal.jade
Normal file
30
app/templates/courses/student-log-in-modal.jade
Normal file
|
@ -0,0 +1,30 @@
|
|||
extends /templates/core/modal-base
|
||||
|
||||
block modal-header-content
|
||||
.clearfix
|
||||
|
||||
|
||||
block modal-body-content
|
||||
.text-center
|
||||
h2.modal-title(data-i18n="login.log_in")
|
||||
|
||||
form.form
|
||||
.form-group
|
||||
label.control-label(for="email")
|
||||
span(data-i18n="general.email")
|
||||
| :
|
||||
.input-border
|
||||
input#email.input-large.form-control(name="email", type="email", value=view.formValues.email)
|
||||
.form-group
|
||||
label.control-label(for="password")
|
||||
span(data-i18n="general.password") Password
|
||||
| :
|
||||
.input-border
|
||||
input#password.input-large.form-control(name="password", type="password", value=view.formValues.password)
|
||||
|
||||
.text-center
|
||||
button#log-in-btn.btn.btn-default(data-i18n="login.log_in")
|
||||
p
|
||||
a#create-new-account-link(data-i18n="login.signup_switch")
|
||||
|
||||
block modal-footer-content
|
|
@ -9,6 +9,7 @@ utils = require 'core/utils'
|
|||
LevelSession = require 'models/LevelSession'
|
||||
Level = require 'models/Level'
|
||||
ChooseLanguageModal = require 'views/courses/ChooseLanguageModal'
|
||||
StudentLogInModal = require 'views/courses/StudentLogInModal'
|
||||
|
||||
|
||||
module.exports = class HourOfCodeView extends RootView
|
||||
|
@ -18,6 +19,7 @@ module.exports = class HourOfCodeView extends RootView
|
|||
events:
|
||||
'click #student-btn': 'onClickStudentButton'
|
||||
'click #start-new-game-btn': 'onClickStartNewGameButton'
|
||||
'click #log-in-btn': 'onClickLogInButton'
|
||||
|
||||
initialize: ->
|
||||
@setUpHourOfCode()
|
||||
|
@ -83,6 +85,10 @@ module.exports = class HourOfCodeView extends RootView
|
|||
app.router.navigate(url, { trigger: true })
|
||||
})
|
||||
|
||||
onClickLogInButton: ->
|
||||
modal = new StudentLogInModal()
|
||||
@openModalView(modal)
|
||||
|
||||
# onClickStudentButton: ->
|
||||
# @state = 'enrolling'
|
||||
# @stateMessage = undefined
|
||||
|
|
23
app/views/courses/StudentLogInModal.coffee
Normal file
23
app/views/courses/StudentLogInModal.coffee
Normal file
|
@ -0,0 +1,23 @@
|
|||
ModalView = require 'views/core/ModalView'
|
||||
template = require 'templates/courses/student-log-in-modal'
|
||||
auth = require 'core/auth'
|
||||
forms = require 'core/forms'
|
||||
User = require 'models/User'
|
||||
|
||||
module.exports = class StudentSignInModal extends ModalView
|
||||
id: 'student-log-in-modal'
|
||||
template: template
|
||||
|
||||
initialize: ->
|
||||
@formValues = {}
|
||||
|
||||
events:
|
||||
'click #log-in-btn': 'onClickLogInButton'
|
||||
|
||||
onClickLogInButton: ->
|
||||
forms.clearFormAlerts(@$el)
|
||||
userObject = forms.formToObject @$el
|
||||
res = tv4.validateMultiple userObject, User.schema
|
||||
return forms.applyErrorsToForm(@$el, res.errors) unless res.valid
|
||||
@enableModalInProgress(@$el) # TODO: part of forms
|
||||
loginUser userObject, null, window.nextURL
|
Loading…
Reference in a new issue