mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-22 05:22:24 -05:00
8dbc86ca04
Hide TeachersContactModal after sending message Fix GET /db/level/:handle/session, more extensively test Fix EnrollmentView number of students input to stop losing focus on input Fix EnrollmentsView syntax Fix ActivateLicensesModal "Get Enrollments" button when already in the enrollments page Update EnrollmentsView with new credit numbers when ActivateLicensesModal closes Hide search box in TeacherClassView "Enrollment Status" tab Tweak EnrollmentsView styling Fix EnrollmentsView tests Fix AnalyticsView Make EnrollmentsView more explicitly handle undefined and empty array prepaid groups Remove log CoursesView handles JoinClassModal cancel Re-enable EditStudentModal set password button when the form changes Fix course instance tests, next level endpoint bug Fix EditStudentModal tests
45 lines
1.5 KiB
CoffeeScript
45 lines
1.5 KiB
CoffeeScript
ModalView = require 'views/core/ModalView'
|
|
State = require 'models/State'
|
|
template = require 'templates/teachers/edit-student-modal'
|
|
auth = require 'core/auth'
|
|
|
|
module.exports = class EditStudentModal extends ModalView
|
|
id: 'edit-student-modal'
|
|
template: template
|
|
|
|
events:
|
|
'click .send-recovery-email-btn:not(.disabled)': 'onClickSendRecoveryEmail'
|
|
'click .change-password-btn:not(.disabled)': 'onClickChangePassword'
|
|
'input .new-password-input': 'onChangeNewPasswordInput'
|
|
|
|
initialize: ({ @user, @classroom }) ->
|
|
@supermodel.trackRequest @user.fetch()
|
|
@utils = require 'core/utils'
|
|
@state = new State({
|
|
emailSent: false
|
|
passwordChanged: false
|
|
newPassword: ""
|
|
errorMessage: ""
|
|
})
|
|
@listenTo @state, 'change', @render
|
|
@listenTo @classroom, 'save-password:success', ->
|
|
@state.set { passwordChanged: true, errorMessage: "" }
|
|
@listenTo @classroom, 'save-password:error', (error) ->
|
|
@state.set({ errorMessage: error.message })
|
|
# TODO: Show an error. (password too short)
|
|
|
|
onClickSendRecoveryEmail: ->
|
|
email = @user.get('email')
|
|
auth.sendRecoveryEmail(email).then =>
|
|
@state.set { emailSent: true }
|
|
|
|
onClickChangePassword: ->
|
|
@classroom.setStudentPassword(@user, @state.get('newPassword'))
|
|
|
|
onChangeNewPasswordInput: (e) ->
|
|
@state.set {
|
|
newPassword: $(e.currentTarget).val()
|
|
emailSent: false
|
|
passwordChanged: false
|
|
}, { silent: true }
|
|
@renderSelectors('.change-password-btn')
|