MDL-69613 gradereport: confirm message if override none is selected

This commit is contained in:
Nathan Nguyen 2020-09-23 12:41:40 +10:00
parent 5486b031ee
commit ee1f0fb18a
3 changed files with 25 additions and 1 deletions

View File

@ -268,6 +268,7 @@ abstract class screen {
'requires' => array('base', 'dom', 'event', 'event-simulate', 'io-base')
);
$PAGE->requires->string_for_js('overridenoneconfirm', 'gradereport_singleview');
$PAGE->requires->js_init_call('M.gradereport_singleview.init', array(), false, $module);
}

View File

@ -1,6 +1,11 @@
M.gradereport_singleview = {};
M.gradereport_singleview.init = function(Y) {
if (this.initialised) {
return;
}
this.initialised = true;
var getColumnIndex = function(cell) {
var rowNode = cell.ancestor('tr');
if (!rowNode || !cell) {
@ -104,7 +109,24 @@ M.gradereport_singleview.init = function(Y) {
link.on('click', function(e) {
e.preventDefault();
Y.all('input[name^=' + type + ']').each(toggle(link.hasClass('all')));
var selectall = link.hasClass('all');
var self = this;
if ((type === 'override') && !selectall) {
Y.use('moodle-core-notification-confirm', function() {
var confirm = new M.core.confirm({
title: M.util.get_string('confirm', 'moodle'),
question: M.util.get_string('overridenoneconfirm', 'gradereport_singleview'),
});
confirm.on('complete-yes', function() {
confirm.hide();
confirm.destroy();
Y.all('input[name^=' + type + ']').each(toggle(link.hasClass('all')));
}, self);
confirm.show();
});
} else {
Y.all('input[name^=' + type + ']').each(toggle(link.hasClass('all')));
}
});
});

View File

@ -50,6 +50,7 @@ $string['override'] = 'Override';
$string['overrideall'] = 'Override all grades';
$string['overridefor'] = 'Override for {$a}';
$string['overridenone'] = 'Do not override any grades';
$string['overridenoneconfirm'] = 'You are trying to disable all grade overrides. After saving, all the previously overridden grades will be lost. Do you want to continue?';
$string['pluginname'] = 'Single view';
$string['privacy:metadata'] = 'The Grade single view report only shows data stored in other locations.';
$string['savegrades'] = 'Saving grades';