diff --git a/actions/notification/amd/build/chaptersource.min.js b/actions/notification/amd/build/chaptersource.min.js index bf8999f..685335a 100644 --- a/actions/notification/amd/build/chaptersource.min.js +++ b/actions/notification/amd/build/chaptersource.min.js @@ -9,4 +9,4 @@ */ define("pulseaction_notification/chaptersource",["jquery","core/ajax","core/notification","core/modal_factory","core/fragment","core/str","core/modal_events"],(function($,Ajax,Notification,ModalFactory,Fragment,Str,ModalEvents){const previewModalBody=function(contextID){let userid=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;var params;params=void 0!==window.tinyMCE&&window.tinyMCE.get("id_pulsenotification_headercontent_editor")?{contentheader:window.tinyMCE.get("id_pulsenotification_headercontent_editor").getContent(),contentstatic:window.tinyMCE.get("id_pulsenotification_staticcontent_editor").getContent(),contentfooter:window.tinyMCE.get("id_pulsenotification_footercontent_editor").getContent(),userid:userid}:{contentheader:document.querySelector("#id_pulsenotification_headercontent_editoreditable").innerHTML,contentstatic:document.querySelector("#id_pulsenotification_staticcontent_editoreditable").innerHTML,contentfooter:document.querySelector("#id_pulsenotification_footercontent_editoreditable").innerHTML,userid:userid};var formData,dynamicparams={};null!==document.querySelector("[name=pulsenotification_dynamiccontent]")&&(dynamicparams={contentdynamic:document.querySelector("[name=pulsenotification_dynamiccontent]").value,contenttype:document.querySelector("[name=pulsenotification_contenttype]").value,chapterid:document.querySelector("[name=pulsenotification_chapterid]").value,contentlength:document.querySelector("[name=pulsenotification_contentlength]").value});var form=document.forms["pulse-automation-template"],formdata=new FormData(form);formData={formdata:formdata=new URLSearchParams(formdata).toString()};var finalParams={...params,...dynamicparams,...formData};return Fragment.loadFragment("pulseaction_notification","preview_content",contextID,finalParams)};return{processResults:function(selector,modules){return modules},transport:function(selector,query,success,failure){var mod=document.querySelector("#id_pulsenotification_dynamiccontent");Ajax.call([{methodname:"pulseaction_notification_get_chapters",args:{mod:mod.value}}])[0].then((function(result){success(result)})).fail(failure)},updateChapter:function(ctxID,contentMods){const SELECTORS_chaperType="#id_pulsenotification_contenttype",SELECTORS_mod="#id_pulsenotification_dynamiccontent";if(null!==contentMods){var type=document.querySelector(SELECTORS_chaperType);document.querySelector(SELECTORS_mod).addEventListener("change",(e=>{var selected=e.currentTarget.value;contentMods.includes(selected.toString())?Array.prototype.find.call(type.options,(function(cmid){"2"==cmid.value&&(cmid.disabled=!1)})):Array.prototype.find.call(type.options,(function(cmid){"2"==cmid.value&&(cmid.disabled=!0)}))}))}document.querySelector(SELECTORS_chaperType).addEventListener("change",(()=>resetChapter())),document.querySelector(SELECTORS_mod).addEventListener("change",(()=>resetChapter()));var chapter=document.querySelector("#id_pulsenotification_chapterid");function resetChapter(){chapter.innerHTML="",chapter.value="";var event=new Event("change");chapter.dispatchEvent(event)}},previewNotification:function(contextid){var btn=document.querySelector('[name="pulsenotification_preview"]');null!==btn&&btn.addEventListener("click",(function(){var contextID;contextID=contextid,ModalFactory.create({title:Str.get_string("preview","pulseaction_notification"),body:previewModalBody(contextID),large:!0}).then((modal=>{modal.show(),modal.getRoot().on(ModalEvents.bodyRendered,(function(){modal.getRoot().get(0).querySelector("[name=userselector]").addEventListener("change",(e=>{e.preventDefault();var target=e.target;modal.setBody(previewModalBody(contextID,target.value))}))}))})).catch()}))},reportModal:function(contextID){document.addEventListener("click",(function(e){if(null!==e.target.closest('[data-target="view-content"]')){var target=e.target.closest("a"),instance=target.dataset.instanceid,userid=target.dataset.userid;!function(contextID,instance,userid){var params={instanceid:instance,userid:userid};ModalFactory.create({title:Str.get_string("preview","pulseaction_notification"),body:Fragment.loadFragment("pulseaction_notification","preview_instance_content",contextID,params),large:!0}).then((modal=>{modal.show()})).catch()}(contextID,instance,userid)}}))}}})); -//# sourceMappingURL=chaptersource.min.js.map +//# sourceMappingURL=chaptersource.min.js.map \ No newline at end of file diff --git a/actions/notification/amd/build/chaptersource.min.js.map b/actions/notification/amd/build/chaptersource.min.js.map index 79fb648..d466030 100644 --- a/actions/notification/amd/build/chaptersource.min.js.map +++ b/actions/notification/amd/build/chaptersource.min.js.map @@ -1 +1 @@ -{"version":3,"file":"chaptersource.min.js","sources":["../src/chaptersource.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\r\n//\r\n// Moodle is free software: you can redistribute it and/or modify\r\n// it under the terms of the GNU General Public License as published by\r\n// the Free Software Foundation, either version 3 of the License, or\r\n// (at your option) any later version.\r\n//\r\n// Moodle is distributed in the hope that it will be useful,\r\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n// GNU General Public License for more details.\r\n//\r\n// You should have received a copy of the GNU General Public License\r\n// along with Moodle. If not, see .\r\n\r\n/**\r\n * Frameworks datasource.\r\n *\r\n * This module is compatible with core/form-autocomplete.\r\n *\r\n * @module tool_lp/frameworks_datasource\r\n * @copyright 2016 Frédéric Massart - FMCorz.net\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\ndefine(['jquery', 'core/ajax', 'core/notification', 'core/modal_factory', 'core/fragment', 'core/str', 'core/modal_events'],\r\n function($, Ajax, Notification, ModalFactory, Fragment, Str, ModalEvents) {\r\n\r\n const previewModalBody = function(contextID, userid = null) {\r\n\r\n var params;\r\n if (window.tinyMCE !== undefined && window.tinyMCE.get('id_pulsenotification_headercontent_editor')) {\r\n // EditorPlugin = window.tinyMCE;\r\n params = {\r\n contentheader: window.tinyMCE.get('id_pulsenotification_headercontent_editor').getContent(),\r\n contentstatic: window.tinyMCE.get('id_pulsenotification_staticcontent_editor').getContent(),\r\n contentfooter: window.tinyMCE.get('id_pulsenotification_footercontent_editor').getContent(),\r\n userid: userid\r\n };\r\n } else {\r\n // EditorPlugin = document;\r\n params = {\r\n contentheader: document.querySelector('#id_pulsenotification_headercontent_editoreditable').innerHTML,\r\n contentstatic: document.querySelector('#id_pulsenotification_staticcontent_editoreditable').innerHTML,\r\n contentfooter: document.querySelector('#id_pulsenotification_footercontent_editoreditable').innerHTML,\r\n userid: userid\r\n };\r\n }\r\n\r\n var dynamicparams = {};\r\n\r\n if (document.querySelector('[name=pulsenotification_dynamiccontent]') !== null) {\r\n dynamicparams = {\r\n contentdynamic: document.querySelector('[name=pulsenotification_dynamiccontent]').value,\r\n contenttype: document.querySelector('[name=pulsenotification_contenttype]').value,\r\n chapterid: document.querySelector('[name=pulsenotification_chapterid]').value,\r\n contentlength: document.querySelector('[name=pulsenotification_contentlength]').value,\r\n };\r\n }\r\n // Get the form data.\r\n var formData;\r\n var form = document.forms['pulse-automation-template'];\r\n var formdata = new FormData(form);\r\n formdata = new URLSearchParams(formdata).toString();\r\n formData = {\r\n formdata: formdata\r\n };\r\n\r\n var finalParams = {...params, ...dynamicparams, ...formData};\r\n\r\n return Fragment.loadFragment('pulseaction_notification', 'preview_content', contextID, finalParams);\r\n };\r\n\r\n const previewModal = function(contextID) {\r\n\r\n ModalFactory.create({\r\n title: Str.get_string('preview', 'pulseaction_notification'),\r\n body: previewModalBody(contextID),\r\n large: true,\r\n }).then((modal) => {\r\n modal.show();\r\n\r\n modal.getRoot().on(ModalEvents.bodyRendered, function() {\r\n modal.getRoot().get(0).querySelector('[name=userselector]').addEventListener('change', (e) => {\r\n e.preventDefault();\r\n var target = e.target;\r\n modal.setBody(previewModalBody(contextID, target.value));\r\n });\r\n });\r\n\r\n return;\r\n }).catch();\r\n };\r\n\r\n const notificationModal = function(contextID, instance, userid) {\r\n\r\n var params = {\r\n instanceid: instance,\r\n userid: userid\r\n };\r\n\r\n ModalFactory.create({\r\n title: Str.get_string('preview', 'pulseaction_notification'),\r\n body: Fragment.loadFragment('pulseaction_notification', 'preview_instance_content', contextID, params),\r\n large: true,\r\n }).then((modal) => {\r\n modal.show();\r\n return;\r\n }).catch();\r\n };\r\n\r\n return {\r\n\r\n processResults: function(selector, modules) {\r\n return modules;\r\n },\r\n\r\n transport: function(selector, query, success, failure) {\r\n\r\n var mod = document.querySelector(\"#id_pulsenotification_dynamiccontent\");\r\n\r\n var promise = Ajax.call([{\r\n methodname: 'pulseaction_notification_get_chapters',\r\n args: {mod: mod.value}\r\n }]);\r\n\r\n promise[0].then(function(result) {\r\n success(result);\r\n return;\r\n }).fail(failure);\r\n },\r\n\r\n updateChapter: function(ctxID, contentMods) {\r\n\r\n const SELECTORS = {\r\n chaperType: \"#id_pulsenotification_contenttype\",\r\n mod: \"#id_pulsenotification_dynamiccontent\"\r\n };\r\n\r\n // Disable the content type option for modules other than book and page.\r\n if (contentMods !== null) {\r\n var type = document.querySelector(SELECTORS.chaperType);\r\n document.querySelector(SELECTORS.mod).addEventListener(\"change\", (e) => {\r\n var target = e.currentTarget;\r\n var selected = target.value;\r\n if (contentMods.includes(selected.toString())) {\r\n Array.prototype.find.call(type.options, function(cmid) {\r\n if (cmid.value == '2') {\r\n cmid.disabled = false;\r\n }\r\n });\r\n } else {\r\n Array.prototype.find.call(type.options, function(cmid) {\r\n if (cmid.value == '2') {\r\n cmid.disabled = true;\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n document.querySelector(SELECTORS.chaperType).addEventListener(\"change\", () => resetChapter());\r\n document.querySelector(SELECTORS.mod).addEventListener(\"change\", () => resetChapter());\r\n var chapter = document.querySelector(\"#id_pulsenotification_chapterid\");\r\n\r\n /**\r\n *\r\n */\r\n function resetChapter() {\r\n chapter.innerHTML = '';\r\n chapter.value = '';\r\n var event = new Event('change');\r\n chapter.dispatchEvent(event);\r\n }\r\n },\r\n\r\n previewNotification: function(contextid) {\r\n\r\n var btn = document.querySelector('[name=\"pulsenotification_preview\"]');\r\n\r\n if (btn === null) {\r\n return;\r\n }\r\n\r\n btn.addEventListener('click', function() {\r\n previewModal(contextid);\r\n });\r\n },\r\n\r\n reportModal: function(contextID) {\r\n // View content.\r\n /* var btn = document.querySelectorAll('[data-target=\"view-content\"]');\r\n\r\n if (btn === null) {\r\n return;\r\n }\r\n\r\n btn.forEach((element) => {\r\n element.addEventListener('click', function(e) {\r\n\r\n var target = e.target.closest('a');\r\n\r\n var instance = target.dataset.instanceid;\r\n var userid = target.dataset.userid;\r\n\r\n notificationModal(contextID, instance, userid); // Notification modal.\r\n });\r\n });\r\n */\r\n\r\n document.addEventListener('click', function(e) {\r\n\r\n if (e.target.closest('[data-target=\"view-content\"]') !== null) {\r\n\r\n var target = e.target.closest('a');\r\n\r\n var instance = target.dataset.instanceid;\r\n var userid = target.dataset.userid;\r\n\r\n notificationModal(contextID, instance, userid); // Notification modal.\r\n }\r\n\r\n })\r\n }\r\n };\r\n\r\n});\r\n"],"names":["define","$","Ajax","Notification","ModalFactory","Fragment","Str","ModalEvents","previewModalBody","contextID","userid","params","undefined","window","tinyMCE","get","contentheader","getContent","contentstatic","contentfooter","document","querySelector","innerHTML","formData","dynamicparams","contentdynamic","value","contenttype","chapterid","contentlength","form","forms","formdata","FormData","URLSearchParams","toString","finalParams","loadFragment","processResults","selector","modules","transport","query","success","failure","mod","call","methodname","args","then","result","fail","updateChapter","ctxID","contentMods","SELECTORS","type","addEventListener","e","selected","currentTarget","includes","Array","prototype","find","options","cmid","disabled","resetChapter","chapter","event","Event","dispatchEvent","previewNotification","contextid","btn","create","title","get_string","body","large","modal","show","getRoot","on","bodyRendered","preventDefault","target","setBody","catch","reportModal","closest","instance","dataset","instanceid","notificationModal"],"mappings":";;;;;;;;;AAyBAA,gDAAO,CAAC,SAAU,YAAa,oBAAqB,qBAAsB,gBAAiB,WAAY,sBACnG,SAASC,EAAGC,KAAMC,aAAcC,aAAcC,SAAUC,IAAKC,mBAEvDC,iBAAmB,SAASC,eAAWC,8DAAS,SAE9CC,OAGAA,YAFmBC,IAAnBC,OAAOC,SAAyBD,OAAOC,QAAQC,IAAI,6CAE1C,CACLC,cAAeH,OAAOC,QAAQC,IAAI,6CAA6CE,aAC/EC,cAAeL,OAAOC,QAAQC,IAAI,6CAA6CE,aAC/EE,cAAeN,OAAOC,QAAQC,IAAI,6CAA6CE,aAC/EP,OAAQA,QAIH,CACLM,cAAeI,SAASC,cAAc,sDAAsDC,UAC5FJ,cAAeE,SAASC,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E,iBAAiB,UAAU,IAAMW,qBACnEC,QAAUjD,SAASC,cAAc,4CAK5B+C,eACLC,QAAQ/C,UAAY,GACpB+C,QAAQ3C,MAAQ,OACZ4C,MAAQ,IAAIC,MAAM,UACtBF,QAAQG,cAAcF,SAI9BG,oBAAqB,SAASC,eAEtBC,IAAMvD,SAASC,cAAc,sCAErB,OAARsD,KAIJA,IAAIlB,iBAAiB,SAAS,WA/GjB,IAAShD,UAAAA,UAgHLiE,UA9GrBtE,aAAawE,OAAO,CAChBC,MAAOvE,IAAIwE,WAAW,UAAW,4BACjCC,KAAMvE,iBAAiBC,WACvBuE,OAAO,IACR/B,MAAMgC,QACLA,MAAMC,OAEND,MAAME,UAAUC,GAAG7E,YAAY8E,cAAc,WACzCJ,MAAME,UAAUpE,IAAI,GAAGM,cAAc,uBAAuBoC,iBAAiB,UAAWC,IACpFA,EAAE4B,qBACEC,OAAS7B,EAAE6B,OACfN,MAAMO,QAAQhF,iBAAiBC,UAAW8E,OAAO7D,iBAK1D+D,YAkGHC,YAAa,SAASjF,WAqBlBW,SAASqC,iBAAiB,SAAS,SAASC,MAEiB,OAArDA,EAAE6B,OAAOI,QAAQ,gCAA0C,KAEvDJ,OAAS7B,EAAE6B,OAAOI,QAAQ,KAE1BC,SAAWL,OAAOM,QAAQC,WAC1BpF,OAAS6E,OAAOM,QAAQnF,QA3HlB,SAASD,UAAWmF,SAAUlF,YAEhDC,OAAS,CACTmF,WAAYF,SACZlF,OAAQA,QAGZN,aAAawE,OAAO,CAChBC,MAAOvE,IAAIwE,WAAW,UAAW,4BACjCC,KAAM1E,SAASgC,aAAa,2BAA4B,2BAA4B5B,UAAWE,QAC/FqE,OAAO,IACR/B,MAAMgC,QACLA,MAAMC,UAEPO,QA+GSM,CAAkBtF,UAAWmF,SAAUlF"} \ No newline at end of file +{"version":3,"file":"chaptersource.min.js","sources":["../src/chaptersource.js"],"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 .\n\n/**\n * Frameworks datasource.\n *\n * This module is compatible with core/form-autocomplete.\n *\n * @module tool_lp/frameworks_datasource\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/notification', 'core/modal_factory', 'core/fragment', 'core/str', 'core/modal_events'],\n function($, Ajax, Notification, ModalFactory, Fragment, Str, ModalEvents) {\n\n const previewModalBody = function(contextID, userid = null) {\n\n var params;\n if (window.tinyMCE !== undefined && window.tinyMCE.get('id_pulsenotification_headercontent_editor')) {\n // EditorPlugin = window.tinyMCE;\n params = {\n contentheader: window.tinyMCE.get('id_pulsenotification_headercontent_editor').getContent(),\n contentstatic: window.tinyMCE.get('id_pulsenotification_staticcontent_editor').getContent(),\n contentfooter: window.tinyMCE.get('id_pulsenotification_footercontent_editor').getContent(),\n userid: userid\n };\n } else {\n // EditorPlugin = document;\n params = {\n contentheader: document.querySelector('#id_pulsenotification_headercontent_editoreditable').innerHTML,\n contentstatic: document.querySelector('#id_pulsenotification_staticcontent_editoreditable').innerHTML,\n contentfooter: document.querySelector('#id_pulsenotification_footercontent_editoreditable').innerHTML,\n userid: userid\n };\n }\n\n var dynamicparams = {};\n\n if (document.querySelector('[name=pulsenotification_dynamiccontent]') !== null) {\n dynamicparams = {\n contentdynamic: document.querySelector('[name=pulsenotification_dynamiccontent]').value,\n contenttype: document.querySelector('[name=pulsenotification_contenttype]').value,\n chapterid: document.querySelector('[name=pulsenotification_chapterid]').value,\n contentlength: document.querySelector('[name=pulsenotification_contentlength]').value,\n };\n }\n // Get the form data.\n var formData;\n var form = document.forms['pulse-automation-template'];\n var formdata = new FormData(form);\n formdata = new URLSearchParams(formdata).toString();\n formData = {\n formdata: formdata\n };\n\n var finalParams = {...params, ...dynamicparams, ...formData};\n\n return Fragment.loadFragment('pulseaction_notification', 'preview_content', contextID, finalParams);\n };\n\n const previewModal = function(contextID) {\n\n ModalFactory.create({\n title: Str.get_string('preview', 'pulseaction_notification'),\n body: previewModalBody(contextID),\n large: true,\n }).then((modal) => {\n modal.show();\n\n modal.getRoot().on(ModalEvents.bodyRendered, function() {\n modal.getRoot().get(0).querySelector('[name=userselector]').addEventListener('change', (e) => {\n e.preventDefault();\n var target = e.target;\n modal.setBody(previewModalBody(contextID, target.value));\n });\n });\n\n return;\n }).catch();\n };\n\n const notificationModal = function(contextID, instance, userid) {\n\n var params = {\n instanceid: instance,\n userid: userid\n };\n\n ModalFactory.create({\n title: Str.get_string('preview', 'pulseaction_notification'),\n body: Fragment.loadFragment('pulseaction_notification', 'preview_instance_content', contextID, params),\n large: true,\n }).then((modal) => {\n modal.show();\n return;\n }).catch();\n };\n\n return {\n\n processResults: function(selector, modules) {\n return modules;\n },\n\n transport: function(selector, query, success, failure) {\n\n var mod = document.querySelector(\"#id_pulsenotification_dynamiccontent\");\n\n var promise = Ajax.call([{\n methodname: 'pulseaction_notification_get_chapters',\n args: {mod: mod.value}\n }]);\n\n promise[0].then(function(result) {\n success(result);\n return;\n }).fail(failure);\n },\n\n updateChapter: function(ctxID, contentMods) {\n\n const SELECTORS = {\n chaperType: \"#id_pulsenotification_contenttype\",\n mod: \"#id_pulsenotification_dynamiccontent\"\n };\n\n // Disable the content type option for modules other than book and page.\n if (contentMods !== null) {\n var type = document.querySelector(SELECTORS.chaperType);\n document.querySelector(SELECTORS.mod).addEventListener(\"change\", (e) => {\n var target = e.currentTarget;\n var selected = target.value;\n if (contentMods.includes(selected.toString())) {\n Array.prototype.find.call(type.options, function(cmid) {\n if (cmid.value == '2') {\n cmid.disabled = false;\n }\n });\n } else {\n Array.prototype.find.call(type.options, function(cmid) {\n if (cmid.value == '2') {\n cmid.disabled = true;\n }\n });\n }\n });\n }\n\n document.querySelector(SELECTORS.chaperType).addEventListener(\"change\", () => resetChapter());\n document.querySelector(SELECTORS.mod).addEventListener(\"change\", () => resetChapter());\n var chapter = document.querySelector(\"#id_pulsenotification_chapterid\");\n\n /**\n *\n */\n function resetChapter() {\n chapter.innerHTML = '';\n chapter.value = '';\n var event = new Event('change');\n chapter.dispatchEvent(event);\n }\n },\n\n previewNotification: function(contextid) {\n\n var btn = document.querySelector('[name=\"pulsenotification_preview\"]');\n\n if (btn === null) {\n return;\n }\n\n btn.addEventListener('click', function() {\n previewModal(contextid);\n });\n },\n\n reportModal: function(contextID) {\n // View content.\n /* var btn = document.querySelectorAll('[data-target=\"view-content\"]');\n\n if (btn === null) {\n return;\n }\n\n btn.forEach((element) => {\n element.addEventListener('click', function(e) {\n\n var target = e.target.closest('a');\n\n var instance = target.dataset.instanceid;\n var userid = target.dataset.userid;\n\n notificationModal(contextID, instance, userid); // Notification modal.\n });\n });\n */\n\n document.addEventListener('click', function(e) {\n\n if (e.target.closest('[data-target=\"view-content\"]') !== null) {\n\n var target = e.target.closest('a');\n\n var instance = target.dataset.instanceid;\n var userid = target.dataset.userid;\n\n notificationModal(contextID, instance, userid); // Notification modal.\n }\n\n })\n }\n };\n\n});\n"],"names":["define","$","Ajax","Notification","ModalFactory","Fragment","Str","ModalEvents","previewModalBody","contextID","userid","params","undefined","window","tinyMCE","get","contentheader","getContent","contentstatic","contentfooter","document","querySelector","innerHTML","formData","dynamicparams","contentdynamic","value","contenttype","chapterid","contentlength","form","forms","formdata","FormData","URLSearchParams","toString","finalParams","loadFragment","processResults","selector","modules","transport","query","success","failure","mod","call","methodname","args","then","result","fail","updateChapter","ctxID","contentMods","SELECTORS","type","addEventListener","e","selected","currentTarget","includes","Array","prototype","find","options","cmid","disabled","resetChapter","chapter","event","Event","dispatchEvent","previewNotification","contextid","btn","create","title","get_string","body","large","modal","show","getRoot","on","bodyRendered","preventDefault","target","setBody","catch","reportModal","closest","instance","dataset","instanceid","notificationModal"],"mappings":";;;;;;;;;AAyBAA,gDAAO,CAAC,SAAU,YAAa,oBAAqB,qBAAsB,gBAAiB,WAAY,sBACnG,SAASC,EAAGC,KAAMC,aAAcC,aAAcC,SAAUC,IAAKC,mBAEvDC,iBAAmB,SAASC,eAAWC,8DAAS,SAE9CC,OAGAA,YAFmBC,IAAnBC,OAAOC,SAAyBD,OAAOC,QAAQC,IAAI,6CAE1C,CACLC,cAAeH,OAAOC,QAAQC,IAAI,6CAA6CE,aAC/EC,cAAeL,OAAOC,QAAQC,IAAI,6CAA6CE,aAC/EE,cAAeN,OAAOC,QAAQC,IAAI,6CAA6CE,aAC/EP,OAAQA,QAIH,CACLM,cAAeI,SAASC,cAAc,sDAAsDC,UAC5FJ,cAAeE,SAASC,cAAc,sDAAsDC,UAC5FH,cAAeC,SAASC,cAAc,sDAAsDC,UAC5FZ,OAAQA,YAeZa,SAXAC,cAAgB,GAEsD,OAAtEJ,SAASC,cAAc,6CACvBG,cAAgB,CACZC,eAAgBL,SAASC,cAAc,2CAA2CK,MAClFC,YAAaP,SAASC,cAAc,wCAAwCK,MAC5EE,UAAWR,SAASC,cAAc,sCAAsCK,MACxEG,cAAeT,SAASC,cAAc,0CAA0CK,YAKpFI,KAAOV,SAASW,MAAM,6BACtBC,SAAW,IAAIC,SAASH,MAE5BP,SAAW,CACPS,SAFJA,SAAW,IAAIE,gBAAgBF,UAAUG,gBAKrCC,YAAc,IAAIzB,UAAWa,iBAAkBD,iBAE5ClB,SAASgC,aAAa,2BAA4B,kBAAmB5B,UAAW2B,oBAyCpF,CAEHE,eAAgB,SAASC,SAAUC,gBACxBA,SAGXC,UAAW,SAASF,SAAUG,MAAOC,QAASC,aAEtCC,IAAMzB,SAASC,cAAc,wCAEnBnB,KAAK4C,KAAK,CAAC,CACrBC,WAAY,wCACZC,KAAM,CAACH,IAAKA,IA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,SAAS,SAASC,MAEiB,OAArDA,EAAE6B,OAAOI,QAAQ,gCAA0C,KAEvDJ,OAAS7B,EAAE6B,OAAOI,QAAQ,KAE1BC,SAAWL,OAAOM,QAAQC,WAC1BpF,OAAS6E,OAAOM,QAAQnF,QA3HlB,SAASD,UAAWmF,SAAUlF,YAEhDC,OAAS,CACTmF,WAAYF,SACZlF,OAAQA,QAGZN,aAAawE,OAAO,CAChBC,MAAOvE,IAAIwE,WAAW,UAAW,4BACjCC,KAAM1E,SAASgC,aAAa,2BAA4B,2BAA4B5B,UAAWE,QAC/FqE,OAAO,IACR/B,MAAMgC,QACLA,MAAMC,UAEPO,QA+GSM,CAAkBtF,UAAWmF,SAAUlF"} \ No newline at end of file diff --git a/actions/notification/classes/notification.php b/actions/notification/classes/notification.php index 832e313..c94bdfa 100644 --- a/actions/notification/classes/notification.php +++ b/actions/notification/classes/notification.php @@ -716,6 +716,7 @@ protected function generate_the_scheduletime($userid, $lastrun=null, $expectedru * * @param array $roles Role ids to fetch * @param \context $context + * @param int $childuserid * @return array List of the users. */ protected function get_users_withroles(array $roles, $context, $childuserid=null) { diff --git a/actions/notification/classes/reportbuilder/datasource/notification.php b/actions/notification/classes/reportbuilder/datasource/notification.php index 9e6be95..bc47a00 100644 --- a/actions/notification/classes/reportbuilder/datasource/notification.php +++ b/actions/notification/classes/reportbuilder/datasource/notification.php @@ -121,9 +121,7 @@ public function get_default_columns(): array { * @return array */ public function get_default_filters(): array { - return [ - 'notification:instanceid' - ]; + return []; } /** @@ -133,9 +131,7 @@ public function get_default_filters(): array { */ public function get_default_conditions(): array { - return [ - 'notification:instanceid' - ]; + return []; } } diff --git a/amd/build/automation.min.js b/amd/build/automation.min.js index a5d483f..259af9c 100644 --- a/amd/build/automation.min.js +++ b/amd/build/automation.min.js @@ -1,3 +1,3 @@ define("mod_pulse/automation",["jquery","core/modal_factory","core/templates","core/str"],(function($,Modal,Template,Str){const moveOverRidePosition=function(){var group="checkboxgroupautomation";return null===document.querySelectorAll("input[type=checkbox]."+group)||(document.querySelectorAll("input[type=checkbox]."+group).forEach((overElement=>{var id=overElement.id;id=id.replace("id_override_","");var element=document.querySelector("div#fitem_id_"+id);if(null===element&&null===(element=document.querySelector("div#fgroup_id_"+id)))return!0;var parent=overElement.parentNode;parent.innerHTML+='';var nodeToMove=document.createElement("div");return nodeToMove.classList.add("custom-control","custom-switch"),nodeToMove.append(parent),element.querySelector(".felement").append(nodeToMove),!0})),null===document.querySelectorAll("input[type=checkbox].checkboxgroupautomation")||null===document.querySelectorAll('[data-fieldtype="autocomplete"]')||document.querySelectorAll('[data-fieldtype="autocomplete"]').forEach((element=>{if(null===element)return!0;var observer=new MutationObserver((function(mutations){mutations.forEach((mutation=>{var overrideElement=mutation.target.querySelector(".custom-switch");null!==overrideElement&&(overrideElement.parentNode.append(overrideElement),observer.disconnect())}))}));return observer.observe(element,{attributes:!0,childList:!0,subtree:!0}),!0}))),!0};return{init:function(){null!==document.forms["pulse-automation-template"]&&(document.forms["pulse-automation-template"].onsubmit=e=>{var invalidElement=e.target.querySelector(".is-invalid");if(null===invalidElement)return!0;var hrefSelector='[href="#'+invalidElement.parentNode.parentNode.parentNode.id+'"]';return document.querySelector(hrefSelector).click(),!0}),function(){var templateReference=document.querySelector("#pulse-template-reference"),instanceReference=document.querySelector("#fitem_id_insreference .felement");templateReference&&instanceReference&&(templateReference.classList.remove("hide"),instanceReference.prepend(templateReference));const trigger=document.querySelectorAll('[data-target="overridemodal"]');null!==trigger&&trigger.forEach((elem=>{elem.nextSibling.querySelector(".felement").append(elem),elem.addEventListener("click",(function(e){e.preventDefault();var data=e.target.dataset,instance=document.querySelector("[name=overinstance_"+data.element+"]");if(null!==instance){var overrides=JSON.parse(instance.value);overrides.map((value=>(value.url=M.cfg.wwwroot+"/mod/pulse/automation/instances/edit.php?instanceid="+value.id+"&sesskey="+M.cfg.sesskey,value))),Modal.create({title:Str.get_string("instanceoverrides","pulse"),body:Template.render("mod_pulse/overrides",{instances:overrides})}).then((modal=>(modal.show(),!0))).catch()}}))}))}(),moveOverRidePosition(),null!==document.forms["pulse-automation-template"]&&(document.forms["pulse-automation-template"].onsubmit=()=>document.querySelector('[name="title"]').removeAttribute("disabled"))},instanceMenuLink:function(){(navMenu=>{if(null!==navMenu){var menu=navMenu.querySelector("a.automation-templates");null!==menu&&((menu=menu.parentNode).dataset.forceintomoremenu=!1,menu.querySelector("a").classList.remove("dropdown-item"),menu.querySelector("a").classList.add("nav-link"),menu.parentNode.removeChild(menu),navMenu.insertBefore(menu,navMenu.children[1]),window.dispatchEvent(new Event("resize")))}})(document.querySelector(".secondary-navigation ul.more-nav"))}}})); -//# sourceMappingURL=automation.min.js.map +//# sourceMappingURL=automation.min.js.map \ No newline at end of file diff --git a/amd/build/module.min.js b/amd/build/module.min.js index ab6fed9..5308603 100644 --- a/amd/build/module.min.js +++ b/amd/build/module.min.js @@ -9,4 +9,4 @@ */ define("mod_pulse/module",["core_editor/events"],(function(){return{init:function(){for(var module=this,templatevars=document.getElementsByClassName("fitem_id_templatevars_editor"),l=0;l{elem.addEventListener("click",(function(e){var EditorInput=e.currentTarget.querySelector('[id*="_editoreditable"]');module.insertCaretActive(EditorInput)}))}));var targetNode=document.querySelector("textarea[id$=_editor]");null!==targetNode&&new MutationObserver((function(){"none"==targetNode.style.display&&setTimeout(initIframeListeners,100)})).observe(targetNode,{attributes:!0,childList:!0});const initIframeListeners=()=>{var iframes=document.querySelectorAll('[data-fieldtype="editor"] iframe');return!(null===iframes||!iframes.length)&&(iframes.forEach((iframe=>{iframe.contentDocument.addEventListener("click",(function(e){var currentFrame=e.target;iframes.forEach((frame=>{var frameElem=frame.contentDocument.querySelector(".insertatcaretactive");null!==frameElem&&frameElem.classList.remove("insertatcaretactive")}));var contentBody=currentFrame.querySelector("body");null!==contentBody&&contentBody.classList.add("insertatcaretactive")}))})),!0)};for(var clickforword=document.getElementsByClassName("clickforword"),i=0;i{const span=document.createElement("span");span.classList="badge badge-info pulse-completion-roles",node.after(span),span.appendChild(node)}))}},insertCaretActive:function(EditorInput){if(null!==EditorInput){for(var caret=document.getElementsByClassName("insertatcaretactive"),j=0;j3===node.nodeType&&node.textContent.trim().length>1))},isSelectionInsideDiv:div=>{const selection=window.getSelection();if(0===selection.rangeCount)return!1;const startNode=selection.getRangeAt(0).startContainer,endNode=selection.getRangeAt(0).endContainer;return div.contains(startNode)&&div.contains(endNode)},insertAtCaret:function(myValue){for(var sel,range,caretelements=document.getElementsByClassName("insertatcaretactive"),n=0;n