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