Skip to content

Commit

Permalink
MDL-54852 assignment: Suppress "leave page" warning after save
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dagefoerde committed Nov 6, 2016
1 parent c1971a2 commit ce50f55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mod/assign/amd/build/grading_panel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions mod/assign/amd/src/grading_panel.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ce50f55

Please sign in to comment.