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

View file

@ -118,10 +118,24 @@ module.exports = class EmployersView extends View
seniorityFilter: ['College Student', 'Recent Grad', 'Junior', 'Senior'] seniorityFilter: ['College Student', 'Recent Grad', 'Junior', 'Senior']
@defaultFilters = _.cloneDeep @filters @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: -> getRenderData: ->
ctx = super() ctx = super()
ctx.isEmployer = @isEmployer() 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 @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) -> not c.get('jobProfile').curated?
ctx.candidates = _.sortBy ctx.candidates, (c) -> c.get('jobProfile').curated?.featured 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) ctx.featuredCandidates = ctx.featuredCandidates.slice(0,7)
if me.isAdmin() if me.isAdmin()
ctx.featuredCandidates = ctx.candidates ctx.featuredCandidates = ctx.candidates
ctx.candidatesInFilter = @candidatesInFilter
ctx.otherCandidates = _.reject ctx.activeCandidates, (c) -> c.get('jobProfileApproved') ctx.otherCandidates = _.reject ctx.activeCandidates, (c) -> c.get('jobProfileApproved')
ctx.remarks = {} ctx.remarks = {}
ctx.remarks[remark.get('user')] = remark for remark in @remarks.models ctx.remarks[remark.get('user')] = remark for remark in @remarks.models