Working on some flagging coffeescript
This commit is contained in:
@@ -23,26 +23,34 @@ class OpenEnded
|
||||
parent_tr = $(event.target).parent().parent()
|
||||
tr_children = parent_tr.children()
|
||||
action_type = "unflag"
|
||||
submission_id = tr_children[4].innerText
|
||||
student_id = tr_children[5].innerText
|
||||
@post('take_action_on_flags', {'submission_id' : submission_id, 'student_id' : student_id, 'action_type' : action_type}, @handle_after_action)
|
||||
submission_id = tr_children[5].innerText
|
||||
student_id = tr_children[6].innerText
|
||||
callback_func = @after_action_wrapper($(event.target), action_type)
|
||||
@post('take_action_on_flags', {'submission_id' : submission_id, 'student_id' : student_id, 'action_type' : action_type}, callback_func)
|
||||
|
||||
ban: (event) =>
|
||||
event.preventDefault()
|
||||
parent_tr = $(event.target).parent().parent()
|
||||
tr_children = parent_tr.children()
|
||||
action_type = "ban"
|
||||
submission_id = tr_children[4].innerText
|
||||
student_id = tr_children[5].innerText
|
||||
@post('take_action_on_flags', {'submission_id' : submission_id, 'student_id' : student_id, 'action_type' : action_type}, @handle_after_action)
|
||||
submission_id = tr_children[5].innerText
|
||||
student_id = tr_children[6].innerText
|
||||
callback_func = @after_action_wrapper($(event.target), action_type)
|
||||
@post('take_action_on_flags', {'submission_id' : submission_id, 'student_id' : student_id, 'action_type' : action_type}, callback_func)
|
||||
|
||||
post: (cmd, data, callback) ->
|
||||
# if this post request fails, the error callback will catch it
|
||||
$.post(@ajax_url + cmd, data, callback)
|
||||
.error => callback({success: false, error: "Error occured while performing this operation"})
|
||||
|
||||
after_action_wrapper: (target, action_type) ->
|
||||
return @handle_after_action
|
||||
|
||||
handle_after_action: (data) ->
|
||||
@gentle_alert data.data
|
||||
tr_parent = target.parent().parent()
|
||||
tr_children = tr_parent.children()
|
||||
action_taken = tr_children[4].children()[0]
|
||||
action_taken.replaceWith('<div class="action-taken">#{action_type} done for student.</div>')
|
||||
|
||||
gentle_alert: (msg) =>
|
||||
if $('.message-container').length
|
||||
|
||||
@@ -47,6 +47,9 @@
|
||||
<td>
|
||||
<a href="#ban" class="ban-button action-button" data-action-type="ban">Ban</a>
|
||||
</td>
|
||||
<td>
|
||||
<div class="action-taken"></div>
|
||||
</td>
|
||||
<td style="display:none;">
|
||||
${problem['submission_id']}
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user