mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Add district picker to teachers/signup
This commit is contained in:
parent
b4b435283b
commit
f79a9b96bf
3 changed files with 46 additions and 2 deletions
|
@ -93,7 +93,7 @@ block content
|
|||
.col-md-offset-2.col-md-4.col-sm-6
|
||||
.form-group
|
||||
label.control-label(data-i18n="teachers_quote.organization_label")
|
||||
input.form-control(name="organization")
|
||||
input.form-control#organization-control(name="organization")
|
||||
|
||||
.col-md-4.col-sm-6
|
||||
.form-group
|
||||
|
@ -167,6 +167,14 @@ block content
|
|||
span.spl.text-muted(data-i18n="signup.optional")
|
||||
|
||||
textarea.form-control(rows=8, name="notes")
|
||||
input(type="hidden" name="nces_id")
|
||||
input(type="hidden" name="nces_name")
|
||||
input(type="hidden" name="nces_district")
|
||||
input(type="hidden" name="nces_district_id")
|
||||
input(type="hidden" name="nces_district_schools")
|
||||
input(type="hidden" name="nces_district_students")
|
||||
input(type="hidden" name="nces_students")
|
||||
input(type="hidden" name="nces_phone")
|
||||
|
||||
#buttons-row.row.m-y-2.text-center
|
||||
input#create-account-btn.btn.btn-lg.btn-primary(type="submit" data-i18n="[value]teachers_quote.create_account")
|
||||
|
|
|
@ -177,7 +177,7 @@ block content
|
|||
input(type="hidden" name="nces_district_schools")
|
||||
input(type="hidden" name="nces_district_students")
|
||||
input(type="hidden" name="nces_students")
|
||||
input(type="hidden" name="phone")
|
||||
input(type="hidden" name="nces_phone")
|
||||
|
||||
#buttons-row.row.text-center
|
||||
input#submit-request-btn.btn.btn-lg.btn-primary(type="submit" data-i18n="[value]teachers_quote.title")
|
||||
|
|
|
@ -6,9 +6,11 @@ AuthModal = require 'views/core/AuthModal'
|
|||
storage = require 'core/storage'
|
||||
errors = require 'core/errors'
|
||||
User = require 'models/User'
|
||||
algolia = require 'core/services/algolia'
|
||||
|
||||
FORM_KEY = 'request-quote-form'
|
||||
SIGNUP_REDIRECT = '/teachers/classes'
|
||||
NCES_KEYS = ['id', 'name', 'district', 'district_id', 'district_schools', 'district_students', 'students', 'phone']
|
||||
|
||||
module.exports = class CreateTeacherAccountView extends RootView
|
||||
id: 'create-teacher-account-view'
|
||||
|
@ -20,6 +22,10 @@ module.exports = class CreateTeacherAccountView extends RootView
|
|||
'submit form': 'onSubmitForm'
|
||||
'click #gplus-signup-btn': 'onClickGPlusSignupButton'
|
||||
'click #facebook-signup-btn': 'onClickFacebookSignupButton'
|
||||
'change input[name="city"]': 'invalidateNCES'
|
||||
'change input[name="state"]': 'invalidateNCES'
|
||||
'change input[name="district"]': 'invalidateNCES'
|
||||
'change input[name="country"]': 'invalidateNCES'
|
||||
|
||||
initialize: ->
|
||||
@trialRequest = new TrialRequest()
|
||||
|
@ -33,6 +39,10 @@ module.exports = class CreateTeacherAccountView extends RootView
|
|||
if @trialRequest and @trialRequest.get('status') isnt 'submitted' and @trialRequest.get('status') isnt 'approved'
|
||||
window.tracker?.trackEvent 'View Trial Request', category: 'Teachers', label: 'View Trial Request', ['Mixpanel']
|
||||
super()
|
||||
|
||||
invalidateNCES: ->
|
||||
for key in NCES_KEYS
|
||||
@$('input[name="nces_' + key + '"]').val ''
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
|
@ -54,6 +64,29 @@ module.exports = class CreateTeacherAccountView extends RootView
|
|||
@$('#other-education-level-input').val(obj.otherInput)
|
||||
forms.objectToForm(@$('form'), obj, { overwriteExisting: true })
|
||||
|
||||
$("#organization-control").autocomplete({hint: false}, [
|
||||
source: (query, callback) ->
|
||||
algolia.schoolsIndex.search(query, { hitsPerPage: 5, aroundLatLngViaIP: false }).then (answer) ->
|
||||
callback answer.hits
|
||||
, ->
|
||||
callback []
|
||||
displayKey: 'name',
|
||||
templates:
|
||||
suggestion: (suggestion) ->
|
||||
hr = suggestion._highlightResult
|
||||
"<div class='school'> #{hr.name.value} </div>" +
|
||||
"<div class='district'>#{hr.district.value}, " +
|
||||
"<span>#{hr.city?.value}, #{hr.state.value}</span></div>"
|
||||
|
||||
]).on 'autocomplete:selected', (event, suggestion, dataset) =>
|
||||
@$('input[name="city"]').val suggestion.city
|
||||
@$('input[name="state"]').val suggestion.state
|
||||
@$('input[name="district"]').val suggestion.district
|
||||
@$('input[name="country"]').val 'USA'
|
||||
|
||||
for key in NCES_KEYS
|
||||
@$('input[name="nces_' + key + '"]').val suggestion[key]
|
||||
|
||||
onClickLoginLink: ->
|
||||
modal = new AuthModal({ initialValues: { email: @trialRequest.get('properties')?.email } })
|
||||
@openModalView(modal)
|
||||
|
@ -264,3 +297,6 @@ formSchema = {
|
|||
}
|
||||
notes: { type: 'string' }
|
||||
}
|
||||
|
||||
for key in NCES_KEYS
|
||||
formSchema['nces_' + key] = type: 'string'
|
||||
|
|
Loading…
Reference in a new issue