MDL-54852 assignment: Suppress "leave page" warning after save
authorJan Dageförde <jan.dagefoerde@ercis.uni-muenster.de>
Sun, 6 Nov 2016 20:41:02 +0000 (21:41 +0100)
committerJan Dageförde <jan.dagefoerde@ercis.uni-muenster.de>
Mon, 7 Nov 2016 09:35:06 +0000 (10:35 +0100)
If the user navigates away from the grading page immediately
after saving the grading form, the browser warning can be
safely omitted, as there are no unsaved changes. This is achieved
by calling `reset_form_dirty_state()` of the core_formchangechecker
YUI module, which is responsible for the warning.

mod/assign/amd/build/grading_panel.min.js
mod/assign/amd/src/grading_panel.js

index 3bd700c..90f6866 100644 (file)
Binary files a/mod/assign/amd/build/grading_panel.min.js and b/mod/assign/amd/build/grading_panel.min.js differ
index 4f380b8..1c43216 100644 (file)
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since      3.1
  */
-define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
+define(['jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragment',
         'core/ajax', 'core/str', 'mod_assign/grading_form_change_checker',
         'mod_assign/grading_events'],
-       function($, notification, templates, fragment, ajax, str, checker, GradingEvents) {
+       function($, Y, notification, templates, fragment, ajax, str, checker, GradingEvents) {
 
     /**
      * GradingPanel class.
@@ -147,6 +147,9 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
             ]).done(function(strs) {
                 notification.alert(strs[0], strs[1]);
             }).fail(notification.exception);
+            Y.use('moodle-core-formchangechecker', function() {
+                M.core_formchangechecker.reset_form_dirty_state();
+            });
             if (nextUserId == this._lastUserId) {
                 $(document).trigger('reset', nextUserId);
             } else {