Merge branch 'MDL-67827-master' of git://github.com/andrewnicols/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2020-03-09 20:36:09 +01:00
commit 9dc5d5ce0b
10 changed files with 28 additions and 14 deletions

View File

@ -1,2 +1,2 @@
define ("enrol_manual/quickenrolment",["core/templates","jquery","core/str","core/config","core/notification","core/modal_factory","core/modal_events","core/fragment"],function(a,b,c,d,f,g,h,i){var j={COHORTSELECT:"#id_cohortlist",TRIGGERBUTTONS:".enrolusersbutton.enrol_manual_plugin [type='submit']",UNWANTEDHIDDENFIELDS:":input[value='_qf__force_multiselect_submission']"},k=function(a){this.contextid=a.contextid;this.initModal()};k.prototype.courseid=0;k.prototype.modal=null;k.prototype.initModal=function(){var a=b(j.TRIGGERBUTTONS);b.when(c.get_strings([{key:"enroluserscohorts",component:"enrol_manual"},{key:"enrolusers",component:"enrol_manual"}]),g.create({type:g.types.SAVE_CANCEL,large:!0},a)).then(function(a,c){this.modal=c;c.setTitle(a[1]);c.setSaveButtonText(a[1]);c.getRoot().on(h.save,this.submitForm.bind(this));c.getRoot().on("submit","form",this.submitFormAjax.bind(this));c.getRoot().on(h.hidden,function(){c.setBody("")});c.getRoot().on(h.shown,function(){var d=this.getBody();d.then(function(d){var e=b(d).find(j.COHORTSELECT).length?0:1;c.setSaveButtonText(a[e])}).fail(f.exception);c.setBody(d)}.bind(this))}.bind(this)).fail(f.exception)};k.prototype.submitForm=function(a){a.preventDefault();this.modal.getRoot().find("form").submit()};k.prototype.submitFormAjax=function(a){a.preventDefault();var c=this.modal.getRoot().find("form"),e=c.find(j.UNWANTEDHIDDENFIELDS);e.each(function(){b(this).remove()});var g=c.serialize();this.modal.hide();var h=d.wwwroot+"/enrol/manual/ajax.php?"+g;b.ajax(h,{type:"GET",processData:!1,contentType:"application/json"}).then(function(a){if(a.error){f.addNotification({message:a.error,type:"error"})}else{if("undefined"!=typeof window.M.core_formchangechecker){window.M.core_formchangechecker.reset_form_dirty_state()}window.location.reload()}}).fail(f.exception)};k.prototype.getBody=function(){return i.loadFragment("enrol_manual","enrol_users_form",this.contextid,{}).fail(f.exception)};k.prototype.getFooter=function(){return a.render("enrol_manual/enrol_modal_footer",{})};return{init:function init(a){new k(a)}}});
define ("enrol_manual/quickenrolment",["core/templates","jquery","core/str","core/config","core/notification","core/modal_factory","core/modal_events","core/fragment","core/pending"],function(a,b,c,d,f,g,h,i,j){var k={COHORTSELECT:"#id_cohortlist",TRIGGERBUTTONS:".enrolusersbutton.enrol_manual_plugin [type='submit']",UNWANTEDHIDDENFIELDS:":input[value='_qf__force_multiselect_submission']"},l=function(a){this.contextid=a.contextid;this.initModal()};l.prototype.courseid=0;l.prototype.modal=null;l.prototype.initModal=function(){var a=b(k.TRIGGERBUTTONS);b.when(c.get_strings([{key:"enroluserscohorts",component:"enrol_manual"},{key:"enrolusers",component:"enrol_manual"}]),g.create({type:g.types.SAVE_CANCEL,large:!0},a)).then(function(a,c){this.modal=c;c.setTitle(a[1]);c.setSaveButtonText(a[1]);c.getRoot().on(h.save,this.submitForm.bind(this));c.getRoot().on("submit","form",this.submitFormAjax.bind(this));c.getRoot().on(h.hidden,function(){c.setBody("")});c.getRoot().on(h.shown,function(){var d=new j("enrol_manual/quickenrolment:initModal:shown"),e=this.getBody();e.then(function(d){var e=b(d).find(k.COHORTSELECT).length?0:1;c.setSaveButtonText(a[e])}).then(d.resolve).catch(f.exception);c.setBody(e)}.bind(this))}.bind(this)).fail(f.exception)};l.prototype.submitForm=function(a){a.preventDefault();this.modal.getRoot().find("form").submit()};l.prototype.submitFormAjax=function(a){a.preventDefault();var c=this.modal.getRoot().find("form"),e=c.find(k.UNWANTEDHIDDENFIELDS);e.each(function(){b(this).remove()});var g=c.serialize();this.modal.hide();var h=d.wwwroot+"/enrol/manual/ajax.php?"+g;b.ajax(h,{type:"GET",processData:!1,contentType:"application/json"}).then(function(a){if(a.error){f.addNotification({message:a.error,type:"error"})}else{if("undefined"!=typeof window.M.core_formchangechecker){window.M.core_formchangechecker.reset_form_dirty_state()}window.location.reload()}}).fail(f.exception)};l.prototype.getBody=function(){return i.loadFragment("enrol_manual","enrol_users_form",this.contextid,{}).fail(f.exception)};l.prototype.getFooter=function(){return a.render("enrol_manual/enrol_modal_footer",{})};return{init:function init(a){new l(a)}}});
//# sourceMappingURL=quickenrolment.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -28,8 +28,9 @@ define(['core/templates',
'core/modal_factory',
'core/modal_events',
'core/fragment',
'core/pending',
],
function(Template, $, Str, Config, Notification, ModalFactory, ModalEvents, Fragment) {
function(Template, $, Str, Config, Notification, ModalFactory, ModalEvents, Fragment, Pending) {
/** @type {Object} The list of selectors for the quick enrolment modal. */
var SELECTORS = {
@ -91,6 +92,7 @@ define(['core/templates',
});
modal.getRoot().on(ModalEvents.shown, function() {
var pendingPromise = new Pending('enrol_manual/quickenrolment:initModal:shown');
var bodyPromise = this.getBody();
bodyPromise.then(function(html) {
var stringIndex = $(html).find(SELECTORS.COHORTSELECT).length ? 0 : 1;
@ -98,7 +100,8 @@ define(['core/templates',
return;
})
.fail(Notification.exception);
.then(pendingPromise.resolve)
.catch(Notification.exception);
modal.setBody(bodyPromise);
}.bind(this));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
define ("core/modal_factory",["jquery","core/modal_events","core/modal_registry","core/modal","core/modal_save_cancel","core/modal_cancel","core/templates","core/notification","core/custom_interaction_events"],function(a,b,c,d,e,f,g,h,i){var j={DEFAULT:"core/modal",SAVE_CANCEL:"core/modal_save_cancel",CANCEL:"core/modal_cancel"},k={DEFAULT:"DEFAULT",SAVE_CANCEL:"SAVE_CANCEL",CANCEL:"CANCEL"};c.register(k.DEFAULT,d,j.DEFAULT);c.register(k.SAVE_CANCEL,e,j.SAVE_CANCEL);c.register(k.CANCEL,f,j.CANCEL);var l=function(c,d,e){var f=null,g="function"==typeof e.preShowCallback,h=function(b,d){f=a(b.currentTarget);c.then(function(a){if(g){e.preShowCallback(f,a)}a.show();return a});d.originalEvent.preventDefault()};if(Array.isArray(d)){var j=d[1];d=d[0];i.define(d,[i.events.activate]);d.on(i.events.activate,j,h)}else{i.define(d,[i.events.activate]);d.on(i.events.activate,h)}c.then(function(a){a.getRoot().on(b.hidden,function(){if(null!==f){f.focus()}});return a})},m=function(b,c){c=a(c);var d=b.module,e=new d(c);return e},n=function(b,c){var d=b.template,e=g.render(d,c).then(function(c){var d=a(c);return m(b,d)}).fail(h.exception);return e};return{create:function create(a,b){var d=a.type||k.DEFAULT,e=a.large?!0:!1,f=null,g={};f=c.get(d);if(!f){h.exception({message:"Unable to find modal of type: "+d})}if("undefined"!=typeof a.templateContext){g=a.templateContext}var i=n(f,g).then(function(b){if("undefined"!=typeof a.title){b.setTitle(a.title)}if("undefined"!=typeof a.body){b.setBody(a.body)}if("undefined"!=typeof a.footer){b.setFooter(a.footer)}if(e){b.setLarge()}return b});if("undefined"!=typeof b){l(i,b,a)}return i},types:k}});
define ("core/modal_factory",["jquery","core/modal_events","core/modal_registry","core/modal","core/modal_save_cancel","core/modal_cancel","core/templates","core/notification","core/custom_interaction_events","core/pending"],function(a,b,c,d,e,f,g,h,i,j){var k={DEFAULT:"core/modal",SAVE_CANCEL:"core/modal_save_cancel",CANCEL:"core/modal_cancel"},l={DEFAULT:"DEFAULT",SAVE_CANCEL:"SAVE_CANCEL",CANCEL:"CANCEL"};c.register(l.DEFAULT,d,k.DEFAULT);c.register(l.SAVE_CANCEL,e,k.SAVE_CANCEL);c.register(l.CANCEL,f,k.CANCEL);var m=function(c,d,e){var f=null,g="function"==typeof e.preShowCallback,h=function(b,d){var h=new j("core/modal_factory:setUpTrigger:triggeredCallback");f=a(b.currentTarget);c.then(function(a){if(g){e.preShowCallback(f,a)}a.show();return a}).then(h.resolve);d.originalEvent.preventDefault()};if(Array.isArray(d)){var k=d[1];d=d[0];i.define(d,[i.events.activate]);d.on(i.events.activate,k,h)}else{i.define(d,[i.events.activate]);d.on(i.events.activate,h)}c.then(function(a){a.getRoot().on(b.hidden,function(){if(null!==f){f.focus()}});return a})},n=function(b,c){c=a(c);var d=b.module,e=new d(c);return e},o=function(b,c){var d=b.template,e=g.render(d,c).then(function(c){var d=a(c);return n(b,d)}).fail(h.exception);return e};return{create:function create(a,b){var d=a.type||l.DEFAULT,e=a.large?!0:!1,f=null,g={};f=c.get(d);if(!f){h.exception({message:"Unable to find modal of type: "+d})}if("undefined"!=typeof a.templateContext){g=a.templateContext}var i=o(f,g).then(function(b){if("undefined"!=typeof a.title){b.setTitle(a.title)}if("undefined"!=typeof a.body){b.setBody(a.body)}if("undefined"!=typeof a.footer){b.setFooter(a.footer)}if(e){b.setLarge()}return b});if("undefined"!=typeof b){m(i,b,a)}return i},types:l}});
//# sourceMappingURL=modal_factory.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -32,7 +32,8 @@ define([
'core/event',
'core/modal_events',
'core/local/aria/focuslock',
], function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents, FocusLock) {
'core/pending',
], function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents, FocusLock, Pending) {
var SELECTORS = {
CONTAINER: '[data-region="modal-container"]',
@ -615,6 +616,8 @@ define([
return;
}
var pendingPromise = new Pending('core/modal:show');
if (this.hasFooterContent()) {
this.showFooter();
} else {
@ -625,7 +628,8 @@ define([
this.attachToDOM();
}
this.getBackdrop().done(function(backdrop) {
this.getBackdrop()
.then(function(backdrop) {
var currentIndex = this.calculateZIndex();
var newIndex = currentIndex + 2;
var newBackdropIndex = newIndex - 1;
@ -638,7 +642,10 @@ define([
this.getModal().focus();
$('body').addClass('modal-open');
this.root.trigger(ModalEvents.shown, this);
}.bind(this));
return;
}.bind(this))
.then(pendingPromise.resolve);
};
/**

View File

@ -24,9 +24,10 @@
*/
define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
'core/modal_save_cancel', 'core/modal_cancel',
'core/templates', 'core/notification', 'core/custom_interaction_events'],
'core/templates', 'core/notification', 'core/custom_interaction_events',
'core/pending'],
function($, ModalEvents, ModalRegistry, Modal, ModalSaveCancel,
ModalCancel, Templates, Notification, CustomEvents) {
ModalCancel, Templates, Notification, CustomEvents, Pending) {
// The templates for each type of modal.
var TEMPLATES = {
@ -64,6 +65,7 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
var hasPreShowCallback = (typeof modalConfig.preShowCallback == 'function');
// Function to handle the trigger element being activated.
var triggeredCallback = function(e, data) {
var pendingPromise = new Pending('core/modal_factory:setUpTrigger:triggeredCallback');
actualTriggerElement = $(e.currentTarget);
modalPromise.then(function(modal) {
if (hasPreShowCallback) {
@ -75,7 +77,8 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
modal.show();
return modal;
});
})
.then(pendingPromise.resolve);
data.originalEvent.preventDefault();
};

View File

@ -34,6 +34,7 @@ require_once(__DIR__ . '/../../filelib.php');
require_once(__DIR__ . '/../../clilib.php');
use Behat\Mink\Session;
use Behat\Mink\Exception\ExpectationException;
/**
* Init/reset utilities for Behat database and dataroot