mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Filter functional
This commit is contained in:
parent
b58f2c49eb
commit
ae63461ef3
3 changed files with 51 additions and 33 deletions
|
@ -42,7 +42,7 @@
|
||||||
display: inline-block
|
display: inline-block
|
||||||
button
|
button
|
||||||
display: inline-block
|
display: inline-block
|
||||||
h1, h2, h3
|
h1, h2, h3, h4
|
||||||
font-family: Arial, Helvetica, sans-serif
|
font-family: Arial, Helvetica, sans-serif
|
||||||
color: #333333
|
color: #333333
|
||||||
#tagline
|
#tagline
|
||||||
|
|
|
@ -11,7 +11,7 @@ block content
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-heading
|
.panel-heading
|
||||||
h4.panel-title
|
h4.panel-title
|
||||||
a(data-toggle="collapse" data-target="#collapseOne" href="#collapseOne")
|
a(data-toggle="collapse" data-target="#collapseOne")
|
||||||
span.glyphicon.glyphicon-folder-open
|
span.glyphicon.glyphicon-folder-open
|
||||||
| Filter
|
| Filter
|
||||||
.panel-collapse.collapse.in#collapseOne
|
.panel-collapse.collapse.in#collapseOne
|
||||||
|
@ -19,72 +19,77 @@ block content
|
||||||
form#filters
|
form#filters
|
||||||
.filter_section#screened_filter
|
.filter_section#screened_filter
|
||||||
h4 Screened
|
h4 Screened
|
||||||
input(type="checkbox" name="phoneScreenFilter" value=true)
|
input(type="checkbox" name="phoneScreenFilter" value="true" checked)
|
||||||
| Phone Screened
|
| Phone Screened
|
||||||
|
br
|
||||||
|
input(type="checkbox" name="phoneScreenFilter" value="false" checked)
|
||||||
|
| Not Phone Screened
|
||||||
.filter_section#visa_filter
|
.filter_section#visa_filter
|
||||||
h4 Visa
|
h4 Visa
|
||||||
input(type="checkbox" name="visa" value="Authorized to work in the US")
|
input(type="checkbox" name="visa" value="Authorized to work in the US" checked)
|
||||||
| US Authorized
|
| US Authorized
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="visa" value="Need visa sponsorship")
|
input(type="checkbox" name="visa" value="Need visa sponsorship" checked)
|
||||||
| Not Authorized
|
| Not Authorized
|
||||||
.filter_section#school_filter
|
.filter_section#school_filter
|
||||||
h4 School
|
h4 School
|
||||||
input(type="checkbox" name="schoolFilter" value="Top 20 Eng.")
|
input(type="checkbox" name="schoolFilter" value="Top 20 Eng." checked)
|
||||||
| Top 20 Eng.
|
| Top 20 Eng.
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="schoolFilter" value="Other US")
|
input(type="checkbox" name="schoolFilter" value="Other US" checked)
|
||||||
| Other US
|
| Other US
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="schoolFilter" value="Other Intl.")
|
input(type="checkbox" name="schoolFilter" value="Other Intl." checked)
|
||||||
| Other Intl.
|
| Other Intl.
|
||||||
.filter_section#location_filter
|
.filter_section#location_filter
|
||||||
h4 Location
|
h4 Location
|
||||||
input(type="checkbox" name="locationFilter" value="Bay Area")
|
input(type="checkbox" name="locationFilter" value="Bay Area" checked)
|
||||||
| Bay Area
|
| Bay Area
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="locationFilter" value="New York")
|
input(type="checkbox" name="locationFilter" value="New York" checked)
|
||||||
| New York
|
| New York
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="locationFilter" value="Other US")
|
input(type="checkbox" name="locationFilter" value="Other US" checked)
|
||||||
| Other US
|
| Other US
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="locationFilter" value="International")
|
input(type="checkbox" name="locationFilter" value="International" checked)
|
||||||
| International
|
| International
|
||||||
.filter_section#role_filter
|
.filter_section#role_filter
|
||||||
h4 Role
|
h4 Role
|
||||||
input(type="checkbox" name="roleFilter" value="Web Developer")
|
input(type="checkbox" name="roleFilter" value="Web Developer" checked)
|
||||||
| Web Developer
|
| Web Developer
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="roleFilter" value="Software Developer")
|
input(type="checkbox" name="roleFilter" value="Software Developer" checked)
|
||||||
| Software Developer
|
| Software Developer
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="roleFilter" value="iOS Developer")
|
input(type="checkbox" name="roleFilter" value="iOS Developer" checked)
|
||||||
| iOS Developer
|
| iOS Developer
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="roleFilter" value="Android Developer")
|
input(type="checkbox" name="roleFilter" value="Android Developer" checked)
|
||||||
| Android Developer
|
| Android Developer
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="roleFilter" value="Project Manager")
|
input(type="checkbox" name="roleFilter" value="Project Manager" checked)
|
||||||
| Project Developer
|
| Project Developer
|
||||||
.filter_section#seniority_filter
|
.filter_section#seniority_filter
|
||||||
h4 Seniority
|
h4 Seniority
|
||||||
input(type="checkbox" name="seniorityFilter" value="College Student")
|
input(type="checkbox" name="seniorityFilter" value="College Student" checked)
|
||||||
| College Student
|
| College Student
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="seniorityFilter" value="Recent Grad")
|
input(type="checkbox" name="seniorityFilter" value="Recent Grad" checked)
|
||||||
| Recent Grad
|
| Recent Grad
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="seniorityFilter" value="Junior")
|
input(type="checkbox" name="seniorityFilter" value="Junior" checked)
|
||||||
| Junior
|
| Junior
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="seniorityFilter" value="Senior")
|
input(type="checkbox" name="seniorityFilter" value="Senior" checked)
|
||||||
| Senior
|
| Senior
|
||||||
br
|
br
|
||||||
input(type="checkbox" name="seniorityFilter" value="Management")
|
input(type="checkbox" name="seniorityFilter" value="Management" checked)
|
||||||
| Management
|
| Management
|
||||||
|
input#select_all_checkbox(type="checkbox" name="select_all" checked)
|
||||||
|
| Select all
|
||||||
button.btn#filter-button Filter
|
button.btn#filter-button Filter
|
||||||
button.btn#create-alert-button Create Alert
|
//button.btn#create-alert-button Create Alert
|
||||||
if candidates.length
|
if candidates.length
|
||||||
#candidate-table
|
#candidate-table
|
||||||
table
|
table
|
||||||
|
|
|
@ -23,12 +23,14 @@ module.exports = class EmployersView extends View
|
||||||
'click tbody tr': 'onCandidateClicked'
|
'click tbody tr': 'onCandidateClicked'
|
||||||
'change #filters input': 'onFilterChanged'
|
'change #filters input': 'onFilterChanged'
|
||||||
'click #filter-button': 'applyFilters'
|
'click #filter-button': 'applyFilters'
|
||||||
|
'change #select_all_checkbox': 'handleSelectAllChange'
|
||||||
|
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
super options
|
super options
|
||||||
@getCandidates()
|
@getCandidates()
|
||||||
@setFilterDefaults()
|
@setFilterDefaults()
|
||||||
|
|
||||||
|
|
||||||
afterRender: ->
|
afterRender: ->
|
||||||
super()
|
super()
|
||||||
@sortTable() if @candidates.models.length
|
@sortTable() if @candidates.models.length
|
||||||
|
@ -36,15 +38,26 @@ module.exports = class EmployersView extends View
|
||||||
afterInsert: ->
|
afterInsert: ->
|
||||||
super()
|
super()
|
||||||
_.delay @checkForEmployerSignupHash, 500
|
_.delay @checkForEmployerSignupHash, 500
|
||||||
onFilterChanged: (e) ->
|
|
||||||
|
onFilterChanged: ->
|
||||||
@resetFilters()
|
@resetFilters()
|
||||||
that = @
|
that = @
|
||||||
$("#filters :input").each ->
|
$("#filters :input").each ->
|
||||||
input = $(this)
|
input = $(this)
|
||||||
checked = input.prop 'checked'
|
checked = input.prop 'checked'
|
||||||
name = input.attr 'name'
|
name = input.attr 'name'
|
||||||
|
value = input.val()
|
||||||
|
if name is "phoneScreenFilter"
|
||||||
|
value = JSON.parse(input.prop 'value')
|
||||||
if checked
|
if checked
|
||||||
that.filters[name] = _.union that.filters[name], [input.val()]
|
that.filters[name] = _.union that.filters[name], [value]
|
||||||
|
else
|
||||||
|
that.filters[name] = _.difference that.filters[name], [value]
|
||||||
|
handleSelectAllChange: (e) ->
|
||||||
|
checkedState = e.currentTarget.checked
|
||||||
|
$("#filters :input").each ->
|
||||||
|
$(this).prop 'checked', checkedState
|
||||||
|
@onFilterChanged()
|
||||||
|
|
||||||
resetFilters: ->
|
resetFilters: ->
|
||||||
for filterName, filterValues of @filters
|
for filterName, filterValues of @filters
|
||||||
|
@ -54,18 +67,18 @@ module.exports = class EmployersView extends View
|
||||||
candidateList = _.sortBy @candidates.models, (c) -> c.get('jobProfile').updated
|
candidateList = _.sortBy @candidates.models, (c) -> c.get('jobProfile').updated
|
||||||
candidateList = _.filter candidateList, (c) -> c.get('jobProfileApproved')
|
candidateList = _.filter candidateList, (c) -> c.get('jobProfileApproved')
|
||||||
|
|
||||||
filteredCandidates = []
|
filteredCandidates = candidateList
|
||||||
for filterName, filterValues of @filters
|
for filterName, filterValues of @filters
|
||||||
if filterName is "visa"
|
if filterName is "visa"
|
||||||
filteredCandidates = _.union filteredCandidates, _.filter(candidateList, (c) ->
|
filteredCandidates = _.difference filteredCandidates, _.filter(filteredCandidates, (c) ->
|
||||||
fieldValue = c.get('jobProfile').visa
|
fieldValue = c.get('jobProfile').visa
|
||||||
return _.contains filterValues, fieldValue
|
return not (_.contains filterValues, fieldValue)
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
filteredCandidates = _.union filteredCandidates, _.filter(candidateList, (c) ->
|
filteredCandidates = _.difference filteredCandidates, _.filter(filteredCandidates, (c) ->
|
||||||
unless c.get('jobProfile').curated then return false
|
unless c.get('jobProfile').curated then return true
|
||||||
fieldValue = c.get('jobProfile').curated?[filterName]
|
fieldValue = c.get('jobProfile').curated?[filterName]
|
||||||
return _.contains filterValues, fieldValue
|
return not (_.contains filterValues, fieldValue)
|
||||||
)
|
)
|
||||||
candidateIDsToShow = _.pluck filteredCandidates, 'id'
|
candidateIDsToShow = _.pluck filteredCandidates, 'id'
|
||||||
$("#candidate-table tr").each -> $(this).hide()
|
$("#candidate-table tr").each -> $(this).hide()
|
||||||
|
@ -76,7 +89,7 @@ module.exports = class EmployersView extends View
|
||||||
return filteredCandidates
|
return filteredCandidates
|
||||||
setFilterDefaults: ->
|
setFilterDefaults: ->
|
||||||
@filters =
|
@filters =
|
||||||
phoneScreenFilter: [true]
|
phoneScreenFilter: [true, false]
|
||||||
visa: ['Authorized to work in the US', 'Need visa sponsorship']
|
visa: ['Authorized to work in the US', 'Need visa sponsorship']
|
||||||
schoolFilter: ['Top 20 Eng.', 'Other US', 'Other Intl.']
|
schoolFilter: ['Top 20 Eng.', 'Other US', 'Other Intl.']
|
||||||
locationFilter: ['Bay Area', 'New York', 'Other US', 'International']
|
locationFilter: ['Bay Area', 'New York', 'Other US', 'International']
|
||||||
|
|
Loading…
Reference in a new issue