Skip to content

Commit

Permalink
MDL-69613 gradereport: confirm message if override none is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Nguyen committed Sep 28, 2020
1 parent 5486b03 commit ee1f0fb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions grade/report/singleview/classes/local/screen/screen.php
Expand Up @@ -268,6 +268,7 @@ public function js() {
'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);
}

Expand Down
24 changes: 23 additions & 1 deletion grade/report/singleview/js/singleview.js
@@ -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) {
Expand Down Expand Up @@ -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')));
}
});
});

Expand Down
1 change: 1 addition & 0 deletions grade/report/singleview/lang/en/gradereport_singleview.php
Expand Up @@ -50,6 +50,7 @@
$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';
Expand Down

0 comments on commit ee1f0fb

Please sign in to comment.