Commit 588a307d by Miles Steele

add dangerous button confirmation popup

parent 02b7757d
......@@ -7,6 +7,12 @@ plantTimeout = -> window.InstructorDashboard.util.plantTimeout.apply this, argum
plantInterval = -> window.InstructorDashboard.util.plantInterval.apply this, arguments
std_ajax_err = -> window.InstructorDashboard.util.std_ajax_err.apply this, arguments
# wrap window.confirm
# display `msg`
# run `ok` or `cancel` depending on response
confirm_then = ({msg, ok, cancel}) ->
if window.confirm msg then ok?() else cancel?()
# get jquery element and assert its existance
find_and_assert = ($root, selector) ->
item = $root.find selector
......@@ -156,7 +162,9 @@ class StudentAdmin
error: std_ajax_err => @$request_response_error_single.text "Error resetting problem attempts."
# delete state for student on problem
@$btn_delete_state_single.click =>
@$btn_delete_state_single.click => confirm_then
msg: "Delete student '#{@$field_student_select.val()}'s state on problem '#{@$field_problem_select_single.val()}'?"
ok: =>
send_data =
student_email: @$field_student_select.val()
problem_to_reset: @$field_problem_select_single.val()
......@@ -202,7 +210,9 @@ class StudentAdmin
error: std_ajax_err => @$request_response_error_single.text "Error getting task history for student+problem"
# start task to reset attempts on problem for all students
@$btn_reset_attempts_all.click =>
@$btn_reset_attempts_all.click => confirm_then
msg: "Reset attempts for all students on problem '#{@$field_problem_select_all.val()}'?"
ok: =>
send_data =
all_students: true
problem_to_reset: @$field_problem_select_all.val()
......@@ -215,20 +225,9 @@ class StudentAdmin
error: std_ajax_err => @$request_response_error_all.text "Error starting a task to reset attempts for all students on this problem."
# start task to rescore problem for all students
@$btn_reset_attempts_all.click =>
send_data =
all_students: true
problem_to_reset: @$field_problem_select_all.val()
$.ajax
dataType: 'json'
url: @$btn_reset_attempts_all.data 'endpoint'
data: send_data
success: @clear_errors_then -> console.log 'started reset attempts task'
error: std_ajax_err => @$request_response_error_all.text "Error starting a task to reset attempts on this problem for all students."
# start task to rescore problem for all students
@$btn_rescore_problem_all.click =>
@$btn_rescore_problem_all.click => confirm_then
msg: "Rescore problem '#{@$field_problem_select_all.val()}' for all students?"
ok: =>
send_data =
all_students: true
problem_to_reset: @$field_problem_select_all.val()
......
......@@ -63,7 +63,9 @@
@include idashbutton(#eee);
&.molly-guard {
@include idashbutton($danger-red);
// @include idashbutton($danger-red);
// @include idashbutton($black);
// border: 2px solid $danger-red;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment