Your IP : 192.168.165.1


Current Path : C:/xampp/htdocs/moodle/report/insights/amd/build/
Upload File :
Current File : C:/xampp/htdocs/moodle/report/insights/amd/build/message_users.min.js

define ("report_insights/message_users",["jquery","core/str","core/log","core/modal_factory","core/modal_events","core/templates","core/notification","core/ajax"],function(a,b,c,d,e,f,g,h){var i={BULKACTIONSELECT:"#formactionid"},j=function(a,b){this.actionName=b;this.attachEventListeners(a)};j.prototype.actionName=null;j.prototype.modal=null;j.prototype.attachEventListeners=function(b){a(b+" button[data-bulk-sendmessage]").on("click",function(b){b.preventDefault();var d=a(b.currentTarget),e={},f=d.data("prediction-to-user-id");a(".insights-list input[data-togglegroup^=\"insight-bulk-action\"][data-toggle=\"slave\"]:checked").each(function(b,d){var g=a(d).closest("tr[data-prediction-id]").data("prediction-id");if("undefined"==typeof f[g]){c.error("Unknown user for prediction "+g);return}var h=f[g];e[g]=h});if(0===Object.keys(e).length){return this}this.showSendMessage(e);return this}.bind(this))};j.prototype.showSendMessage=function(c){var g=new Set(Object.values(c));if(0==g.length){return a.Deferred().resolve().promise()}var h=null;if(1==g.size){h=b.get_string("sendbulkmessagesingle","core_message")}else{h=b.get_string("sendbulkmessage","core_message",g.size)}return a.when(d.create({type:d.types.SAVE_CANCEL,body:f.render("core_user/send_bulk_message",{})}),h).then(function(b,d){this.modal=b;this.modal.setTitle(d);this.modal.setSaveButtonText(d);this.modal.getRoot().on(e.hidden,function(){a(i.BULKACTIONSELECT).focus();this.modal.getRoot().remove()}.bind(this));this.modal.getRoot().on(e.save,this.submitSendMessage.bind(this,c));this.modal.show();return this.modal}.bind(this))};j.prototype.submitSendMessage=function(a){var c=this.modal.getRoot().find("form textarea").val(),d=[],e=new Set(Object.values(a));e.forEach(function(a){d.push({touserid:a,text:c})});var f=this.actionName,i=null;return h.call([{methodname:"core_message_send_instant_messages",args:{messages:d}}])[0].then(function(a){if(1==a.length){return b.get_string("sendbulkmessagesentsingle","core_message")}else{return b.get_string("sendbulkmessagesent","core_message",a.length)}}).then(function(b){i=b;return h.call([{methodname:"report_insights_action_executed",args:{actionname:f,predictionids:Object.keys(a)}}])[0]}).then(function(){g.addNotification({message:i,type:"success"});return!0}).catch(g.exception)};return{init:function init(a,b){return new j(a,b)}}});
//# sourceMappingURL=message_users.min.js.map