MDL-66679 Forms: Submit button remains disabled after file download

When you download a file directly from a Moodle form submit button,
the submit button disables when you click it, but you remain on that
page so we need to re-enable the button.

This commit causes it to re-enable once the file download finishes,
setting a temporary cookie to indicate this to the JavaScript code.

It also adds a method to disable the system on a given form by
setting data-double-submit-protection="off".
This commit is contained in:
sam marshall
2019-10-30 16:36:28 +00:00
parent d7699706da
commit 225eb7b27e
11 changed files with 162 additions and 3 deletions
+3
View File
@@ -54,6 +54,9 @@ function download_as_dataformat($filename, $dataformat, $columns, $iterator, $ca
// Close the session so that the users other tabs in the same session are not blocked.
\core\session\manager::write_close();
// If this file was requested from a form, then mark download as complete (before sending headers).
\core_form\util::form_download_complete();
$format->set_filename($filename);
$format->send_http_headers();
// This exists to support all dataformats - see MDL-56046.