added bulk removing of users to group admin panel

This commit is contained in:
Henry Oswald 2014-03-03 17:48:48 +00:00
parent c991625a27
commit a0805f97e0
2 changed files with 34 additions and 20 deletions

View file

@ -14,6 +14,7 @@ block content
table.table-striped.table.table-striped
thead
tr
th
th email
th Name
th Registered
@ -21,13 +22,19 @@ block content
tbody#userList
-each user in users
tr
td
input(type="checkbox")
td #{user.email}
td #{user.first_name} #{user.last_name}
td #{!user.holdingAccount}
td
button.btn.btn-danger(id=user._id) Remove
input(type="hidden", name="user_id", value=user._id).user_id {{user._id}}
div
button.btn.btn-danger#deleteUsers Delete Selected
div  
div
form.well.form-inline#addUserToGroup
div
input(name="_csrf", type="hidden", value=csrfToken)
@ -36,6 +43,7 @@ block content
div  
div Add multiple emails seperated with commas or space.
- locals.supressDefaultJs = true
script(data-main='/js/SubscriptionGroupsManager.js', src='/js/libs/require.js')

View file

@ -7,10 +7,13 @@ require [
tableRowTemplate = '''
<tr>
<td> <input type="checkbox"></td>
<td> {{ email }} </td>
<td> {{ first_name }} {{ last_name }} </td>
<td> {{ !holdingAccount }} </td>
<td><button id="{{_id}}"" class="btn btn-danger">Remove</button></td>
<td>
<input type="hidden" name="user_id" value="{{user_id}}" class="user_id">
</td>
</tr>
'''
@ -54,16 +57,19 @@ require [
sendNewUserToServer(email)
$form.find("input").val('')
removeUser = (e)->
button = $(e.target)
user_id = button.attr("id")
removeUsers = (e)->
selectedUserRows = $('td input:checked').closest('tr').find(".user_id")
selectedUserRows.each (index, userRow)->
user_id = $(userRow).val()
$.ajax
url: "/subscription/group/user/#{user_id}"
type: 'DELETE'
data:
_csrf: csrfToken
success: ->
button.parents("tr").fadeOut(250)
$(userRow).parents("tr").fadeOut(250)
$form.on 'keypress', (e)->
if(e.keyCode == 13)
@ -71,4 +77,4 @@ require [
$form.find(".addUser").on 'click', addUser
$('table').on 'click', '.btn-danger', removeUser
$('#deleteUsers').on 'click', removeUsers