Implement candidate filter counts next to filters

This commit is contained in:
Michael Schmatz 2014-07-07 21:43:30 -07:00
parent e294f344c4
commit e71ca28f02
2 changed files with 27 additions and 12 deletions

View file

@ -28,50 +28,50 @@ block content
h4 Visa
label
input(type="checkbox" name="visa" value="Authorized to work in the US")
| US Authorized
| US Authorized (#{candidatesInFilter("visa","Authorized to work in the US")})
br
label
input(type="checkbox" name="visa" value="Need visa sponsorship")
| Not Authorized
| Not Authorized (#{candidatesInFilter("visa","Need visa sponsorship")})
.filter_section#school_filter
h4 Education
label
input(type="checkbox" name="schoolFilter" value="Top School")
| Top School
| Top School (#{candidatesInFilter("schoolFilter","Top School")})
br
label
input(type="checkbox" name="schoolFilter" value="Other")
| Other
| Other (#{candidatesInFilter("schoolFilter","Other")})
.filter_section#role_filter
h4 Role
label
input(type="checkbox" name="roleFilter" value="Web Developer")
| Web Developer
| Web Developer (#{candidatesInFilter("roleFilter","Web Developer")})
br
label
input(type="checkbox" name="roleFilter" value="Software Developer")
| Software Developer
| Software Developer (#{candidatesInFilter("roleFilter","Software Developer")})
br
label
input(type="checkbox" name="roleFilter" value="Mobile Developer")
| Mobile Developer
| Mobile Developer (#{candidatesInFilter("roleFilter","Mobile Developer")})
.filter_section#seniority_filter
h4 Seniority
label
input(type="checkbox" name="seniorityFilter" value="Senior")
| Senior
| Senior (#{candidatesInFilter("seniorityFilter","Senior")})
br
label
input(type="checkbox" name="seniorityFilter" value="Junior")
| Junior
| Junior (#{candidatesInFilter("seniorityFilter","Junior")})
br
label
input(type="checkbox" name="seniorityFilter" value="Recent Grad")
| Recent Grad
| Recent Grad (#{candidatesInFilter("seniorityFilter","Recent Grad")})
br
label
input(type="checkbox" name="seniorityFilter" value="College Student")
| College Student
| College Student (#{candidatesInFilter("seniorityFilter","College Student")})
//input#select_all_checkbox(type="checkbox" name="select_all" checked)
//| Select all

View file

@ -118,10 +118,24 @@ module.exports = class EmployersView extends View
seniorityFilter: ['College Student', 'Recent Grad', 'Junior', 'Senior']
@defaultFilters = _.cloneDeep @filters
candidatesInFilter: (filterName, filterValue) =>
candidates = @getActiveAndApprovedCandidates()
if filterName and filterValue
if filterName is 'visa'
return (_.filter candidates, (c) -> c.get('jobProfile').visa is filterValue).length
else
return (_.filter candidates, (c) -> c.get('jobProfile').curated?[filterName] is filterValue).length
else
return Math.floor(Math.random() * 500)
getActiveAndApprovedCandidates: =>
candidates = _.filter @candidates.models, (c) -> c.get('jobProfile').active
return _.filter candidates, (c) -> c.get('jobProfileApproved')
getRenderData: ->
ctx = super()
ctx.isEmployer = @isEmployer()
#If you change the candidates displayed, change candidatesInFilter()
ctx.candidates = _.sortBy @candidates.models, (c) -> -1 * c.get('jobProfile').experience
ctx.candidates = _.sortBy ctx.candidates, (c) -> not c.get('jobProfile').curated?
ctx.candidates = _.sortBy ctx.candidates, (c) -> c.get('jobProfile').curated?.featured
@ -134,6 +148,7 @@ module.exports = class EmployersView extends View
ctx.featuredCandidates = ctx.featuredCandidates.slice(0,7)
if me.isAdmin()
ctx.featuredCandidates = ctx.candidates
ctx.candidatesInFilter = @candidatesInFilter
ctx.otherCandidates = _.reject ctx.activeCandidates, (c) -> c.get('jobProfileApproved')
ctx.remarks = {}
ctx.remarks[remark.get('user')] = remark for remark in @remarks.models