MDL-54852 assignment: Suppress "leave page" warning after save

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.
This commit is contained in:
Jan Dageförde
2016-11-06 21:58:18 +01:00
parent c1971a2fdf
commit ce50f55c1f
2 changed files with 8 additions and 3 deletions
File diff suppressed because one or more lines are too long
+7 -2
View File
@@ -23,10 +23,14 @@
* @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) {
Y.use('moodle-core-formchangechecker', function(){
// moodle-core-formchangechecker is now available via M.core_formchangechecker
});
/**
* GradingPanel class.
@@ -144,6 +148,7 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
{ key: 'gradechangessaveddetail', component: 'mod_assign' },
]).done(function(strs) {
notification.alert(strs[0], strs[1]);
M.core_formchangechecker.reset_form_dirty_state();
}).fail(notification.exception);
if (nextUserId == this._lastUserId) {
$(document).trigger('reset', nextUserId);