Current Path : /var/www/ljmtc/cbt/message/amd/build/ |
Current File : /var/www/ljmtc/cbt/message/amd/build/message_send_bulk.min.js.map |
{"version":3,"sources":["../src/message_send_bulk.js"],"names":["showModal","users","callback","length","Promise","resolve","titlePromise","ModalFactory","create","type","types","SAVE_CANCEL","body","Templates","render","title","then","modal","setSaveButtonText","getRoot","on","ModalEvents","hidden","remove","save","messageText","find","val","sendMessage","show","messages","forEach","user","push","touserid","text","Ajax","call","methodname","args","messageIds","msg","Notification","addNotification","message","catch","exception"],"mappings":"iRAuBA,OACA,OACA,OACA,OACA,O,mDAUO,GAAMA,CAAAA,CAAS,CAAG,SAACC,CAAD,CAA4B,IAApBC,CAAAA,CAAoB,wDAAT,IAAS,CACjD,GAAI,CAACD,CAAK,CAACE,MAAX,CAAmB,CAEf,MAAOC,CAAAA,OAAO,CAACC,OAAR,EACV,CACD,GAAIC,CAAAA,CAAY,CAAG,IAAnB,CACA,GAAoB,CAAhB,EAAAL,CAAK,CAACE,MAAV,CAAuB,CACnBG,CAAY,CAAG,iBAAW,uBAAX,CAAoC,cAApC,CAClB,CAFD,IAEO,CACHA,CAAY,CAAG,iBAAW,iBAAX,CAA8B,cAA9B,CAA8CL,CAAK,CAACE,MAApD,CAClB,CAED,MAAOI,WAAaC,MAAb,CAAoB,CACvBC,IAAI,CAAEF,UAAaG,KAAb,CAAmBC,WADF,CAEvBC,IAAI,CAAEC,UAAUC,MAAV,CAAiB,gCAAjB,CAAmD,EAAnD,CAFiB,CAGvBC,KAAK,CAAET,CAHgB,CAApB,EAKNU,IALM,CAKD,SAASC,CAAT,CAAgB,CAClBA,CAAK,CAACC,iBAAN,CAAwBZ,CAAxB,EAGAW,CAAK,CAACE,OAAN,GAAgBC,EAAhB,CAAmBC,UAAYC,MAA/B,CAAuC,UAAW,CAC9C,GAAIpB,CAAJ,CAAc,CACVA,CAAQ,EACX,CACDe,CAAK,CAACE,OAAN,GAAgBI,MAAhB,EACH,CALD,EAOAN,CAAK,CAACE,OAAN,GAAgBC,EAAhB,CAAmBC,UAAYG,IAA/B,CAAqC,UAAW,CAC5C,GAAIC,CAAAA,CAAW,CAAGR,CAAK,CAACE,OAAN,GAAgBO,IAAhB,CAAqB,eAArB,EAAsCC,GAAtC,EAAlB,CACAC,CAAW,CAACH,CAAD,CAAcxB,CAAd,CACd,CAHD,EAKAgB,CAAK,CAACY,IAAN,GAEA,MAAOZ,CAAAA,CACV,CAxBM,CAyBV,CArCM,C,cA+CA,GAAMW,CAAAA,CAAW,CAAG,SAACH,CAAD,CAAcxB,CAAd,CAAwB,CAC/C,GAAI6B,CAAAA,CAAQ,CAAG,EAAf,CAEA7B,CAAK,CAAC8B,OAAN,CAAc,SAAAC,CAAI,CAAI,CAClBF,CAAQ,CAACG,IAAT,CAAc,CACVC,QAAQ,CAAEF,CADA,CAEVG,IAAI,CAAEV,CAFI,CAAd,CAIH,CALD,EAOA,MAAOW,WAAKC,IAAL,CAAU,CAAC,CACdC,UAAU,CAAE,oCADE,CAEdC,IAAI,CAAE,CAACT,QAAQ,CAAEA,CAAX,CAFQ,CAAD,CAAV,EAGH,CAHG,EAINd,IAJM,CAID,SAASwB,CAAT,CAAqB,CACvB,GAAyB,CAArB,EAAAA,CAAU,CAACrC,MAAf,CAA4B,CACxB,MAAO,iBAAW,2BAAX,CAAwC,cAAxC,CACV,CAFD,IAEO,CACH,MAAO,iBAAW,qBAAX,CAAkC,cAAlC,CAAkDqC,CAAU,CAACrC,MAA7D,CACV,CACJ,CAVM,EAWNa,IAXM,CAWD,SAASyB,CAAT,CAAc,CAChBC,UAAaC,eAAb,CAA6B,CACzBC,OAAO,CAAEH,CADgB,CAEzBhC,IAAI,CAAE,SAFmB,CAA7B,EAIA,QACH,CAjBM,EAkBNoC,KAlBM,CAkBAH,UAAaI,SAlBb,CAmBV,CA7BM,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Send bulk message to the given user ids.\n *\n * @module core_message/message_send_bulk\n * @copyright 2019 Shamim Rezaie <shamim@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport {get_string} from 'core/str';\nimport ModalFactory from 'core/modal_factory';\nimport Templates from 'core/templates';\nimport ModalEvents from 'core/modal_events';\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\n/**\n * Show the send message popup.\n *\n * @method showModal\n * @param {int[]} users\n * @param {Function} callback A callback to apply after the form is closed.\n * @returns {Promise}\n */\nexport const showModal = (users, callback = null) => {\n if (!users.length) {\n // Nothing to do.\n return Promise.resolve();\n }\n let titlePromise = null;\n if (users.length == 1) {\n titlePromise = get_string('sendbulkmessagesingle', 'core_message');\n } else {\n titlePromise = get_string('sendbulkmessage', 'core_message', users.length);\n }\n\n return ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n body: Templates.render('core_message/send_bulk_message', {}),\n title: titlePromise,\n })\n .then(function(modal) {\n modal.setSaveButtonText(titlePromise);\n\n // When the dialog is closed, perform the callback (if provided).\n modal.getRoot().on(ModalEvents.hidden, function() {\n if (callback) {\n callback();\n }\n modal.getRoot().remove();\n });\n\n modal.getRoot().on(ModalEvents.save, function() {\n let messageText = modal.getRoot().find('form textarea').val();\n sendMessage(messageText, users);\n });\n\n modal.show();\n\n return modal;\n });\n};\n\n/**\n * Send a message to these users.\n *\n * @method sendMessage\n * @param {String} messageText\n * @param {Number[]} users\n * @returns {Promise}\n */\nexport const sendMessage = (messageText, users) => {\n let messages = [];\n\n users.forEach(user => {\n messages.push({\n touserid: user,\n text: messageText\n });\n });\n\n return Ajax.call([{\n methodname: 'core_message_send_instant_messages',\n args: {messages: messages}\n }])[0]\n .then(function(messageIds) {\n if (messageIds.length == 1) {\n return get_string('sendbulkmessagesentsingle', 'core_message');\n } else {\n return get_string('sendbulkmessagesent', 'core_message', messageIds.length);\n }\n })\n .then(function(msg) {\n Notification.addNotification({\n message: msg,\n type: \"success\"\n });\n return true;\n })\n .catch(Notification.exception);\n};\n"],"file":"message_send_bulk.min.js"}