diff --git a/mod/data/amd/build/importpresets.min.js b/mod/data/amd/build/importpresets.min.js index 0914786d6d0..9933ac2d3e0 100644 --- a/mod/data/amd/build/importpresets.min.js +++ b/mod/data/amd/build/importpresets.min.js @@ -5,6 +5,6 @@ define("mod_data/importpresets",["exports","core_form/modalform","core/notificat * @module mod_data/importpreset * @copyright 2022 Laurent David * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_modalform=_interopRequireDefault(_modalform),_notification=_interopRequireDefault(_notification);const selectors_importPresetButton='[data-action="importpresets"]';_exports.init=()=>{const importPresetButton=document.querySelector(selectors_importPresetButton);importPresetButton.addEventListener("click",(event=>{event.preventDefault();const modalForm=new _modalform.default({modalConfig:{title:(0,_str.get_string)("importpreset","mod_data")},formClass:"mod_data\\form\\import_presets",args:{cmid:importPresetButton.dataset.dataid},saveButtonText:(0,_str.get_string)("importandapply","mod_data")});modalForm.addEventListener(modalForm.events.FORM_SUBMITTED,(event=>{event.detail.result?window.location.assign(event.detail.url):_notification.default.addNotification({type:"error",message:event.detail.errors.join("
")})})),modalForm.show()}))}})); + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_modalform=_interopRequireDefault(_modalform),_notification=_interopRequireDefault(_notification);const selectors_importPresetButton='[data-action="importpresets"]';_exports.init=()=>{document.addEventListener("click",(event=>{const importPresetButton=event.target.closest(selectors_importPresetButton);if(!importPresetButton)return;event.preventDefault();const modalForm=new _modalform.default({modalConfig:{title:(0,_str.get_string)("importpreset","mod_data")},formClass:"mod_data\\form\\import_presets",args:{cmid:importPresetButton.dataset.dataid},saveButtonText:(0,_str.get_string)("importandapply","mod_data")});modalForm.addEventListener(modalForm.events.FORM_SUBMITTED,(event=>{event.detail.result?window.location.assign(event.detail.url):_notification.default.addNotification({type:"error",message:event.detail.errors.join("
")})})),modalForm.show()}))}})); //# sourceMappingURL=importpresets.min.js.map \ No newline at end of file diff --git a/mod/data/amd/build/importpresets.min.js.map b/mod/data/amd/build/importpresets.min.js.map index 3f14ff27d88..80143082774 100644 --- a/mod/data/amd/build/importpresets.min.js.map +++ b/mod/data/amd/build/importpresets.min.js.map @@ -1 +1 @@ -{"version":3,"file":"importpresets.min.js","sources":["../src/importpresets.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 module for importing presets.\n *\n * @module mod_data/importpreset\n * @copyright 2022 Laurent David \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalForm from 'core_form/modalform';\nimport Notification from 'core/notification';\nimport {get_string as getString} from 'core/str';\n\nconst selectors = {\n importPresetButton: '[data-action=\"importpresets\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n const importPresetButton = document.querySelector(selectors.importPresetButton);\n\n importPresetButton.addEventListener('click', event => {\n event.preventDefault();\n\n const modalForm = new ModalForm({\n modalConfig: {\n title: getString('importpreset', 'mod_data'),\n },\n formClass: 'mod_data\\\\form\\\\import_presets',\n args: {cmid: importPresetButton.dataset.dataid},\n saveButtonText: getString('importandapply', 'mod_data'),\n });\n\n modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {\n if (event.detail.result) {\n window.location.assign(event.detail.url);\n } else {\n Notification.addNotification({\n type: 'error',\n message: event.detail.errors.join('
')\n });\n }\n });\n modalForm.show();\n });\n};\n"],"names":["selectors","importPresetButton","document","querySelector","addEventListener","event","preventDefault","modalForm","ModalForm","modalConfig","title","formClass","args","cmid","dataset","dataid","saveButtonText","events","FORM_SUBMITTED","detail","result","window","location","assign","url","addNotification","type","message","errors","join","show"],"mappings":";;;;;;;0LA2BMA,6BACkB,8CAMJ,WACVC,mBAAqBC,SAASC,cAAcH,8BAElDC,mBAAmBG,iBAAiB,SAASC,QACzCA,MAAMC,uBAEAC,UAAY,IAAIC,mBAAU,CAC5BC,YAAa,CACTC,OAAO,mBAAU,eAAgB,aAErCC,UAAW,iCACXC,KAAM,CAACC,KAAMZ,mBAAmBa,QAAQC,QACxCC,gBAAgB,mBAAU,iBAAkB,cAGhDT,UAAUH,iBAAiBG,UAAUU,OAAOC,gBAAgBb,QACpDA,MAAMc,OAAOC,OACbC,OAAOC,SAASC,OAAOlB,MAAMc,OAAOK,2BAEvBC,gBAAgB,CACzBC,KAAM,QACNC,QAAStB,MAAMc,OAAOS,OAAOC,KAAK,aAI9CtB,UAAUuB"} \ No newline at end of file +{"version":3,"file":"importpresets.min.js","sources":["../src/importpresets.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 module for importing presets.\n *\n * @module mod_data/importpreset\n * @copyright 2022 Laurent David \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalForm from 'core_form/modalform';\nimport Notification from 'core/notification';\nimport {get_string as getString} from 'core/str';\n\nconst selectors = {\n importPresetButton: '[data-action=\"importpresets\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n document.addEventListener('click', (event) => {\n const importPresetButton = event.target.closest(selectors.importPresetButton);\n\n if (!importPresetButton) {\n return;\n }\n\n event.preventDefault();\n const modalForm = new ModalForm({\n modalConfig: {\n title: getString('importpreset', 'mod_data'),\n },\n formClass: 'mod_data\\\\form\\\\import_presets',\n args: {cmid: importPresetButton.dataset.dataid},\n saveButtonText: getString('importandapply', 'mod_data'),\n });\n\n modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {\n if (event.detail.result) {\n window.location.assign(event.detail.url);\n } else {\n Notification.addNotification({\n type: 'error',\n message: event.detail.errors.join('
')\n });\n }\n });\n modalForm.show();\n });\n};\n"],"names":["selectors","document","addEventListener","event","importPresetButton","target","closest","preventDefault","modalForm","ModalForm","modalConfig","title","formClass","args","cmid","dataset","dataid","saveButtonText","events","FORM_SUBMITTED","detail","result","window","location","assign","url","addNotification","type","message","errors","join","show"],"mappings":";;;;;;;0LA2BMA,6BACkB,8CAMJ,KAChBC,SAASC,iBAAiB,SAAUC,cAC1BC,mBAAqBD,MAAME,OAAOC,QAAQN,kCAE3CI,0BAILD,MAAMI,uBACAC,UAAY,IAAIC,mBAAU,CAC5BC,YAAa,CACTC,OAAO,mBAAU,eAAgB,aAErCC,UAAW,iCACXC,KAAM,CAACC,KAAMV,mBAAmBW,QAAQC,QACxCC,gBAAgB,mBAAU,iBAAkB,cAGhDT,UAAUN,iBAAiBM,UAAUU,OAAOC,gBAAgBhB,QACpDA,MAAMiB,OAAOC,OACbC,OAAOC,SAASC,OAAOrB,MAAMiB,OAAOK,2BAEvBC,gBAAgB,CACzBC,KAAM,QACNC,QAASzB,MAAMiB,OAAOS,OAAOC,KAAK,aAI9CtB,UAAUuB"} \ No newline at end of file diff --git a/mod/data/amd/build/saveaspreset.min.js b/mod/data/amd/build/saveaspreset.min.js index 73575fd0b0f..5ca264d3673 100644 --- a/mod/data/amd/build/saveaspreset.min.js +++ b/mod/data/amd/build/saveaspreset.min.js @@ -5,6 +5,6 @@ define("mod_data/saveaspreset",["exports","core_form/modalform","core/notificati * @module mod_data/saveaspreset * @copyright 2021 Mihail Geshoski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_modalform=_interopRequireDefault(_modalform),_notification=_interopRequireDefault(_notification);const selectors_saveAsPresetButton='[data-action="saveaspreset"]';_exports.init=()=>{const saveAsPresetButton=document.querySelector(selectors_saveAsPresetButton);saveAsPresetButton.addEventListener("click",(event=>{event.preventDefault();const modalForm=new _modalform.default({modalConfig:{title:(0,_str.get_string)("savedataaspreset","mod_data")},formClass:"mod_data\\form\\save_as_preset",args:{d:saveAsPresetButton.getAttribute("data-dataid")},saveButtonText:(0,_str.get_string)("save"),returnFocus:saveAsPresetButton});modalForm.addEventListener(modalForm.events.FORM_SUBMITTED,(event=>{event.detail.result?window.location.reload():_notification.default.addNotification({type:"error",message:event.detail.errors.join("
")})})),modalForm.show()}))}})); + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_modalform=_interopRequireDefault(_modalform),_notification=_interopRequireDefault(_notification);const selectors_saveAsPresetButton='[data-action="saveaspreset"]';_exports.init=()=>{document.addEventListener("click",(event=>{const saveAsPresetButton=event.target.closest(selectors_saveAsPresetButton);if(!saveAsPresetButton)return;event.preventDefault();const modalForm=new _modalform.default({modalConfig:{title:(0,_str.get_string)("savedataaspreset","mod_data")},formClass:"mod_data\\form\\save_as_preset",args:{d:saveAsPresetButton.dataset.dataid},saveButtonText:(0,_str.get_string)("save"),returnFocus:saveAsPresetButton});modalForm.addEventListener(modalForm.events.FORM_SUBMITTED,(event=>{event.detail.result?window.location.reload():_notification.default.addNotification({type:"error",message:event.detail.errors.join("
")})})),modalForm.show()}))}})); //# sourceMappingURL=saveaspreset.min.js.map \ No newline at end of file diff --git a/mod/data/amd/build/saveaspreset.min.js.map b/mod/data/amd/build/saveaspreset.min.js.map index 83fa714f729..51f597941ee 100644 --- a/mod/data/amd/build/saveaspreset.min.js.map +++ b/mod/data/amd/build/saveaspreset.min.js.map @@ -1 +1 @@ -{"version":3,"file":"saveaspreset.min.js","sources":["../src/saveaspreset.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 module for saving a database as a preset.\n *\n * @module mod_data/saveaspreset\n * @copyright 2021 Mihail Geshoski \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalForm from 'core_form/modalform';\nimport Notification from 'core/notification';\nimport {get_string as getString} from 'core/str';\n\nconst selectors = {\n saveAsPresetButton: '[data-action=\"saveaspreset\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n const saveAsPresetButton = document.querySelector(selectors.saveAsPresetButton);\n\n saveAsPresetButton.addEventListener('click', event => {\n event.preventDefault();\n\n const modalForm = new ModalForm({\n modalConfig: {\n title: getString('savedataaspreset', 'mod_data'),\n },\n formClass: 'mod_data\\\\form\\\\save_as_preset',\n args: {d: saveAsPresetButton.getAttribute('data-dataid')},\n saveButtonText: getString('save'),\n returnFocus: saveAsPresetButton,\n });\n\n // Show a toast notification when the form is submitted.\n modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {\n if (event.detail.result) {\n window.location.reload();\n } else {\n Notification.addNotification({\n type: 'error',\n message: event.detail.errors.join('
')\n });\n }\n });\n\n modalForm.show();\n });\n};\n"],"names":["selectors","saveAsPresetButton","document","querySelector","addEventListener","event","preventDefault","modalForm","ModalForm","modalConfig","title","formClass","args","d","getAttribute","saveButtonText","returnFocus","events","FORM_SUBMITTED","detail","result","window","location","reload","addNotification","type","message","errors","join","show"],"mappings":";;;;;;;0LA2BMA,6BACkB,6CAMJ,WACVC,mBAAqBC,SAASC,cAAcH,8BAElDC,mBAAmBG,iBAAiB,SAASC,QACzCA,MAAMC,uBAEAC,UAAY,IAAIC,mBAAU,CAC5BC,YAAa,CACTC,OAAO,mBAAU,mBAAoB,aAEzCC,UAAW,iCACXC,KAAM,CAACC,EAAGZ,mBAAmBa,aAAa,gBAC1CC,gBAAgB,mBAAU,QAC1BC,YAAaf,qBAIjBM,UAAUH,iBAAiBG,UAAUU,OAAOC,gBAAgBb,QACpDA,MAAMc,OAAOC,OACbC,OAAOC,SAASC,+BAEHC,gBAAgB,CACzBC,KAAM,QACNC,QAAUrB,MAAMc,OAAOQ,OAAOC,KAAK,aAK/CrB,UAAUsB"} \ No newline at end of file +{"version":3,"file":"saveaspreset.min.js","sources":["../src/saveaspreset.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 module for saving a database as a preset.\n *\n * @module mod_data/saveaspreset\n * @copyright 2021 Mihail Geshoski \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalForm from 'core_form/modalform';\nimport Notification from 'core/notification';\nimport {get_string as getString} from 'core/str';\n\nconst selectors = {\n saveAsPresetButton: '[data-action=\"saveaspreset\"]',\n};\n\n/**\n * Initialize module.\n */\nexport const init = () => {\n\n document.addEventListener('click', (event) => {\n const saveAsPresetButton = event.target.closest(selectors.saveAsPresetButton);\n\n if (!saveAsPresetButton) {\n return;\n }\n\n event.preventDefault();\n const modalForm = new ModalForm({\n modalConfig: {\n title: getString('savedataaspreset', 'mod_data'),\n },\n formClass: 'mod_data\\\\form\\\\save_as_preset',\n args: {d: saveAsPresetButton.dataset.dataid},\n saveButtonText: getString('save'),\n returnFocus: saveAsPresetButton,\n });\n\n // Show a toast notification when the form is submitted.\n modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {\n if (event.detail.result) {\n window.location.reload();\n } else {\n Notification.addNotification({\n type: 'error',\n message: event.detail.errors.join('
')\n });\n }\n });\n\n modalForm.show();\n });\n};\n"],"names":["selectors","document","addEventListener","event","saveAsPresetButton","target","closest","preventDefault","modalForm","ModalForm","modalConfig","title","formClass","args","d","dataset","dataid","saveButtonText","returnFocus","events","FORM_SUBMITTED","detail","result","window","location","reload","addNotification","type","message","errors","join","show"],"mappings":";;;;;;;0LA2BMA,6BACkB,6CAMJ,KAEhBC,SAASC,iBAAiB,SAAUC,cAC1BC,mBAAqBD,MAAME,OAAOC,QAAQN,kCAE3CI,0BAILD,MAAMI,uBACAC,UAAY,IAAIC,mBAAU,CAC5BC,YAAa,CACTC,OAAO,mBAAU,mBAAoB,aAEzCC,UAAW,iCACXC,KAAM,CAACC,EAAGV,mBAAmBW,QAAQC,QACrCC,gBAAgB,mBAAU,QAC1BC,YAAad,qBAIjBI,UAAUN,iBAAiBM,UAAUW,OAAOC,gBAAgBjB,QACpDA,MAAMkB,OAAOC,OACbC,OAAOC,SAASC,+BAEHC,gBAAgB,CACzBC,KAAM,QACNC,QAAUzB,MAAMkB,OAAOQ,OAAOC,KAAK,aAK/CtB,UAAUuB"} \ No newline at end of file diff --git a/mod/data/amd/build/templateseditor.min.js.map b/mod/data/amd/build/templateseditor.min.js.map index b7e94269881..07698917b6c 100644 --- a/mod/data/amd/build/templateseditor.min.js.map +++ b/mod/data/amd/build/templateseditor.min.js.map @@ -1 +1 @@ -{"version":3,"file":"templateseditor.min.js","sources":["../src/templateseditor.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 module to control the template editor.\n *\n * @module mod_data/templateseditor\n * @copyright 2021 Mihail Geshoski \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {get_string as getString} from 'core/str';\nimport {prefetchStrings} from 'core/prefetch';\nimport {relativeUrl} from 'core/url';\nimport {saveCancel} from 'core/notification';\n\nprefetchStrings('admin', ['confirmation']);\nprefetchStrings('mod_data', [\n 'resettemplateconfirmtitle',\n 'resettemplateconfirm',\n 'resettemplate',\n 'enabletemplateeditorcheck',\n 'editorenable'\n]);\n\n/**\n * Template editor constants.\n */\nconst selectors = {\n toggleTemplateEditor: 'input[name=\"useeditor\"]',\n resetTemplate: 'input[name=\"defaultform\"]',\n resetButton: 'input[name=\"resetbutton\"]',\n editForm: '#edittemplateform',\n};\n\n/**\n * Register event listeners for the module.\n *\n * @param {int} instanceId The database ID\n * @param {string} mode The template mode\n */\nconst registerEventListeners = (instanceId, mode) => {\n registerResetButton();\n registerEditorToggler(instanceId, mode);\n};\n\nconst registerResetButton = () => {\n const editForm = document.querySelector(selectors.editForm);\n const resetButton = document.querySelector(selectors.resetButton);\n const resetTemplate = document.querySelector(selectors.resetTemplate);\n\n if (!resetButton || !resetTemplate || !editForm) {\n return;\n }\n\n resetButton.addEventListener('click', async(event) => {\n event.preventDefault();\n saveCancel(\n getString('resettemplateconfirmtitle', 'mod_data'),\n getString('resettemplateconfirm', 'mod_data'),\n getString('resettemplate', 'mod_data'),\n () => {\n resetTemplate.value = \"true\";\n editForm.submit();\n },\n null,\n {triggerElement: event.target}\n );\n });\n};\n\nconst registerEditorToggler = (instanceId, mode) => {\n const toggleTemplateEditor = document.querySelector(selectors.toggleTemplateEditor);\n\n if (!toggleTemplateEditor) {\n return;\n }\n\n toggleTemplateEditor.addEventListener('click', async(event) => {\n event.preventDefault();\n // Whether the event action attempts to enable or disable the template editor.\n const enableTemplateEditor = event.target.checked;\n\n if (enableTemplateEditor) {\n // Display a confirmation dialog before enabling the template editor.\n saveCancel(\n getString('confirmation', 'admin'),\n getString('enabletemplateeditorcheck', 'mod_data'),\n getString('editorenable', 'mod_data'),\n () => {\n window.location = relativeUrl('/mod/data/templates.php', {d: instanceId, mode: mode, useeditor: true});\n },\n null,\n {triggerElement: event.target}\n );\n } else {\n window.location = relativeUrl('/mod/data/templates.php', {d: instanceId, mode: mode, useeditor: false});\n }\n });\n};\n\n/**\n * Initialize the module.\n *\n * @param {int} instanceId The database ID\n * @param {string} mode The template mode\n */\nexport const init = (instanceId, mode) => {\n registerEventListeners(instanceId, mode);\n};\n"],"names":["selectors","registerResetButton","editForm","document","querySelector","resetButton","resetTemplate","addEventListener","async","event","preventDefault","value","submit","triggerElement","target","registerEditorToggler","instanceId","mode","toggleTemplateEditor","checked","window","location","d","useeditor","registerEventListeners"],"mappings":";;;;;;;;8BA4BgB,QAAS,CAAC,+CACV,WAAY,CACxB,4BACA,uBACA,gBACA,4BACA,uBAMEA,+BACoB,0BADpBA,wBAEa,4BAFbA,sBAGW,4BAHXA,mBAIQ,oBAcRC,oBAAsB,WAClBC,SAAWC,SAASC,cAAcJ,oBAClCK,YAAcF,SAASC,cAAcJ,uBACrCM,cAAgBH,SAASC,cAAcJ,yBAExCK,aAAgBC,eAAkBJ,UAIvCG,YAAYE,iBAAiB,SAASC,MAAAA,QAClCC,MAAMC,+CAEF,mBAAU,4BAA6B,aACvC,mBAAU,uBAAwB,aAClC,mBAAU,gBAAiB,aAC3B,KACIJ,cAAcK,MAAQ,OACtBT,SAASU,WAEb,KACA,CAACC,eAAgBJ,MAAMK,aAK7BC,sBAAwB,CAACC,WAAYC,cACjCC,qBAAuBf,SAASC,cAAcJ,gCAE/CkB,sBAILA,qBAAqBX,iBAAiB,SAASC,MAAAA,QAC3CC,MAAMC,iBAEuBD,MAAMK,OAAOK,sCAKlC,mBAAU,eAAgB,UAC1B,mBAAU,4BAA6B,aACvC,mBAAU,eAAgB,aAC1B,KACIC,OAAOC,UAAW,oBAAY,0BAA2B,CAACC,EAAGN,WAAYC,KAAMA,KAAMM,WAAW,MAEpG,KACA,CAACV,eAAgBJ,MAAMK,SAG3BM,OAAOC,UAAW,oBAAY,0BAA2B,CAACC,EAAGN,WAAYC,KAAMA,KAAMM,WAAW,sBAWxF,CAACP,WAAYC,QAlEF,EAACD,WAAYC,QACxChB,sBACAc,sBAAsBC,WAAYC,OAiElCO,CAAuBR,WAAYC"} \ No newline at end of file +{"version":3,"file":"templateseditor.min.js","sources":["../src/templateseditor.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 module to control the template editor.\n *\n * @module mod_data/templateseditor\n * @copyright 2021 Mihail Geshoski \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {get_string as getString} from 'core/str';\nimport {prefetchStrings} from 'core/prefetch';\nimport {relativeUrl} from 'core/url';\nimport {saveCancel} from 'core/notification';\n\nprefetchStrings('admin', ['confirmation']);\nprefetchStrings('mod_data', [\n 'resettemplateconfirmtitle',\n 'resettemplateconfirm',\n 'resettemplate',\n 'enabletemplateeditorcheck',\n 'editorenable'\n]);\n\n/**\n * Template editor constants.\n */\nconst selectors = {\n toggleTemplateEditor: 'input[name=\"useeditor\"]',\n resetTemplate: 'input[name=\"defaultform\"]',\n resetButton: 'input[name=\"resetbutton\"]',\n editForm: '#edittemplateform',\n};\n\n/**\n * Register event listeners for the module.\n *\n * @param {Number} instanceId The database ID\n * @param {string} mode The template mode\n */\nconst registerEventListeners = (instanceId, mode) => {\n registerResetButton();\n registerEditorToggler(instanceId, mode);\n};\n\nconst registerResetButton = () => {\n const editForm = document.querySelector(selectors.editForm);\n const resetButton = document.querySelector(selectors.resetButton);\n const resetTemplate = document.querySelector(selectors.resetTemplate);\n\n if (!resetButton || !resetTemplate || !editForm) {\n return;\n }\n\n resetButton.addEventListener('click', async(event) => {\n event.preventDefault();\n saveCancel(\n getString('resettemplateconfirmtitle', 'mod_data'),\n getString('resettemplateconfirm', 'mod_data'),\n getString('resettemplate', 'mod_data'),\n () => {\n resetTemplate.value = \"true\";\n editForm.submit();\n },\n null,\n {triggerElement: event.target}\n );\n });\n};\n\nconst registerEditorToggler = (instanceId, mode) => {\n const toggleTemplateEditor = document.querySelector(selectors.toggleTemplateEditor);\n\n if (!toggleTemplateEditor) {\n return;\n }\n\n toggleTemplateEditor.addEventListener('click', async(event) => {\n event.preventDefault();\n // Whether the event action attempts to enable or disable the template editor.\n const enableTemplateEditor = event.target.checked;\n\n if (enableTemplateEditor) {\n // Display a confirmation dialog before enabling the template editor.\n saveCancel(\n getString('confirmation', 'admin'),\n getString('enabletemplateeditorcheck', 'mod_data'),\n getString('editorenable', 'mod_data'),\n () => {\n window.location = relativeUrl('/mod/data/templates.php', {d: instanceId, mode: mode, useeditor: true});\n },\n null,\n {triggerElement: event.target}\n );\n } else {\n window.location = relativeUrl('/mod/data/templates.php', {d: instanceId, mode: mode, useeditor: false});\n }\n });\n};\n\n/**\n * Initialize the module.\n *\n * @param {int} instanceId The database ID\n * @param {string} mode The template mode\n */\nexport const init = (instanceId, mode) => {\n registerEventListeners(instanceId, mode);\n};\n"],"names":["selectors","registerResetButton","editForm","document","querySelector","resetButton","resetTemplate","addEventListener","async","event","preventDefault","value","submit","triggerElement","target","registerEditorToggler","instanceId","mode","toggleTemplateEditor","checked","window","location","d","useeditor","registerEventListeners"],"mappings":";;;;;;;;8BA4BgB,QAAS,CAAC,+CACV,WAAY,CACxB,4BACA,uBACA,gBACA,4BACA,uBAMEA,+BACoB,0BADpBA,wBAEa,4BAFbA,sBAGW,4BAHXA,mBAIQ,oBAcRC,oBAAsB,WAClBC,SAAWC,SAASC,cAAcJ,oBAClCK,YAAcF,SAASC,cAAcJ,uBACrCM,cAAgBH,SAASC,cAAcJ,yBAExCK,aAAgBC,eAAkBJ,UAIvCG,YAAYE,iBAAiB,SAASC,MAAAA,QAClCC,MAAMC,+CAEF,mBAAU,4BAA6B,aACvC,mBAAU,uBAAwB,aAClC,mBAAU,gBAAiB,aAC3B,KACIJ,cAAcK,MAAQ,OACtBT,SAASU,WAEb,KACA,CAACC,eAAgBJ,MAAMK,aAK7BC,sBAAwB,CAACC,WAAYC,cACjCC,qBAAuBf,SAASC,cAAcJ,gCAE/CkB,sBAILA,qBAAqBX,iBAAiB,SAASC,MAAAA,QAC3CC,MAAMC,iBAEuBD,MAAMK,OAAOK,sCAKlC,mBAAU,eAAgB,UAC1B,mBAAU,4BAA6B,aACvC,mBAAU,eAAgB,aAC1B,KACIC,OAAOC,UAAW,oBAAY,0BAA2B,CAACC,EAAGN,WAAYC,KAAMA,KAAMM,WAAW,MAEpG,KACA,CAACV,eAAgBJ,MAAMK,SAG3BM,OAAOC,UAAW,oBAAY,0BAA2B,CAACC,EAAGN,WAAYC,KAAMA,KAAMM,WAAW,sBAWxF,CAACP,WAAYC,QAlEF,EAACD,WAAYC,QACxChB,sBACAc,sBAAsBC,WAAYC,OAiElCO,CAAuBR,WAAYC"} \ No newline at end of file diff --git a/mod/data/amd/src/importpresets.js b/mod/data/amd/src/importpresets.js index 370391f0084..2c57a259e19 100644 --- a/mod/data/amd/src/importpresets.js +++ b/mod/data/amd/src/importpresets.js @@ -33,11 +33,14 @@ const selectors = { * Initialize module */ export const init = () => { - const importPresetButton = document.querySelector(selectors.importPresetButton); + document.addEventListener('click', (event) => { + const importPresetButton = event.target.closest(selectors.importPresetButton); + + if (!importPresetButton) { + return; + } - importPresetButton.addEventListener('click', event => { event.preventDefault(); - const modalForm = new ModalForm({ modalConfig: { title: getString('importpreset', 'mod_data'), diff --git a/mod/data/amd/src/saveaspreset.js b/mod/data/amd/src/saveaspreset.js index f6d04ada041..642eb276753 100644 --- a/mod/data/amd/src/saveaspreset.js +++ b/mod/data/amd/src/saveaspreset.js @@ -30,20 +30,24 @@ const selectors = { }; /** - * Initialize module + * Initialize module. */ export const init = () => { - const saveAsPresetButton = document.querySelector(selectors.saveAsPresetButton); - saveAsPresetButton.addEventListener('click', event => { + document.addEventListener('click', (event) => { + const saveAsPresetButton = event.target.closest(selectors.saveAsPresetButton); + + if (!saveAsPresetButton) { + return; + } + event.preventDefault(); - const modalForm = new ModalForm({ modalConfig: { title: getString('savedataaspreset', 'mod_data'), }, formClass: 'mod_data\\form\\save_as_preset', - args: {d: saveAsPresetButton.getAttribute('data-dataid')}, + args: {d: saveAsPresetButton.dataset.dataid}, saveButtonText: getString('save'), returnFocus: saveAsPresetButton, }); diff --git a/mod/data/amd/src/templateseditor.js b/mod/data/amd/src/templateseditor.js index 5dc45eba7b6..5c5bf8505de 100644 --- a/mod/data/amd/src/templateseditor.js +++ b/mod/data/amd/src/templateseditor.js @@ -48,7 +48,7 @@ const selectors = { /** * Register event listeners for the module. * - * @param {int} instanceId The database ID + * @param {Number} instanceId The database ID * @param {string} mode The template mode */ const registerEventListeners = (instanceId, mode) => { diff --git a/mod/data/templates/presets_action_bar.mustache b/mod/data/templates/presets_action_bar.mustache index 12d51d5d0b0..16eb8d57002 100644 --- a/mod/data/templates/presets_action_bar.mustache +++ b/mod/data/templates/presets_action_bar.mustache @@ -74,11 +74,8 @@
{{#js}} - require(['mod_data/saveaspreset'], function(saveAsPreset) { + require(['mod_data/saveaspreset', 'mod_data/importpresets'], (saveAsPreset, importPresets) => { saveAsPreset.init(); - }); - - require(['mod_data/importpresets'], function(importPresetsModal) { importPresetsModal.init(); }); {{/js}}