AutorÃa | Ultima modificación | Ver Log |
{"version":3,"file":"editpreset.min.js","sources":["../src/editpreset.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript module for editing a database preset.\n *\n * @module mod_data/editpreset\n * @copyright 2022 Sara Arjona <sara@moodle.com>\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 {getString} from 'core/str';\n\nconst selectors = {\n editPresetButton: '[data-action=\"editpreset\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n registerEventListeners();\n};\n\n/**\n * Register events for update/delete links.\n */\nconst registerEventListeners = () => {\n document.addEventListener('click', (event) => {\n const editAction = event.target.closest(selectors.editPresetButton);\n if (editAction) {\n event.preventDefault();\n showEditPresetModal(editAction);\n }\n });\n};\n\n/**\n * Show the edit preset modal.\n *\n * @param {HTMLElement} editAction the edit action element.\n */\nconst showEditPresetModal = (editAction) => {\n const modalForm = new ModalForm({\n modalConfig: {\n title: getString('editpreset', 'mod_data'),\n },\n formClass: 'mod_data\\\\form\\\\save_as_preset',\n
args: {\n d: editAction.getAttribute('data-dataid'),\n action: editAction.getAttribute('data-action'),\n presetname: editAction.getAttribute('data-presetname'),\n presetdescription: editAction.getAttribute('data-presetdescription')\n },\n saveButtonText: getString('save'),\n returnFocus: editAction,\n });\n\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('<br>')\n });\n }\n });\n\n modalForm.show();\n};\n"],"names":["selectors","registerEventListeners","document","addEventListener","event","editAction","target","closest","preventDefault","showEditPresetModal","modalForm","ModalForm","modalConfig","title","formClass","args","d","getAttribute","action","presetname","prese
tdescription","saveButtonText","returnFocus","events","FORM_SUBMITTED","detail","result","window","location","reload","addNotification","type","message","errors","join","show"],"mappings":";;;;;;;0LA2BMA,2BACgB,2CAMF,KAChBC,gCAMEA,uBAAyB,KAC3BC,SAASC,iBAAiB,SAAUC,cAC1BC,WAAaD,MAAME,OAAOC,QAAQP,4BACpCK,aACAD,MAAMI,iBACNC,oBAAoBJ,iBAU1BI,oBAAuBJ,mBACnBK,UAAY,IAAIC,mBAAU,CAC5BC,YAAa,CACTC,OAAO,kBAAU,aAAc,aAEnCC,UAAW,iCACXC,KAAM,CACFC,EAAGX,WAAWY,aAAa,eAC3BC,OAAQb,WAAWY,aAAa,eAChCE,WAAYd,WAAWY,aAAa,mBACpCG,kBAAmBf,WAAWY,aAAa,2BAE/CI,gBAAgB,kBAAU,QAC1BC,YAAajB,aAGjBK,UAAUP,iBAAiBO,UAAUa,OAAOC,gBAAgBpB,QACpDA,MAAMqB,OAAOC,OACbC,OAAOC,SAASC,+BAEHC,gBAAgB,CACzBC,KAAM,QACNC,QAAS5B,MAAMqB,OAAOQ,OAAOC,KAAK,aAK9CxB,UAAUyB"}