Current Path : C:/Users/Mahmood/Desktop/moodle8/user/amd/build/ |
Current File : C:/Users/Mahmood/Desktop/moodle8/user/amd/build/status_field.min.js |
define ("core_user/status_field",["core/templates","jquery","core/str","core/config","core/notification","core/modal_factory","core/modal_events","core/fragment","core/ajax"],function(a,b,c,d,f,g,h,i,j){var k={EDIT_ENROLMENT:"[data-action=\"editenrolment\"]",SHOW_DETAILS:"[data-action=\"showdetails\"]",UNENROL:"[data-action=\"unenrol\"]"},l=function(a){this.contextid=a.contextid;this.courseid=a.courseid;this.bindEditEnrol();this.bindUnenrol();this.bindStatusDetails()};l.prototype.courseid=0;l.prototype.bindEditEnrol=function(){var a=this;b(k.EDIT_ENROLMENT).click(function(d){d.preventDefault();var e=b(this),i=e.parent(),j=i.data("fullname"),k=e.attr("rel");b.when(c.get_string("edituserenrolment","enrol",j)).then(function(a){return g.create({large:!0,title:a,type:g.types.SAVE_CANCEL})}).done(function(b){b.getRoot().on(h.save,function(c){c.preventDefault();a.submitEditFormAjax(b)});b.getRoot().on(h.hidden,function(){b.destroy()});b.setBody(a.getBody(k));b.show()}).fail(f.exception)})};l.prototype.bindUnenrol=function(){var a=this;b(k.UNENROL).click(function(d){d.preventDefault();var e=b(this),i=e.parent(),j=[{key:"unenrol",component:"enrol"},{key:"unenrolconfirm",component:"enrol",param:{user:i.data("fullname"),course:i.data("coursename"),enrolinstancename:i.data("enrolinstancename")}}],k=g.create({type:g.types.SAVE_CANCEL});b.when(c.get_strings(j),k).done(function(c,f){var g=c[0],i=c[1];f.setTitle(g);f.setBody(i);f.setSaveButtonText(g);f.getRoot().on(h.save,function(){var c={ueid:b(e).attr("rel")};d.preventDefault();a.submitUnenrolFormAjax(f,c)});f.getRoot().on(h.hidden,function(){f.destroy()});f.show()}).fail(f.exception)})};l.prototype.bindStatusDetails=function(){b(k.SHOW_DETAILS).click(function(d){d.preventDefault();var e=b(this),i=e.parent(),j={fullname:i.data("fullname"),coursename:i.data("coursename"),enrolinstancename:i.data("enrolinstancename"),status:i.data("status"),statusclass:i.find("span").attr("class"),timestart:i.data("timestart"),timeend:i.data("timeend"),timeenrolled:i.data("timeenrolled")},l=e.next(k.EDIT_ENROLMENT);if(l.length){j.editenrollink=b("<div>").append(l.clone()).html()}var m=c.get_strings([{key:"enroldetails",component:"enrol"}]),n=g.create({large:!0,type:g.types.CANCEL});b.when(m,n).done(function(c,d){var e=a.render("core_user/status_details",j);d.setTitle(c[0]);d.setBody(e);if(l.length){d.getRoot().on("click",k.EDIT_ENROLMENT,function(a){a.preventDefault();d.hide();b(l).trigger("click")})}d.show();d.getRoot().on(h.hidden,function(){d.destroy()})}).fail(f.exception)})};l.prototype.submitEditFormAjax=function(a){var c=this,d=a.getRoot().find("form"),e=b(d).find("[name=\"ue\"]").val(),g={methodname:"core_enrol_submit_user_enrolment_form",args:{formdata:d.serialize()}};j.call([g])[0].done(function(b){if(b.result){a.hide();if("undefined"!=typeof window.M.core_formchangechecker){window.M.core_formchangechecker.reset_form_dirty_state()}window.location.reload()}else{var f=JSON.stringify(d.serialize());a.setBody(c.getBody(e,f))}}).fail(f.exception)};l.prototype.submitUnenrolFormAjax=function(a,b){j.call([{methodname:"core_enrol_unenrol_user_enrolment",args:b}])[0].done(function(b){if(b.result){a.hide();if("undefined"!=typeof window.M.core_formchangechecker){window.M.core_formchangechecker.reset_form_dirty_state()}window.location.reload()}else{f.alert(b.errors[0].key,b.errors[0].message)}}).fail(f.exception)};l.prototype.getBody=function(a,b){var c={ueid:a};if("undefined"!=typeof b){c.formdata=b}return i.loadFragment("enrol","user_enrolment_form",this.contextid,c).fail(f.exception)};return{init:function init(a){new l(a)}}}); //# sourceMappingURL=status_field.min.js.map