weekly release 4.0dev
[moodle.git] / user / amd / build / local / participants / bulkactions.min.js
1 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/local/participants/bulkactions",["exports","core_user/repository","core/str","core/modal_events","core/modal_factory","core/notification","core/templates","core/toast"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.showSendMessage=a.showAddNote=void 0;b=k(b);c=k(c);d=i(d);e=i(e);f=i(f);g=i(g);function i(a){return a&&a.__esModule?a:{default:a}}function j(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;j=function(){return a};return a}function k(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=j();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}var l=function(a,b,f,h){if(!b.length){return Promise.resolve()}var i=[];for(var l in f){switch(l){case"draft":i.push({value:"personal",label:f[l]});break;case"public":i.push({value:"course",label:f[l],selected:1});break;case"site":i.push({value:l,label:f[l]});break;}}var j={stateNames:i,stateHelpIcon:h.innerHTML},k=null;if(1===b.length){k=c.get_string("addbulknotesingle","core_notes")}else{k=c.get_string("addbulknote","core_notes",b.length)}return e.default.create({type:e.default.types.SAVE_CANCEL,body:g.default.render("core_user/add_bulk_note",j),title:k,buttons:{save:k},removeOnClose:!0}).then(function(c){c.getRoot().on(d.default.save,function(){return m(a,b,c)});c.show();return c})};a.showAddNote=l;var m=function(a,d,e){var g=e.getRoot().find("form textarea").val(),i=e.getRoot().find("form select").val(),j=d.map(function(b){return{userid:b,text:g,courseid:a,publishstate:i}});return b.createNotesForUsers(j).then(function(a){if(1===a.length){return c.get_string("addbulknotedonesingle","core_notes")}else{return c.get_string("addbulknotedone","core_notes",a.length)}}).then(function(a){return(0,h.add)(a)}).catch(f.default.exception)},n=function(a){if(!a.length){return Promise.resolve()}var b;if(1===a.length){b=c.get_string("sendbulkmessagesingle","core_message")}else{b=c.get_string("sendbulkmessage","core_message",a.length)}return e.default.create({type:e.default.types.SAVE_CANCEL,body:g.default.render("core_user/send_bulk_message",{}),title:b,buttons:{save:b},removeOnClose:!0}).then(function(b){b.getRoot().on(d.default.save,function(c){var d=b.getRoot().find("form textarea").val();if(""===d.trim()){b.getRoot().find("[data-role=\"messagetextrequired\"]").removeAttr("hidden");c.preventDefault();return}o(b,a,d)});b.show();return b})};a.showSendMessage=n;var o=function(a,d,e){var g=d.map(function(a){return{touserid:a,text:e}});return b.sendMessagesToUsers(g).then(function(a){if(1==a.length){return c.get_string("sendbulkmessagesentsingle","core_message")}else{return c.get_string("sendbulkmessagesent","core_message",a.length)}}).then(function(a){return(0,h.add)(a)}).catch(f.default.exception)}});
2 //# sourceMappingURL=bulkactions.min.js.map