diff --git a/enrol/manual/amd/build/quickenrolment.min.js b/enrol/manual/amd/build/quickenrolment.min.js index 8ba0cdee44b5f..583e1361bd27a 100644 --- a/enrol/manual/amd/build/quickenrolment.min.js +++ b/enrol/manual/amd/build/quickenrolment.min.js @@ -1 +1 @@ -define(["core/templates","jquery","core/str","core/config","core/notification","core/modal_factory","core/modal_events","core/fragment"],function(a,b,c,d,e,f,g,h){var i=function(a){this.contextid=a.contextid,this.initModal()};return i.prototype.courseid=0,i.prototype.modal=null,i.prototype.initModal=function(){var a=b('.enrolusersbutton.enrol_manual_plugin [type="submit"]');c.get_string("enrolusers","enrol_manual").then(function(b){return f.create({title:b,body:this.getBody(),footer:this.getFooter()},a).then(function(a){this.modal=a,this.modal.setLarge(),this.modal.getRoot().on(g.hidden,function(){this.modal.setBody(this.getBody())}.bind(this)),this.modal.getFooter().on("click",'[data-action="submit"]',this.submitForm.bind(this)),this.modal.getRoot().on("submit","form",this.submitFormAjax.bind(this))}.bind(this))}.bind(this)).fail(e.exception)},i.prototype.submitForm=function(a){a.preventDefault(),this.modal.getRoot().find("form").submit()},i.prototype.submitFormAjax=function(a){a.preventDefault();var c=this.modal.getRoot().find("form").serialize();this.modal.hide();var f={type:"GET",processData:!1,contentType:"application/json"},g=d.wwwroot+"/enrol/manual/ajax.php?"+c;b.ajax(g,f).then(function(a){a.error?e.addNotification({message:a.error,type:"error"}):("undefined"!=typeof window.M.core_formchangechecker&&window.M.core_formchangechecker.reset_form_dirty_state(),window.location.reload())}).fail(e.exception)},i.prototype.getBody=function(){return h.loadFragment("enrol_manual","enrol_users_form",this.contextid,{}).fail(e.exception)},i.prototype.getFooter=function(){return a.render("enrol_manual/enrol_modal_footer",{})},{init:function(a){new i(a)}}}); \ No newline at end of file +define(["core/templates","jquery","core/str","core/config","core/notification","core/modal_factory","core/modal_events","core/fragment"],function(a,b,c,d,e,f,g,h){var i=function(a){this.contextid=a.contextid,this.initModal()};return i.prototype.courseid=0,i.prototype.modal=null,i.prototype.initModal=function(){var a=b('.enrolusersbutton.enrol_manual_plugin [type="submit"]'),d=[{key:"enroluserscohorts",component:"enrol_manual"},{key:"enrolusers",component:"enrol_manual"}];b.when(c.get_strings(d)).then(function(b){var c=b[0],d=b[1];return f.create({type:f.types.SAVE_CANCEL,title:d,body:this.getBody()},a).then(function(a){this.modal=a,this.modal.setLarge(),this.modal.setSaveButtonText(c),this.modal.getRoot().on(g.hidden,function(){this.modal.setBody(this.getBody())}.bind(this)),this.modal.getRoot().on(g.save,this.submitForm.bind(this)),this.modal.getRoot().on("submit","form",this.submitFormAjax.bind(this))}.bind(this))}.bind(this)).fail(e.exception)},i.prototype.submitForm=function(a){a.preventDefault(),this.modal.getRoot().find("form").submit()},i.prototype.submitFormAjax=function(a){a.preventDefault();var c=this.modal.getRoot().find("form").serialize();this.modal.hide();var f={type:"GET",processData:!1,contentType:"application/json"},g=d.wwwroot+"/enrol/manual/ajax.php?"+c;b.ajax(g,f).then(function(a){a.error?e.addNotification({message:a.error,type:"error"}):("undefined"!=typeof window.M.core_formchangechecker&&window.M.core_formchangechecker.reset_form_dirty_state(),window.location.reload())}).fail(e.exception)},i.prototype.getBody=function(){return h.loadFragment("enrol_manual","enrol_users_form",this.contextid,{}).fail(e.exception)},i.prototype.getFooter=function(){return a.render("enrol_manual/enrol_modal_footer",{})},{init:function(a){new i(a)}}}); \ No newline at end of file diff --git a/enrol/manual/amd/src/quickenrolment.js b/enrol/manual/amd/src/quickenrolment.js index 6650786c8371c..eedda356f4e21 100644 --- a/enrol/manual/amd/src/quickenrolment.js +++ b/enrol/manual/amd/src/quickenrolment.js @@ -59,21 +59,30 @@ define(['core/templates', QuickEnrolment.prototype.initModal = function() { var triggerButtons = $('.enrolusersbutton.enrol_manual_plugin [type="submit"]'); - Str.get_string('enrolusers', 'enrol_manual').then(function(modalTitle) { + var strparams = [ + {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(), - footer: this.getFooter() + 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.getFooter().on('click', '[data-action="submit"]', this.submitForm.bind(this)); + this.modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this)); this.modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this)); }.bind(this)); }.bind(this)).fail(Notification.exception); diff --git a/enrol/manual/templates/enrol_modal_footer.mustache b/enrol/manual/templates/enrol_modal_footer.mustache deleted file mode 100644 index 9fc86c2e7f98c..0000000000000 --- a/enrol/manual/templates/enrol_modal_footer.mustache +++ /dev/null @@ -1,2 +0,0 @@ - -