Add extra information when a school is autocompleted.

This commit is contained in:
Rob 2016-04-18 22:54:43 -07:00
parent 439e7bbcab
commit e64d585841
3 changed files with 25 additions and 7 deletions
app
core/services
templates/teachers
views/teachers

View file

@ -0,0 +1,5 @@
client = algoliasearch("JJM5H2CHJR", "50382fc2f7fa69c67e8233ace7cd7c4c")
module.exports =
client: client
schoolsIndex: client.initIndex('schools')

View file

@ -170,6 +170,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="phone")
#buttons-row.row.text-center
input#submit-request-btn.btn.btn-lg.btn-primary(type="submit" data-i18n="[value]teachers_quote.title")

View file

@ -6,9 +6,11 @@ AuthModal = require 'views/core/AuthModal'
storage = require 'core/storage'
errors = require 'core/errors'
ConfirmModal = require 'views/editor/modal/ConfirmModal'
algolia = require 'core/services/algolia'
FORM_KEY = 'request-quote-form'
SIGNUP_REDIRECT = '/teachers'
NCES_KEYS = ['id', 'name', 'district', 'district_id', 'district_schools', 'district_students', 'students', 'phone']
module.exports = class RequestQuoteView extends RootView
id: 'request-quote-view'
@ -57,11 +59,9 @@ module.exports = class RequestQuoteView extends RootView
@$('#other-education-level-input').val(obj.otherInput)
forms.objectToForm(@$('#request-form'), obj, { overwriteExisting: true })
client = algoliasearch("JJM5H2CHJR", "50382fc2f7fa69c67e8233ace7cd7c4c")
index = client.initIndex('schools')
$("#organization-control").autocomplete({hint: false}, [
source: (query, callback) ->
index.search(query, { hitsPerPage: 5, aroundLatLngViaIP: false }).then (answer) ->
algolia.schoolsIndex.search(query, { hitsPerPage: 5, aroundLatLngViaIP: false }).then (answer) ->
callback answer.hits
, ->
callback []
@ -77,9 +77,11 @@ module.exports = class RequestQuoteView extends RootView
@$('input[name="city"]').val suggestion.city
@$('input[name="state"]').val suggestion.state
@$('input[name="district"]').val suggestion.district
@$('input[name="district"]').val 'USA'
# Stuff we want to save: district ID, geo, school phone, number of students in school, number of students in district, number of schools in district, school mailing address, institution type
console.log('S', suggestion)
@$('input[name="country"]').val 'USA'
for key in NCES_KEYS
@$('input[name="nces_' + key + '"]').val suggestion[key]
onChangeRequestForm: ->
@ -271,9 +273,12 @@ requestFormSchemaAnonymous = {
type: 'array'
items: { type: 'string' }
}
notes: { type: 'string' }
notes: { type: 'string' },
}
for key in NCES_KEYS
requestFormSchemaAnonymous['nces_' + key] = type: 'string'
# same form, but add username input
requestFormSchemaLoggedIn = _.cloneDeep(requestFormSchemaAnonymous)
requestFormSchemaLoggedIn.required.push('name')