2014-04-10 17:59:32 -04:00
|
|
|
ContactView = require 'views/modal/contact_modal'
|
|
|
|
template = require 'templates/modal/job_profile_contact'
|
|
|
|
|
|
|
|
forms = require 'lib/forms'
|
|
|
|
{sendContactMessage} = require 'lib/contact'
|
|
|
|
|
|
|
|
contactSchema =
|
|
|
|
additionalProperties: false
|
|
|
|
required: ['email', 'message']
|
|
|
|
properties:
|
|
|
|
email:
|
|
|
|
type: 'string'
|
|
|
|
maxLength: 100
|
|
|
|
minLength: 1
|
|
|
|
format: 'email'
|
|
|
|
|
|
|
|
subject:
|
|
|
|
type: 'string'
|
|
|
|
minLength: 1
|
|
|
|
|
|
|
|
message:
|
|
|
|
type: 'string'
|
|
|
|
minLength: 1
|
|
|
|
|
|
|
|
recipientID:
|
|
|
|
type: 'string'
|
|
|
|
minLength: 1
|
|
|
|
|
|
|
|
module.exports = class JobProfileContactView extends ContactView
|
|
|
|
id: "job-profile-contact-modal"
|
|
|
|
template: template
|
|
|
|
|
|
|
|
contact: ->
|
|
|
|
forms.clearFormAlerts @$el
|
|
|
|
contactMessage = forms.formToObject @$el
|
|
|
|
contactMessage.recipientID = @options.recipientID
|
|
|
|
res = tv4.validateMultiple contactMessage, contactSchema
|
|
|
|
return forms.applyErrorsToForm @$el, res.errors unless res.valid
|
2014-06-24 17:35:28 -04:00
|
|
|
contactMessage.message += "\n\n\n\n[For reference, the recipient's CodeCombat username is #{@options.recipientUserName}!]"
|
2014-04-10 17:59:32 -04:00
|
|
|
window.tracker?.trackEvent 'Sent Job Profile Message', message: contactMessage
|
|
|
|
sendContactMessage contactMessage, @$el
|
2014-06-10 19:30:07 -04:00
|
|
|
$.post "/db/user/#{me.id}/track/contact_candidate"
|
|
|
|
$.post "/db/user/#{@options.recipientID}/track/contacted_by_employer" unless me.isAdmin()
|