From: Andrew Nicols Date: Fri, 18 Aug 2017 02:02:00 +0000 (+0800) Subject: MDL-59859 enrol_manual: Improve modal creation ordering X-Git-Tag: v3.4.0-beta~420^2 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=b05f2cd7945d1b42cf4bddce31163e698d7181f3 MDL-59859 enrol_manual: Improve modal creation ordering --- diff --git a/enrol/manual/amd/build/quickenrolment.min.js b/enrol/manual/amd/build/quickenrolment.min.js index 583e1361bd2..698752c13b2 100644 Binary files a/enrol/manual/amd/build/quickenrolment.min.js and b/enrol/manual/amd/build/quickenrolment.min.js differ diff --git a/enrol/manual/amd/src/quickenrolment.js b/enrol/manual/amd/src/quickenrolment.js index eedda356f4e..600a89406f8 100644 --- a/enrol/manual/amd/src/quickenrolment.js +++ b/enrol/manual/amd/src/quickenrolment.js @@ -59,33 +59,41 @@ define(['core/templates', QuickEnrolment.prototype.initModal = function() { var triggerButtons = $('.enrolusersbutton.enrol_manual_plugin [type="submit"]'); - var strparams = [ + var stringsPromise = Str.get_strings([ {key: 'enroluserscohorts', component: 'enrol_manual'}, - {key: 'enrolusers', component: 'enrol_manual'} - ]; - - $.when(Str.get_strings(strparams)).then(function(strlist) { - var modalSaveChanges = strlist[0], - modalTitle = strlist[1]; - - return ModalFactory.create({ - type: ModalFactory.types.SAVE_CANCEL, - title: modalTitle, - body: this.getBody() - }, triggerButtons).then(function(modal) { - this.modal = modal; - this.modal.setLarge(); - this.modal.setSaveButtonText(modalSaveChanges); - - // We want the reset the form every time it is opened. - this.modal.getRoot().on(ModalEvents.hidden, function() { - this.modal.setBody(this.getBody()); - }.bind(this)); - - this.modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this)); - this.modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this)); + {key: 'enrolusers', component: 'enrol_manual'}, + ]); + + var titlePromise = stringsPromise.then(function(strings) { + return strings[1]; + }); + + var buttonPromise = stringsPromise.then(function(strings) { + return strings[0]; + }); + + return ModalFactory.create({ + type: ModalFactory.types.SAVE_CANCEL, + large: true, + title: titlePromise, + body: this.getBody() + }, triggerButtons) + .then(function(modal) { + this.modal = modal; + + this.modal.setSaveButtonText(buttonPromise); + + // We want the reset the form every time it is opened. + this.modal.getRoot().on(ModalEvents.hidden, function() { + this.modal.setBody(this.getBody()); }.bind(this)); - }.bind(this)).fail(Notification.exception); + + this.modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this)); + this.modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this)); + + return modal; + }.bind(this)) + .fail(Notification.exception); }; /**