Sindbad~EG File Manager
{"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 <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript module for saving a database as a preset.\n *\n * @module mod_data/saveaspreset\n * @copyright 2021 Mihail Geshoski <mihail@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 {get_string as getString} from 'core/str';\nimport {add as addToast} from 'core/toast';\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 getString('savesuccess', 'data').then(addToast).catch();\n } else {\n Notification.addNotification({\n type: 'error',\n message: event.detail.errors.join('<br>')\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","then","addToast","catch","addNotification","type","message","errors","join","show"],"mappings":";;;;;;;0LA4BMA,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,2BACH,cAAe,QAAQC,KAAKC,YAAUC,8BAEnCC,gBAAgB,CACzBC,KAAM,QACNC,QAAUrB,MAAMc,OAAOQ,OAAOC,KAAK,aAK/CrB,UAAUsB"}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists