MDL-77174 gradeform: Switch from YUI dialogue to utility modal

This commit is contained in:
Andrew Nicols 2023-02-10 12:55:33 +08:00
parent 222c43f8eb
commit 10838ef878
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
2 changed files with 37 additions and 16 deletions

View File

@ -178,11 +178,7 @@ M.gradingform_guideeditor.buttonclick = function(e, confirmed) {
if (action == 'addcriterion' || action == 'addcomment') {
newid = M.gradingform_guideeditor.calculatenewid(elements_str);
}
var dialog_options = {
'scope' : this,
'callbackargs' : [e, true],
'callback' : M.gradingform_guideeditor.buttonclick
};
if (chunks.length == 3 && (action == 'addcriterion' || action == 'addcomment')) {
// ADD NEW CRITERION OR COMMENT
var parentel = Y.one('#'+name+'-'+section)
@ -228,8 +224,18 @@ M.gradingform_guideeditor.buttonclick = function(e, confirmed) {
Y.one('#'+name+'-'+section+'-'+chunks[2]).remove()
M.gradingform_guideeditor.assignclasses(elements_str)
} else {
dialog_options['message'] = M.util.get_string('confirmdeletecriterion', 'gradingform_guide')
M.util.show_confirm_dialog(e, dialog_options);
require(['core/notification', 'core/str'], function(Notification, Str) {
Notification.saveCancelPromise(
Str.get_string('confirmation', 'admin'),
Str.get_string('confirmdeletecriterion', 'gradingform_guide'),
Str.get_string('yes', 'moodle')
).then(function() {
M.gradingform_guideeditor.buttonclick.apply(this, [e, true]);
return;
}.bind(this)).catch(function() {
// User cancelled.
});
}.bind(this));
}
} else {
// unknown action

View File

@ -149,11 +149,6 @@ M.gradingform_rubriceditor.buttonclick = function(e, confirmed) {
newid = M.gradingform_rubriceditor.calculatenewid('#rubric-'+name+' .criterion');
newlevid = M.gradingform_rubriceditor.calculatenewid('#rubric-'+name+' .level');
}
var dialog_options = {
'scope' : this,
'callbackargs' : [e, true],
'callback' : M.gradingform_rubriceditor.buttonclick
};
if (chunks.length == 3 && action == 'addcriterion') {
// ADD NEW CRITERION
var levelsscores = [0], levidx = 1
@ -215,8 +210,18 @@ M.gradingform_rubriceditor.buttonclick = function(e, confirmed) {
Y.one('#'+name+'-criteria-'+chunks[2]).remove()
M.gradingform_rubriceditor.assignclasses(elements_str)
} else {
dialog_options['message'] = M.util.get_string('confirmdeletecriterion', 'gradingform_rubric')
M.util.show_confirm_dialog(e, dialog_options);
require(['core/notification', 'core/str'], function(Notification, Str) {
Notification.saveCancelPromise(
Str.get_string('confirmation', 'admin'),
Str.get_string('confirmdeletecriterion', 'gradingform_rubric'),
Str.get_string('yes', 'moodle')
).then(function() {
M.gradingform_rubriceditor.buttonclick.apply(this, [e, true]);
return;
}.bind(this)).catch(function() {
// User cancelled.
});
}.bind(this));
}
} else if (chunks.length == 4 && action == 'duplicate') {
// Duplicate criterion.
@ -259,8 +264,18 @@ M.gradingform_rubriceditor.buttonclick = function(e, confirmed) {
Y.one('#'+name+'-criteria-'+chunks[2]+'-'+chunks[3]+'-'+chunks[4]).remove()
M.gradingform_rubriceditor.assignclasses(elements_str)
} else {
dialog_options['message'] = M.util.get_string('confirmdeletelevel', 'gradingform_rubric')
M.util.show_confirm_dialog(e, dialog_options);
require(['core/notification', 'core/str'], function(Notification, Str) {
Notification.saveCancelPromise(
Str.get_string('confirmation', 'admin'),
Str.get_string('confirmdeletelevel', 'gradingform_rubric'),
Str.get_string('yes', 'moodle')
).then(function() {
M.gradingform_rubriceditor.buttonclick.apply(this, [e, true]);
return;
}.bind(this)).catch(function() {
// User cancelled.
});
}.bind(this));
}
} else {
// unknown action