Don't allow second click to submit upload form.

Fixes CNVS-3718

When a user submits the gradebook upload form and double-clicks the
"save changes" button, it can cause server-side issues. To prevent
issues from occurring when a form is submitted twice, an event
listener disables the submit button the first time it is clicked.

Test plan:
1. Export the gradebook from a large course.
2. Change a grade on one or two of the assignments.
3. Import the gradebook.
4. Choose the file and click "upload data".
5. Review the changes and **double-click** "save changes."

As the button is disabled on the first click, the second click
should have no effect. No duplicate key value violates unique
constraint error should arise. Note that the button is disabled
for only one half a second.

See also: http://screencast.com/t/gNewKyi1

Change-Id: I274bd5cf4e316178e5e65de7d37ed6dee8e88735
Reviewed-on: https://gerrit.instructure.com/50263
Reviewed-by: Josh Simpson <jsimpson@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Tested-by: Jenkins
Product-Review: Strand McCutchen <smccutchen@instructure.com>
This commit is contained in:
Strand McCutchen 2015-03-12 14:15:48 -07:00
parent 5c5baf1113
commit 7e61b49e74
1 changed files with 9 additions and 0 deletions

View File

@ -119,6 +119,15 @@ define([
else {
$("#no_changes_detected").show();
}
// Only allow the submit button to be clicked once.
$('#gradebook_grid_form button[type=submit]').click(function() {
$(this).prop("disabled", true);
$(this).parents('form').submit()
window.setTimeout(function(that) {
that.prop("disabled", false);
}, 500, $(this));
})
},
handleThingsNeedingToBeResolved: function(){