Basic functionality done, needs validation error handling

As well as formatting
This commit is contained in:
Michael Schmatz 2014-06-07 11:45:49 -07:00
parent 67b10474e8
commit 4072c1b969
4 changed files with 107 additions and 2 deletions
app
lib
schemas/models
templates/account
views/account

View file

@ -22,6 +22,13 @@ module.exports = LinkedInHandler = class LinkedInHandler extends CocoClass
.error(cb)
.result (profiles) =>
cb null, profiles.values[0]
getProfileData: (cb) =>
IN.API.Profile("me")
.fields(["formatted-name","educations","skills","headline","summary","positions"])
.error(cb)
.result (profiles) =>
cb null, profiles.values[0]
destroy: ->
super()

View file

@ -78,7 +78,7 @@ UserSchema = c.object {},
city: c.shortString {title: 'City', description: 'City you want to work in (or live in now), like "San Francisco" or "Lubbock, TX".', default: 'Defaultsville, CA', format: 'city'}
country: c.shortString {title: 'Country', description: 'Country you want to work in (or live in now), like "USA" or "France".', default: 'USA', format: 'country'}
skills: c.array {title: 'Skills', description: 'Tag relevant developer skills in order of proficiency.', default: ['javascript'], minItems: 1, maxItems: 30, uniqueItems: true},
{type: 'string', minLength: 1, maxLength: 20, description: 'Ex.: "objective-c", "mongodb", "rails", "android", "javascript"', format: 'skill'}
{type: 'string', minLength: 1, maxLength: 50, description: 'Ex.: "objective-c", "mongodb", "rails", "android", "javascript"', format: 'skill'}
experience: {type: 'integer', title: 'Years of Experience', minimum: 0, description: 'How many years of professional experience (getting paid) developing software do you have?'}
shortDescription: {type: 'string', maxLength: 140, title: 'Short Description', description: 'Who are you, and what are you looking for? 140 characters max.', default: 'Programmer seeking to build great software.'}
longDescription: {type: 'string', maxLength: 600, title: 'Description', description: 'Describe yourself to potential employers. Keep it short and to the point. We recommend outlining the position that would most interest you. Tasteful markdown okay; 600 characters max.', format: 'markdown', default: '* I write great code.\n* You need great code?\n* Great!'}

View file

@ -3,6 +3,11 @@ extends /templates/base
block content
if allowedToEditJobProfile
.profile-control-bar
if linkedInAuthorized
button.btn#importLinkedIn
span Import LinkedIn
else
script(type="in/Login" id="linkedInAuthButton" data-onAuth="contractCallback")
if editing
.progress.profile-completion-progress
.progress-bar.progress-bar-success(style="width: #{100 * progress}%")

View file

@ -1,6 +1,7 @@
View = require 'views/kinds/RootView'
template = require 'templates/account/profile'
User = require 'models/User'
{me} = require 'lib/auth'
JobProfileContactView = require 'views/modal/job_profile_contact_modal'
JobProfileView = require 'views/account/job_profile_view'
forms = require 'lib/forms'
@ -8,9 +9,12 @@ forms = require 'lib/forms'
module.exports = class ProfileView extends View
id: "profile-view"
template: template
subscriptions:
'linkedin-loaded': 'onLinkedInLoaded'
events:
'click #toggle-editing': 'toggleEditing'
'click #importLinkedIn': 'importLinkedIn'
'click #toggle-job-profile-active': 'toggleJobProfileActive'
'click #toggle-job-profile-approved': 'toggleJobProfileApproved'
'click save-notes-button': 'onJobProfileNotesChanged'
@ -28,6 +32,13 @@ module.exports = class ProfileView extends View
constructor: (options, @userID) ->
@userID ?= me.id
@onJobProfileNotesChanged = _.debounce @onJobProfileNotesChanged, 1000
@authorizedWithLinkedIn = IN?.User?.isAuthorized()
@linkedInLoaded = Boolean(IN.parse)
@waitingForLinkedIn = false
window.contractCallback = =>
@authorizedWithLinkedIn = IN?.User?.isAuthorized()
@render()
super options
@uploadFilePath = "db/user/#{@userID}"
@highlightedContainers = []
@ -41,8 +52,90 @@ module.exports = class ProfileView extends View
else
@user = User.getByID(@userID)
onLinkedInLoaded: =>
@linkedinLoaded = true
if @waitingForLinkedIn
@renderLinkedInButton()
renderLinkedInButton: =>
IN.parse()
afterInsert: ->
super()
linkedInButtonParentElement = document.getElementById("linkedInAuthButton")
if linkedInButtonParentElement
if @linkedinLoaded
@renderLinkedInButton()
else
@waitingForLinkedIn = true
importLinkedIn: =>
application.linkedinHandler.getProfileData (err, profileData) =>
console.log profileData
@processLinkedInProfileData profileData, ->
console.log "DONE"
processLinkedInProfileData: (p, cb) ->
#handle formatted-name
currentJobProfile = me.get('jobProfile')
if p["formattedName"]? and p["formattedName"] isnt "private"
currentJobProfile.name = p["formattedName"]
if p["skills"]?["values"].length
skillNames = []
for skill in p.skills.values
skillNames.push skill.skill.name
console.log "Skills: #{skillNames}"
currentJobProfile.skills = skillNames
if p["headline"]
console.log "jobProfile.shortDescription: #{p["headline"]}"
currentJobProfile.shortDescription = p["headline"]
if p["summary"]
console.log "jobProfile.longDescription: #{p.summary}"
currentJobProfile.longDescription = p.summary
if p["positions"]?["values"]?.length
newWorks = []
for position in p["positions"]["values"]
workObj = {}
workObj.description = position.summary?.slice(0,139)
if position.startDate?.year
workObj.duration = "#{position.startDate.year} - "
if (not position.endDate?.year) or (position.endDate?.year and position.endDate?.year > (new Date().getFullYear()))
workObj.duration += "present"
else
workObj.duration += position.endDate.year
else
workObj.duration = ""
workObj.employer = position.company?.name ? ""
workObj.role = position.title ? ""
newWorks.push workObj
currentJobProfile.work = newWorks
if p["educations"]?["values"]?.length
newEducation = []
for education in p["educations"]["values"]
educationObject = {}
educationObject.degree = education.degree ? "Studied"
if education.startDate?.year
educationObject.duration = "#{education.startDate.year} - "
if (not education.endDate?.year) or (education.endDate?.year and education.endDate?.year > (new Date().getFullYear()))
educationObject.duration += "present"
if educationObject.degree is "Studied"
educationObject.degree = "Studying"
else
educationObject.duration += education.endDate.year
educationObject.school = education.schoolName ? ""
educationObject.description = ""
console.log "Educated at:#{education.schoolName}"
newEducation.push educationObject
currentJobProfile.education = newEducation
me.set('jobProfile',currentJobProfile)
@render()
getRenderData: ->
context = super()
context.linkedInAuthorized = @authorizedWithLinkedIn
context.jobProfileSchema = me.schema().properties.jobProfile
unless jobProfile = @user.get 'jobProfile'
jobProfile = {}