mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Add filter alerts to employer page
This commit is contained in:
parent
e8ffb8980f
commit
f100c4ebbe
5 changed files with 64 additions and 7 deletions
|
@ -181,7 +181,7 @@ _.extend UserSchema.properties,
|
|||
}, c.object({
|
||||
title: 'Saved filter set'
|
||||
description: 'A saved filter set'
|
||||
required: ['phoneScreenFilter','schoolFilter','locationFilter','roleFilter','seniorityFilter','visa','filterActive']
|
||||
required: ['phoneScreenFilter','schoolFilter','locationFilter','roleFilter','seniorityFilter','visa']
|
||||
}, {
|
||||
phoneScreenFilter:
|
||||
title: 'Phone screen filter values'
|
||||
|
|
|
@ -63,7 +63,15 @@
|
|||
cursor: pointer
|
||||
input
|
||||
margin-right: 5px
|
||||
|
||||
#saved-filter-table
|
||||
display: none
|
||||
width: 100%
|
||||
tbody
|
||||
tr:nth-child(even)
|
||||
background-color: #CBCBCB
|
||||
margin-bottom: 20px
|
||||
.deletion-row
|
||||
text-align: center
|
||||
.get-started-button
|
||||
vertical-align: text-bottom
|
||||
margin-left: 10px
|
||||
|
|
|
@ -90,7 +90,15 @@ block content
|
|||
p#results
|
||||
| #{numberOfCandidates}
|
||||
span(data-i18n="employers.results") results
|
||||
//button.btn#create-alert-button Create Alert
|
||||
h4#filter-alerts-heading Filter Email Alerts
|
||||
p Get an email whenever a candidate meeting certain criteria enters the system.
|
||||
table#saved-filter-table
|
||||
thead
|
||||
tr
|
||||
th Filters
|
||||
th Remove
|
||||
tbody
|
||||
button.btn#create-alert-button Create Alert with Current Filters
|
||||
|
||||
#candidates-column(class=fullProfiles ? "full-profiles col-md-9" : "teaser-profiles col-md-12")
|
||||
if candidates.length
|
||||
|
|
|
@ -20,15 +20,16 @@ module.exports = class EmployersView extends RootView
|
|||
template: template
|
||||
|
||||
events:
|
||||
'click tbody tr': 'onCandidateClicked'
|
||||
'click #candidate-table': 'onCandidateClicked'
|
||||
'click #logout-link': 'logoutAccount'
|
||||
'change #filters input': 'onFilterChanged'
|
||||
'click #filter-button': 'applyFilters'
|
||||
'change #select_all_checkbox': 'handleSelectAllChange'
|
||||
'click .get-started-button': 'openSignupModal'
|
||||
'click .navbar-brand': 'restoreBodyColor'
|
||||
'click #login-link': 'onClickAuthbutton'
|
||||
'click #filter-link': 'swapFolderIcon'
|
||||
'click #create-alert-button': 'createFilterAlert'
|
||||
'click .deletion-col': 'deleteFilterAlert'
|
||||
|
||||
constructor: (options) ->
|
||||
super options
|
||||
|
@ -39,6 +40,7 @@ module.exports = class EmployersView extends RootView
|
|||
afterRender: ->
|
||||
super()
|
||||
@sortTable() if @candidates.models.length
|
||||
@renderSavedFilters()
|
||||
|
||||
afterInsert: ->
|
||||
super()
|
||||
|
@ -128,6 +130,45 @@ module.exports = class EmployersView extends RootView
|
|||
return (_.filter candidates, (c) -> c.get('jobProfile').curated?[filterName] is filterValue).length
|
||||
else
|
||||
return Math.floor(Math.random() * 500)
|
||||
createFilterAlert: ->
|
||||
currentFilterSet = _.cloneDeep @filters
|
||||
currentSavedFilters = _.cloneDeep me.get('savedEmployerFilterAlerts') ? []
|
||||
currentSavedFilters.push currentFilterSet
|
||||
@patchEmployerFilterAlerts currentSavedFilters, @renderSavedFilters
|
||||
|
||||
deleteFilterAlert: (e) ->
|
||||
index = $(e.target).closest('tbody tr').data('filter-index')
|
||||
currentSavedFilters = me.get('savedEmployerFilterAlerts')
|
||||
currentSavedFilters.splice(index,1)
|
||||
@patchEmployerFilterAlerts currentSavedFilters, @renderSavedFilters
|
||||
|
||||
patchEmployerFilterAlerts: (newFilters, cb) ->
|
||||
me.set('savedEmployerFilterAlerts',newFilters)
|
||||
unless me.isValid()
|
||||
alert("There was an error setting the filter(me.isValid() returned false.) Reverting! Please notify team@codecombat.com.")
|
||||
me.set 'savedEmployerFilterAlerts', me.previous('savedEmployerFilterAlerts')
|
||||
else
|
||||
triggerErrorAlert = -> alert("There was an error saving your filter alert! Please notify team@codecombat.com.")
|
||||
res = me.save {"savedEmployerFilterAlerts": newFilters}, {patch: true, success: cb, error: triggerErrorAlert}
|
||||
|
||||
renderSavedFilters: =>
|
||||
savedFilters = me.get('savedEmployerFilterAlerts')
|
||||
unless savedFilters?.length then return $("#saved-filter-table").hide()
|
||||
$("#saved-filter-table").show()
|
||||
$("#saved-filter-table").find("tbody tr").remove()
|
||||
for filter, index in savedFilters
|
||||
$("#saved-filter-table tbody").append("""<tr data-filter-index="#{index}"><td>#{@generateFilterAlertDescription(filter)}</td><td class="deletion-col"><a>✗</a></td></tr> """)
|
||||
|
||||
|
||||
generateFilterAlertDescription: (filter) =>
|
||||
descriptionString = ""
|
||||
for key in _.keys(filter).sort()
|
||||
value = filter[key]
|
||||
if key is "filterActive" or _.without(@defaultFilters[key],value...).length is 0 then continue
|
||||
if descriptionString.length then descriptionString += ", "
|
||||
descriptionString += value.join(", ")
|
||||
if descriptionString.length is 0 then descriptionString = "Any new candidate"
|
||||
return descriptionString
|
||||
|
||||
getActiveAndApprovedCandidates: =>
|
||||
candidates = _.filter @candidates.models, (c) -> c.get('jobProfile').active
|
||||
|
|
|
@ -29,7 +29,7 @@ UserHandler = class UserHandler extends Handler
|
|||
'name', 'photoURL', 'password', 'anonymous', 'wizardColor1', 'volume',
|
||||
'firstName', 'lastName', 'gender', 'facebookID', 'gplusID', 'emails',
|
||||
'testGroupNumber', 'music', 'hourOfCode', 'hourOfCodeComplete', 'preferredLanguage',
|
||||
'wizard', 'aceConfig', 'autocastDelay', 'lastLevel', 'jobProfile'
|
||||
'wizard', 'aceConfig', 'autocastDelay', 'lastLevel', 'jobProfile', 'savedEmployerFilterAlerts'
|
||||
]
|
||||
|
||||
getEditableProperties: (req, document) ->
|
||||
|
|
Loading…
Reference in a new issue