Files
moodle/enrol/manual/amd/build/quickenrolment.min.js

3 lines
2.1 KiB
JavaScript

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)}}});
//# sourceMappingURL=quickenrolment.min.js.map