Current Path : C:/Users/Mahmood/Desktop/moodle/user/amd/build/ |
Current File : C:/Users/Mahmood/Desktop/moodle/user/amd/build/status_field.min.js |
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core_user/status_field",["exports","core_table/dynamic","./repository","core/str","core_table/local/dynamic/selectors","core/fragment","core/modal_events","core/modal_factory","core/notification","core/templates","core/toast"],function(a,b,c,d,f,g,h,i,j,k,l){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=o(b);c=o(c);d=o(d);f=m(f);g=m(g);h=m(h);i=m(i);j=m(j);k=m(k);function m(a){return a&&a.__esModule?a:{default:a}}function n(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;n=function(){return a};return a}function o(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=n();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function p(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);if(b)d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable});c.push.apply(c,d)}return c}function q(a){for(var b=1,c;b<arguments.length;b++){c=null!=arguments[b]?arguments[b]:{};if(b%2){p(Object(c),!0).forEach(function(b){r(a,b,c[b])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(a,Object.getOwnPropertyDescriptors(c))}else{p(Object(c)).forEach(function(b){Object.defineProperty(a,b,Object.getOwnPropertyDescriptor(c,b))})}}return a}function r(a,b,c){if(b in a){Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0})}else{a[b]=c}return a}function s(a,b){return x(a)||w(a,b)||u(a,b)||t()}function t(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(a,b){if(!a)return;if("string"==typeof a)return v(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return v(a,b)}function v(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c<b;c++){d[c]=a[c]}return d}function w(a,b){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(a)))return;var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function x(a){if(Array.isArray(a))return a}var y={editEnrolment:"[data-action=\"editenrolment\"]",showDetails:"[data-action=\"showdetails\"]",unenrol:"[data-action=\"unenrol\"]",statusElement:"[data-status]"},z=function(a){return a.closest(f.default.main.region)},A=function(a){return a.closest(y.statusElement)},B=function(a){return a.getAttribute("rel")},C=function(a,b){var c=function(b,c){return I(a,b,c)};document.addEventListener("click",function(a){var d=a.target.closest(f.default.main.fromRegionId(b));if(!d){return}var e=a.target.closest(y.editEnrolment);if(e){a.preventDefault();D(e,c)}var g=a.target.closest(y.unenrol);if(g){a.preventDefault();E(g)}var h=a.target.closest(y.showDetails);if(h){a.preventDefault();F(h)}})},D=function(a,b){var c=A(a),f=B(a);i.default.create({large:!0,title:d.get_string("edituserenrolment","enrol",c.dataset.fullname),type:i.default.types.SAVE_CANCEL,body:b(f)}).then(function(d){d.getRoot().on(h.default.save,function(g){g.preventDefault();G(a,b,d,f,c.dataset)});d.getRoot().on(h.default.hidden,function(){d.destroy()});d.show();return d}).catch(j.default.exception)},E=function(a){var b=A(a),c=B(a);i.default.create({type:i.default.types.SAVE_CANCEL}).then(function(f){f.getRoot().on(h.default.save,function(d){d.preventDefault();H(a,f,{ueid:c},b.dataset)});f.getRoot().on(h.default.hidden,function(){f.destroy()});f.show();var g=[{key:"unenrol",component:"enrol"},{key:"unenrolconfirm",component:"enrol",param:{user:b.dataset.fullname,course:b.dataset.coursename,enrolinstancename:b.dataset.enrolinstancename}}];return Promise.all([d.get_strings(g),f])}).then(function(a){var b=s(a,2),c=b[0],d=b[1];d.setTitle(c[0]);d.setSaveButtonText(c[0]);d.setBody(c[1]);return d}).catch(j.default.exception)},F=function(a){var b=A(a),c=q({editenrollink:"",statusclass:b.querySelector("span.badge").getAttribute("class")},b.dataset),f=b.querySelector(y.editEnrolment);if(f){c.editenrollink=f.outerHTML}i.default.create({large:!0,type:i.default.types.CANCEL,title:d.get_string("enroldetails","enrol"),body:k.default.render("core_user/status_details",c)}).then(function(a){if(f){a.getRoot().on("click",y.editEnrolment,function(b){b.preventDefault();a.hide();f.click()})}a.show();a.getRoot().on(h.default.hidden,function(){return a.destroy()});return a}).catch(j.default.exception)},G=function(a,e,f,g,h){var i=f.getRoot().find("form");c.submitUserEnrolmentForm(i.serialize()).then(function(a){if(!a.result){throw a.result}f.hide();f.destroy();return a}).then(function(){b.refreshTableContent(z(a)).catch(j.default.exception);return d.get_string("enrolmentupdatedforuser","core_enrol",h)}).then(function(a){(0,l.add)(a)}).catch(function(){f.setBody(e(g,JSON.stringify(i.serialize())));return f})},H=function(a,e,f,g){c.unenrolUser(f.ueid).then(function(a){if(!a.result){j.default.alert(a.errors[0].key,a.errors[0].message);return a}e.hide();e.destroy();return a}).then(function(){b.refreshTableContent(z(a)).catch(j.default.exception);return d.get_string("unenrolleduser","core_enrol",g)}).then(function(a){(0,l.add)(a)}).catch(j.default.exception)},I=function(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;return g.default.loadFragment("enrol","user_enrolment_form",a,{ueid:b,formdata:c})};a.init=function init(a){var b=a.contextid,c=a.uniqueid;C(b,c)}}); //# sourceMappingURL=status_field.min.js.map