diff --git a/lib/amd/build/utility.min.js b/lib/amd/build/utility.min.js
index 19324025466..9728d02267a 100644
--- a/lib/amd/build/utility.min.js
+++ b/lib/amd/build/utility.min.js
@@ -1,3 +1,3 @@
-define("core/utility",["core/str","core/pending","core/toast","core/notification"],(function(Str,_pending,_toast,_notification){var obj;Str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Str),_pending=(obj=_pending)&&obj.__esModule?obj:{default:obj};var _systemImportTransformerGlobalIdentifier="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}let registered=!1;const getModalString=function(dataset,type,field){let defaultValue=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return dataset["".concat(type).concat(field,"Str")]?Str.get_string.apply(null,JSON.parse(dataset["".concat(type).concat(field,"Str")])):dataset["".concat(type).concat(field)]?Promise.resolve(dataset["".concat(type).concat(field)]):defaultValue?Str.get_string.apply(null,defaultValue):null},displayConfirmation=(source,type)=>{let confirmationPromise=null;return confirmationPromise="".concat(type,"Type")in source.dataset&&"delete"===source.dataset["".concat(type,"Type")]?(0,_notification.deleteCancelPromise)(getModalString(source.dataset,type,"Title",["confirm","core"]),getModalString(source.dataset,type,"Content"),getModalString(source.dataset,type,"YesButton",["yes","core"])):(0,_notification.saveCancelPromise)(getModalString(source.dataset,type,"Title",["confirm","core"]),getModalString(source.dataset,type,"Content"),getModalString(source.dataset,type,"YesButton",["yes","core"])),confirmationPromise.then((()=>{if("true"===source.dataset["".concat(type,"Toast")]){const stringForToast=getModalString(source.dataset,type,"ToastConfirmation");"string"==typeof stringForToast?(0,_toast.add)(stringForToast):stringForToast.then((str=>(0,_toast.add)(str))).catch((e=>(0,_notification.exception)(e)))}if(source.dataset["".concat(type,"Destination")])window.location.href=source.dataset["".concat(type,"Destination")];else{if(!source.closest("form"))throw new Error("No destination found for confirmation action");source.dataset.confirmation="none",source.dataset.modal="none",source.click()}})).catch((()=>{}))};registered||((()=>{document.addEventListener("click",(e=>{const confirmRequest=e.target.closest('[data-confirmation="modal"]');confirmRequest&&(e.preventDefault(),displayConfirmation(confirmRequest,"confirmation"));const modalConfirmation=e.target.closest('[data-modal="confirmation"]');modalConfirmation&&(e.preventDefault(),displayConfirmation(modalConfirmation,"modal"));const alertRequest=e.target.closest('[data-modal="alert"]');alertRequest&&(e.preventDefault(),(async(title,content)=>{const pendingPromise=new _pending.default("core/confirm:alert"),ModalFactory=await("function"==typeof _systemImportTransformerGlobalIdentifier.define&&_systemImportTransformerGlobalIdentifier.define.amd?new Promise((function(resolve,reject){_systemImportTransformerGlobalIdentifier.require(["core/modal_factory"],resolve,reject)})):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&_systemImportTransformerGlobalIdentifier.require&&"component"===_systemImportTransformerGlobalIdentifier.require.loader?Promise.resolve(require("core/modal_factory")):Promise.resolve(_systemImportTransformerGlobalIdentifier["core/modal_factory"]));ModalFactory.create({type:ModalFactory.types.ALERT,title:title,body:content,removeOnClose:!0}).then((function(modal){return modal.show(),pendingPromise.resolve(),modal}))})(getModalString(alertRequest.dataset,"modal","Title"),getModalString(alertRequest.dataset,"modal","Content")))}))})(),registered=!0)}));
+define("core/utility",["core/str","core/pending","core/toast","core/notification"],(function(Str,_pending,_toast,_notification){var obj;Str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Str),_pending=(obj=_pending)&&obj.__esModule?obj:{default:obj};var _systemImportTransformerGlobalIdentifier="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}let registered=!1;const getModalString=function(dataset,type,field){let defaultValue=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return dataset["".concat(type).concat(field,"Str")]?Str.get_string.apply(null,JSON.parse(dataset["".concat(type).concat(field,"Str")])):dataset["".concat(type).concat(field)]?Promise.resolve(dataset["".concat(type).concat(field)]):defaultValue?Str.get_string.apply(null,defaultValue):null},displayConfirmation=(source,type)=>{let confirmationPromise=null;return confirmationPromise="".concat(type,"Type")in source.dataset&&"delete"===source.dataset["".concat(type,"Type")]?(0,_notification.deleteCancelPromise)(getModalString(source.dataset,type,"Title",["confirm","core"]),getModalString(source.dataset,type,"Content"),getModalString(source.dataset,type,"YesButton",["yes","core"])):(0,_notification.saveCancelPromise)(getModalString(source.dataset,type,"Title",["confirm","core"]),getModalString(source.dataset,type,"Content"),getModalString(source.dataset,type,"YesButton",["yes","core"])),confirmationPromise.then((()=>{if("true"===source.dataset["".concat(type,"Toast")]){const stringForToast=getModalString(source.dataset,type,"ToastConfirmation");"string"==typeof stringForToast?(0,_toast.add)(stringForToast):stringForToast.then((str=>(0,_toast.add)(str))).catch((e=>(0,_notification.exception)(e)))}const link=source.closest("a");if(source.dataset["".concat(type,"Destination")])window.location.href=source.dataset["".concat(type,"Destination")];else{if(!source.closest("form")){if(link&&link.href&&"#"!==link.href)return void(window.location.href=link.href);throw new Error("No destination found for ".concat(type," modal"))}source.dataset.confirmation="none",source.dataset.modal="none",source.click()}})).catch((()=>{}))};registered||((()=>{document.addEventListener("click",(e=>{const confirmRequest=e.target.closest('[data-confirmation="modal"]');confirmRequest&&(e.preventDefault(),displayConfirmation(confirmRequest,"confirmation"));const modalConfirmation=e.target.closest('[data-modal="confirmation"]');modalConfirmation&&(e.preventDefault(),displayConfirmation(modalConfirmation,"modal"));const alertRequest=e.target.closest('[data-modal="alert"]');alertRequest&&(e.preventDefault(),(async(title,content)=>{const pendingPromise=new _pending.default("core/confirm:alert"),ModalFactory=await("function"==typeof _systemImportTransformerGlobalIdentifier.define&&_systemImportTransformerGlobalIdentifier.define.amd?new Promise((function(resolve,reject){_systemImportTransformerGlobalIdentifier.require(["core/modal_factory"],resolve,reject)})):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&_systemImportTransformerGlobalIdentifier.require&&"component"===_systemImportTransformerGlobalIdentifier.require.loader?Promise.resolve(require("core/modal_factory")):Promise.resolve(_systemImportTransformerGlobalIdentifier["core/modal_factory"]));ModalFactory.create({type:ModalFactory.types.ALERT,title:title,body:content,removeOnClose:!0}).then((function(modal){return modal.show(),pendingPromise.resolve(),modal}))})(getModalString(alertRequest.dataset,"modal","Title"),getModalString(alertRequest.dataset,"modal","Content")))}))})(),registered=!0)}));
//# sourceMappingURL=utility.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/utility.min.js.map b/lib/amd/build/utility.min.js.map
index 358a851db47..473f62f6e70 100644
--- a/lib/amd/build/utility.min.js.map
+++ b/lib/amd/build/utility.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"utility.min.js","sources":["../src/utility.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 * Javascript handling for HTML attributes. This module gets autoloaded on page load.\n *\n * With the appropriate HTML attributes, various functionalities defined in this module can be used such as a displaying\n * an alert or a confirmation modal, etc.\n *\n * @module core/utility\n * @copyright 2021 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 4.0\n *\n * @example Calling the confirmation modal to delete a block\n *\n * // The following is an example of how to use this module via an indirect PHP call with a button.\n *\n * $controls[] = new action_menu_link_secondary(\n * $deleteactionurl,\n * new pix_icon('t/delete', $str, 'moodle', array('class' => 'iconsmall', 'title' => '')),\n * $str,\n * [\n * 'class' => 'editing_delete',\n * 'data-modal' => 'confirmation', // Needed so this module will pick it up in the click handler.\n * 'data-modal-title-str' => json_encode(['deletecheck_modal', 'block']),\n * 'data-modal-content-str' => json_encode(['deleteblockcheck', 'block', $blocktitle]),\n * 'data-modal-yes-button-str' => json_encode(['delete', 'core']),\n * 'data-modal-toast' => 'true', // Can be set to inform the user that their action was a success.\n * 'data-modal-toast-confirmation-str' => json_encode(['deleteblockinprogress', 'block', $blocktitle]),\n * 'data-modal-destination' => $deleteconfirmationurl->out(false), // Where do you want to direct the user?\n * ]\n * );\n */\n\nimport * as Str from 'core/str';\nimport Pending from 'core/pending';\nimport {add as addToast} from 'core/toast';\nimport {saveCancelPromise, deleteCancelPromise, exception} from 'core/notification';\n\n// We want to ensure that we only initialize the listeners only once.\nlet registered = false;\n\n/**\n * Either fetch the string or return it from the dom node.\n *\n * @method getConfirmationString\n * @private\n * @param {HTMLElement} dataset The page element to fetch dataset items in\n * @param {String} type The type of string to fetch\n * @param {String} field The dataset field name to fetch the contents of\n * @param {Array|null} [defaultValue=null] The default params to pass to get_string if no value is found in a dataset\n * @return {Promise}\n *\n */\nconst getModalString = (dataset, type, field, defaultValue = null) => {\n if (dataset[`${type}${field}Str`]) {\n return Str.get_string.apply(null, JSON.parse(dataset[`${type}${field}Str`]));\n }\n if (dataset[`${type}${field}`]) {\n return Promise.resolve(dataset[`${type}${field}`]);\n }\n\n if (defaultValue) {\n return Str.get_string.apply(null, defaultValue);\n }\n\n return null;\n};\n\n/**\n * Display a save/cancel confirmation.\n *\n * @private\n * @param {HTMLElement} source The title of the confirmation\n * @param {String} type The content of the confirmation\n * @returns {Promise}\n */\nconst displayConfirmation = (source, type) => {\n let confirmationPromise = null;\n if (`${type}Type` in source.dataset && source.dataset[`${type}Type`] === 'delete') {\n confirmationPromise = deleteCancelPromise(\n getModalString(source.dataset, type, 'Title', ['confirm', 'core']),\n getModalString(source.dataset, type, 'Content'),\n getModalString(source.dataset, type, 'YesButton', ['yes', 'core'])\n );\n } else {\n confirmationPromise = saveCancelPromise(\n getModalString(source.dataset, type, 'Title', ['confirm', 'core']),\n getModalString(source.dataset, type, 'Content'),\n getModalString(source.dataset, type, 'YesButton', ['yes', 'core'])\n );\n }\n return confirmationPromise.then(() => {\n if (source.dataset[`${type}Toast`] === 'true') {\n const stringForToast = getModalString(source.dataset, type, 'ToastConfirmation');\n if (typeof stringForToast === \"string\") {\n addToast(stringForToast);\n } else {\n stringForToast.then(str => addToast(str)).catch(e => exception(e));\n }\n }\n\n if (source.dataset[`${type}Destination`]) {\n window.location.href = source.dataset[`${type}Destination`];\n } else if (source.closest('form')) {\n // Update the modal and confirmation data fields so that we don't loop.\n source.dataset.confirmation = 'none';\n source.dataset.modal = 'none';\n\n // Click on the button again.\n // Note: Do not use the form.submit() because it will not work for cancel buttons.\n source.click();\n } else {\n throw new Error(\"No destination found for confirmation action\");\n }\n return;\n }).catch(() => {\n return;\n });\n};\n\n/**\n * Display an alert and return the promise from it.\n *\n * @private\n * @param {String} title The title of the alert\n * @param {String} content The content of the alert\n * @returns {Promise}\n */\nconst displayAlert = async(title, content) => {\n const pendingPromise = new Pending('core/confirm:alert');\n\n const ModalFactory = await import('core/modal_factory');\n\n return ModalFactory.create({\n type: ModalFactory.types.ALERT,\n title: title,\n body: content,\n removeOnClose: true,\n })\n .then(function(modal) {\n modal.show();\n pendingPromise.resolve();\n\n return modal;\n });\n};\n\n/**\n * Set up the listeners for the confirmation modal widget within the page.\n *\n * @method registerConfirmationListeners\n * @private\n */\nconst registerConfirmationListeners = () => {\n document.addEventListener('click', e => {\n const confirmRequest = e.target.closest('[data-confirmation=\"modal\"]');\n if (confirmRequest) {\n e.preventDefault();\n displayConfirmation(confirmRequest, 'confirmation');\n }\n\n const modalConfirmation = e.target.closest('[data-modal=\"confirmation\"]');\n if (modalConfirmation) {\n e.preventDefault();\n displayConfirmation(modalConfirmation, 'modal');\n }\n\n const alertRequest = e.target.closest('[data-modal=\"alert\"]');\n if (alertRequest) {\n e.preventDefault();\n displayAlert(\n getModalString(alertRequest.dataset, 'modal', 'Title'),\n getModalString(alertRequest.dataset, 'modal', 'Content'),\n );\n }\n });\n};\n\nif (!registered) {\n registerConfirmationListeners();\n registered = true;\n}\n"],"names":["registered","getModalString","dataset","type","field","defaultValue","Str","get_string","apply","JSON","parse","Promise","resolve","displayConfirmation","source","confirmationPromise","then","stringForToast","str","catch","e","window","location","href","closest","Error","confirmation","modal","click","document","addEventListener","confirmRequest","target","preventDefault","modalConfirmation","alertRequest","async","title","content","pendingPromise","Pending","ModalFactory","create","types","ALERT","body","removeOnClose","show","displayAlert","registerConfirmationListeners"],"mappings":"iwCAqDIA,YAAa,QAcXC,eAAiB,SAACC,QAASC,KAAMC,WAAOC,oEAAe,YACrDH,kBAAWC,aAAOC,cACXE,IAAIC,WAAWC,MAAM,KAAMC,KAAKC,MAAMR,kBAAWC,aAAOC,gBAE/DF,kBAAWC,aAAOC,QACXO,QAAQC,QAAQV,kBAAWC,aAAOC,SAGzCC,aACOC,IAAIC,WAAWC,MAAM,KAAMH,cAG/B,MAWLQ,oBAAsB,CAACC,OAAQX,YAC7BY,oBAAsB,YAEtBA,oBADA,UAAGZ,eAAcW,OAAOZ,SAA6C,WAAlCY,OAAOZ,kBAAWC,eAC/B,qCAClBF,eAAea,OAAOZ,QAASC,KAAM,QAAS,CAAC,UAAW,SAC1DF,eAAea,OAAOZ,QAASC,KAAM,WACrCF,eAAea,OAAOZ,QAASC,KAAM,YAAa,CAAC,MAAO,WAGxC,mCAClBF,eAAea,OAAOZ,QAASC,KAAM,QAAS,CAAC,UAAW,SAC1DF,eAAea,OAAOZ,QAASC,KAAM,WACrCF,eAAea,OAAOZ,QAASC,KAAM,YAAa,CAAC,MAAO,UAG3DY,oBAAoBC,MAAK,QACW,SAAnCF,OAAOZ,kBAAWC,eAAyB,OACrCc,eAAiBhB,eAAea,OAAOZ,QAASC,KAAM,qBAC9B,iBAAnBc,8BACEA,gBAETA,eAAeD,MAAKE,MAAO,cAASA,OAAMC,OAAMC,IAAK,2BAAUA,QAInEN,OAAOZ,kBAAWC,qBAClBkB,OAAOC,SAASC,KAAOT,OAAOZ,kBAAWC,yBACtC,CAAA,IAAIW,OAAOU,QAAQ,cAShB,IAAIC,MAAM,gDAPhBX,OAAOZ,QAAQwB,aAAe,OAC9BZ,OAAOZ,QAAQyB,MAAQ,OAIvBb,OAAOc,YAKZT,OAAM,UA+DRnB,aAzBiC,MAClC6B,SAASC,iBAAiB,SAASV,UACzBW,eAAiBX,EAAEY,OAAOR,QAAQ,+BACpCO,iBACAX,EAAEa,iBACFpB,oBAAoBkB,eAAgB,uBAGlCG,kBAAoBd,EAAEY,OAAOR,QAAQ,+BACvCU,oBACAd,EAAEa,iBACFpB,oBAAoBqB,kBAAmB,gBAGrCC,aAAef,EAAEY,OAAOR,QAAQ,wBAClCW,eACAf,EAAEa,iBAzCOG,OAAMC,MAAOC,iBACxBC,eAAiB,IAAIC,iBAAQ,sBAE7BC,2nBAECA,aAAaC,OAAO,CACvBvC,KAAMsC,aAAaE,MAAMC,MACzBP,MAAOA,MACPQ,KAAMP,QACNQ,eAAe,IAElB9B,MAAK,SAASW,cACXA,MAAMoB,OACNR,eAAe3B,UAERe,UA2BHqB,CACI/C,eAAekC,aAAajC,QAAS,QAAS,SAC9CD,eAAekC,aAAajC,QAAS,QAAS,iBAO1D+C,GACAjD,YAAa"}
\ No newline at end of file
+{"version":3,"file":"utility.min.js","sources":["../src/utility.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 * Javascript handling for HTML attributes. This module gets autoloaded on page load.\n *\n * With the appropriate HTML attributes, various functionalities defined in this module can be used such as a displaying\n * an alert or a confirmation modal, etc.\n *\n * @module core/utility\n * @copyright 2021 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 4.0\n *\n * @example Calling the confirmation modal to delete a block\n *\n * // The following is an example of how to use this module via an indirect PHP call with a button.\n *\n * $controls[] = new action_menu_link_secondary(\n * $deleteactionurl,\n * new pix_icon('t/delete', $str, 'moodle', array('class' => 'iconsmall', 'title' => '')),\n * $str,\n * [\n * 'class' => 'editing_delete',\n * 'data-modal' => 'confirmation', // Needed so this module will pick it up in the click handler.\n * 'data-modal-title-str' => json_encode(['deletecheck_modal', 'block']),\n * 'data-modal-content-str' => json_encode(['deleteblockcheck', 'block', $blocktitle]),\n * 'data-modal-yes-button-str' => json_encode(['delete', 'core']),\n * 'data-modal-toast' => 'true', // Can be set to inform the user that their action was a success.\n * 'data-modal-toast-confirmation-str' => json_encode(['deleteblockinprogress', 'block', $blocktitle]),\n * 'data-modal-destination' => $deleteconfirmationurl->out(false), // Where do you want to direct the user?\n * ]\n * );\n */\n\nimport * as Str from 'core/str';\nimport Pending from 'core/pending';\nimport {add as addToast} from 'core/toast';\nimport {saveCancelPromise, deleteCancelPromise, exception} from 'core/notification';\n\n// We want to ensure that we only initialize the listeners only once.\nlet registered = false;\n\n/**\n * Either fetch the string or return it from the dom node.\n *\n * @method getConfirmationString\n * @private\n * @param {HTMLElement} dataset The page element to fetch dataset items in\n * @param {String} type The type of string to fetch\n * @param {String} field The dataset field name to fetch the contents of\n * @param {Array|null} [defaultValue=null] The default params to pass to get_string if no value is found in a dataset\n * @return {Promise}\n *\n */\nconst getModalString = (dataset, type, field, defaultValue = null) => {\n if (dataset[`${type}${field}Str`]) {\n return Str.get_string.apply(null, JSON.parse(dataset[`${type}${field}Str`]));\n }\n if (dataset[`${type}${field}`]) {\n return Promise.resolve(dataset[`${type}${field}`]);\n }\n\n if (defaultValue) {\n return Str.get_string.apply(null, defaultValue);\n }\n\n return null;\n};\n\n/**\n * Display a save/cancel confirmation.\n *\n * @private\n * @param {HTMLElement} source The title of the confirmation\n * @param {String} type The content of the confirmation\n * @returns {Promise}\n */\nconst displayConfirmation = (source, type) => {\n let confirmationPromise = null;\n if (`${type}Type` in source.dataset && source.dataset[`${type}Type`] === 'delete') {\n confirmationPromise = deleteCancelPromise(\n getModalString(source.dataset, type, 'Title', ['confirm', 'core']),\n getModalString(source.dataset, type, 'Content'),\n getModalString(source.dataset, type, 'YesButton', ['yes', 'core'])\n );\n } else {\n confirmationPromise = saveCancelPromise(\n getModalString(source.dataset, type, 'Title', ['confirm', 'core']),\n getModalString(source.dataset, type, 'Content'),\n getModalString(source.dataset, type, 'YesButton', ['yes', 'core'])\n );\n }\n return confirmationPromise.then(() => {\n if (source.dataset[`${type}Toast`] === 'true') {\n const stringForToast = getModalString(source.dataset, type, 'ToastConfirmation');\n if (typeof stringForToast === \"string\") {\n addToast(stringForToast);\n } else {\n stringForToast.then(str => addToast(str)).catch(e => exception(e));\n }\n }\n\n const link = source.closest('a');\n if (source.dataset[`${type}Destination`]) {\n window.location.href = source.dataset[`${type}Destination`];\n } else if (source.closest('form')) {\n // Update the modal and confirmation data fields so that we don't loop.\n source.dataset.confirmation = 'none';\n source.dataset.modal = 'none';\n\n // Click on the button again.\n // Note: Do not use the form.submit() because it will not work for cancel buttons.\n source.click();\n } else if (link && link.href && link.href !== '#') {\n window.location.href = link.href;\n return;\n } else {\n throw new Error(`No destination found for ${type} modal`);\n }\n\n return;\n }).catch(() => {\n return;\n });\n};\n\n/**\n * Display an alert and return the promise from it.\n *\n * @private\n * @param {String} title The title of the alert\n * @param {String} content The content of the alert\n * @returns {Promise}\n */\nconst displayAlert = async(title, content) => {\n const pendingPromise = new Pending('core/confirm:alert');\n\n const ModalFactory = await import('core/modal_factory');\n\n return ModalFactory.create({\n type: ModalFactory.types.ALERT,\n title: title,\n body: content,\n removeOnClose: true,\n })\n .then(function(modal) {\n modal.show();\n pendingPromise.resolve();\n\n return modal;\n });\n};\n\n/**\n * Set up the listeners for the confirmation modal widget within the page.\n *\n * @method registerConfirmationListeners\n * @private\n */\nconst registerConfirmationListeners = () => {\n document.addEventListener('click', e => {\n const confirmRequest = e.target.closest('[data-confirmation=\"modal\"]');\n if (confirmRequest) {\n e.preventDefault();\n displayConfirmation(confirmRequest, 'confirmation');\n }\n\n const modalConfirmation = e.target.closest('[data-modal=\"confirmation\"]');\n if (modalConfirmation) {\n e.preventDefault();\n displayConfirmation(modalConfirmation, 'modal');\n }\n\n const alertRequest = e.target.closest('[data-modal=\"alert\"]');\n if (alertRequest) {\n e.preventDefault();\n displayAlert(\n getModalString(alertRequest.dataset, 'modal', 'Title'),\n getModalString(alertRequest.dataset, 'modal', 'Content'),\n );\n }\n });\n};\n\nif (!registered) {\n registerConfirmationListeners();\n registered = true;\n}\n"],"names":["registered","getModalString","dataset","type","field","defaultValue","Str","get_string","apply","JSON","parse","Promise","resolve","displayConfirmation","source","confirmationPromise","then","stringForToast","str","catch","e","link","closest","window","location","href","Error","confirmation","modal","click","document","addEventListener","confirmRequest","target","preventDefault","modalConfirmation","alertRequest","async","title","content","pendingPromise","Pending","ModalFactory","create","types","ALERT","body","removeOnClose","show","displayAlert","registerConfirmationListeners"],"mappings":"iwCAqDIA,YAAa,QAcXC,eAAiB,SAACC,QAASC,KAAMC,WAAOC,oEAAe,YACrDH,kBAAWC,aAAOC,cACXE,IAAIC,WAAWC,MAAM,KAAMC,KAAKC,MAAMR,kBAAWC,aAAOC,gBAE/DF,kBAAWC,aAAOC,QACXO,QAAQC,QAAQV,kBAAWC,aAAOC,SAGzCC,aACOC,IAAIC,WAAWC,MAAM,KAAMH,cAG/B,MAWLQ,oBAAsB,CAACC,OAAQX,YAC7BY,oBAAsB,YAEtBA,oBADA,UAAGZ,eAAcW,OAAOZ,SAA6C,WAAlCY,OAAOZ,kBAAWC,eAC/B,qCAClBF,eAAea,OAAOZ,QAASC,KAAM,QAAS,CAAC,UAAW,SAC1DF,eAAea,OAAOZ,QAASC,KAAM,WACrCF,eAAea,OAAOZ,QAASC,KAAM,YAAa,CAAC,MAAO,WAGxC,mCAClBF,eAAea,OAAOZ,QAASC,KAAM,QAAS,CAAC,UAAW,SAC1DF,eAAea,OAAOZ,QAASC,KAAM,WACrCF,eAAea,OAAOZ,QAASC,KAAM,YAAa,CAAC,MAAO,UAG3DY,oBAAoBC,MAAK,QACW,SAAnCF,OAAOZ,kBAAWC,eAAyB,OACrCc,eAAiBhB,eAAea,OAAOZ,QAASC,KAAM,qBAC9B,iBAAnBc,8BACEA,gBAETA,eAAeD,MAAKE,MAAO,cAASA,OAAMC,OAAMC,IAAK,2BAAUA,WAIjEC,KAAOP,OAAOQ,QAAQ,QACxBR,OAAOZ,kBAAWC,qBAClBoB,OAAOC,SAASC,KAAOX,OAAOZ,kBAAWC,yBACtC,CAAA,IAAIW,OAAOQ,QAAQ,QAQnB,CAAA,GAAID,MAAQA,KAAKI,MAAsB,MAAdJ,KAAKI,iBAC7BF,OAAOC,SAASC,KAAOJ,KAAKI,YAG1B,IAAIC,yCAAkCvB,gBAV5CW,OAAOZ,QAAQyB,aAAe,OAC9Bb,OAAOZ,QAAQ0B,MAAQ,OAIvBd,OAAOe,YASZV,OAAM,UA+DRnB,aAzBiC,MAClC8B,SAASC,iBAAiB,SAASX,UACzBY,eAAiBZ,EAAEa,OAAOX,QAAQ,+BACpCU,iBACAZ,EAAEc,iBACFrB,oBAAoBmB,eAAgB,uBAGlCG,kBAAoBf,EAAEa,OAAOX,QAAQ,+BACvCa,oBACAf,EAAEc,iBACFrB,oBAAoBsB,kBAAmB,gBAGrCC,aAAehB,EAAEa,OAAOX,QAAQ,wBAClCc,eACAhB,EAAEc,iBAzCOG,OAAMC,MAAOC,iBACxBC,eAAiB,IAAIC,iBAAQ,sBAE7BC,2nBAECA,aAAaC,OAAO,CACvBxC,KAAMuC,aAAaE,MAAMC,MACzBP,MAAOA,MACPQ,KAAMP,QACNQ,eAAe,IAElB/B,MAAK,SAASY,cACXA,MAAMoB,OACNR,eAAe5B,UAERgB,UA2BHqB,CACIhD,eAAemC,aAAalC,QAAS,QAAS,SAC9CD,eAAemC,aAAalC,QAAS,QAAS,iBAO1DgD,GACAlD,YAAa"}
\ No newline at end of file
diff --git a/lib/amd/src/utility.js b/lib/amd/src/utility.js
index 963623030a8..1107cd8553b 100644
--- a/lib/amd/src/utility.js
+++ b/lib/amd/src/utility.js
@@ -113,6 +113,7 @@ const displayConfirmation = (source, type) => {
}
}
+ const link = source.closest('a');
if (source.dataset[`${type}Destination`]) {
window.location.href = source.dataset[`${type}Destination`];
} else if (source.closest('form')) {
@@ -123,9 +124,13 @@ const displayConfirmation = (source, type) => {
// Click on the button again.
// Note: Do not use the form.submit() because it will not work for cancel buttons.
source.click();
+ } else if (link && link.href && link.href !== '#') {
+ window.location.href = link.href;
+ return;
} else {
- throw new Error("No destination found for confirmation action");
+ throw new Error(`No destination found for ${type} modal`);
}
+
return;
}).catch(() => {
return;