AutorÃa | Ultima modificación | Ver Log |
{"version":3,"file":"form.min.js","sources":["../src/form.js"],"sourcesContent":["import ModalFactory from 'core/modal_factory';\nimport ModalForm from 'core_form/modalform';\nimport * as Str from 'core/str';\n\nlet modalForm = null;\nlet responseModal = null;\nlet contextid = null;\nlet appendurl = false;\n\n/**\n * Display the form modal and load the form.\n *\n * @param {Event} e\n */\nasync function showForm(e) {\n e.preventDefault();\n M.util.js_pending('block_messageteacher_show');\n\n const link = e.currentTarget;\n modalForm = new ModalForm({\n formClass: 'block_messageteacher\\\\message_form',\n args: {\n contextid: contextid,\n appendurl: appendurl,\n referurl: link.dataset.referurl,\n courseid: link.dataset.courseid,\n recipientid: link.dataset.recipientid\n },\n modalConfig: {\n title: await Str.get_string('pluginname', 'block_messageteacher')\n },\n saveButtonText: await Str.ge
t_string('send', 'block_messageteacher'),\n returnFocus: link\n });\n modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, submitForm);\n await modalForm.show();\n M.util.js_complete('block_messageteacher_show');\n}\n\n/**\n * Send the message entered into the form using a core webservice.\n *\n * @param {Event} e\n */\nasync function submitForm(e) {\n M.util.js_pending('block_messageteacher_send');\n if (e.detail < 1) {\n responseModal.setBody(e.errormessage);\n } else {\n const sent = await Str.get_string('messagesent', 'block_messageteacher');\n responseModal.setBody(sent);\n }\n responseModal.show();\n M.util.js_complete('block_messageteacher_send');\n}\n\n/**\n * Create modals.\n *\n * Create a Save/Cancel modal to display the form, and a Cancel modal for confirmation/error messages.\n */\nexport const init = async function() {\n\n const title = await Str.get_string('pluginname', 'block_messageteacher');\n\n responseModal = await Mod
alFactory.create({\n type: ModalFactory.types.DEFAULT,\n title: title\n });\n\n var links = document.querySelectorAll('.messageteacher_link');\n for (var i = 0; i < links.length; i++) {\n if (contextid === null) {\n contextid = links[i].parentElement.parentElement.dataset.contextid;\n appendurl = links[i].parentElement.parentElement.dataset.appendurl;\n }\n links[i].addEventListener('click', showForm);\n }\n};\n"],"names":["modalForm","responseModal","contextid","appendurl","showForm","e","preventDefault","M","util","js_pending","link","currentTarget","ModalForm","referurl","dataset","courseid","recipientid","Str","get_string","title","formClass","args","modalConfig","saveButtonText","returnFocus","addEventListener","events","FORM_SUBMITTED","submitForm","show","js_complete","detail","setBody","errormessage","sent","init","ModalFactory","create","type","types","DEFAULT","links","document","querySelectorAll","i","length","parentElement"],"ma
ppings":"ooEAIIA,UAAY,KACZC,cAAgB,KAChBC,UAAY,KACZC,WAAY,WAODC,qIAAf,kBAAwBC,2HACpBA,EAAEC,iBACFC,EAAEC,KAAKC,WAAW,6BAEZC,KAAOL,EAAEM,2BACCC,gCAEN,CACFV,UAAWA,UACXC,UAAWA,UACXU,SAAUH,KAAKI,QAAQD,SACvBE,SAAUL,KAAKI,QAAQC,SACvBC,YAAaN,KAAKI,QAAQE,8BAGbC,IAAIC,WAAW,aAAc,gFAA1CC,sCAEkBF,IAAIC,WAAW,OAAQ,gFAChCR,mBAZbU,UAAW,qCACXC,kBAOAC,yBAGAC,4BACAC,2BAbJxB,0CAeUyB,iBAAiBzB,UAAU0B,OAAOC,eAAgBC,8BACtD5B,UAAU6B,eAChBtB,EAAEC,KAAKsB,YAAY,wHAQRF,8IAAf,kBAA0BvB,uHACtBE,EAAEC,KAAKC,WAAW,+BACdJ,EAAE0B,OAAS,2BACX9B,cAAc+B,QAAQ3B,EAAE4B,oEAELhB,IAAIC,WAAW,cAAe,+BAA3CgB,oBACNjC,cAAc+B,QAAQE,aAE1BjC,cAAc4B,OACdtB,EAAEC,KAAKsB,YAAY,wHAQVK,sDAAO,iKAEIlB,IAAIC,WAAW,aAAc,sCAA3CC,oCAEgBiB,uBAAaC,OAAO,CACtCC,KAAMF,uBAAaG,MAAMC,QACzBrB,MAAOA,mBAFXlB,4BAKIwC,MAAQC,SAASC,iBAAiB,wBAC7BC,EAAI,EAAGA,EAAIH,MAAMI,OAAQD,IACZ,OAAd1C,YACAA,UAAYuC,MAAMG,GAAGE,cAAcA,cAAchC,QAAQZ,UACzDC,UAAYsC,MAAMG,GAAGE,cAAcA,cAAchC,QAAQX,WAE7DsC,MAAMG,GAAGnB,iBAAiB,QAASrB"}