createtemplate.min.js.map 3.84 KB
Newer Older
1
{"version":3,"sources":["../src/createtemplate.js"],"names":["selectors","modaltrigger","init","trigger","document","querySelector","addEventListener","event","preventDefault","ele","currentTarget","modalForm","ModalForm","modalConfig","title","formClass","args","id","dataset","dataid","saveButtonText","events","FORM_SUBMITTED","detail","result","then","addToast","catch","string","Notification","addNotification","type","message","show"],"mappings":"oNAuBA,OACA,O,sDAIMA,CAAAA,CAAS,CAAG,CACdC,YAAY,CAAE,kCADA,C,QAOE,QAAPC,CAAAA,IAAO,EAAM,CACtB,GAAMC,CAAAA,CAAO,CAAGC,QAAQ,CAACC,aAAT,CAAuBL,CAAS,CAACC,YAAjC,CAAhB,CAEAE,CAAO,CAACG,gBAAR,CAAyB,OAAzB,CAAkC,SAAAC,CAAK,CAAI,CACvCA,CAAK,CAACC,cAAN,GADuC,GAEjCC,CAAAA,CAAG,CAAGF,CAAK,CAACG,aAFqB,CAIjCC,CAAS,CAAG,GAAIC,UAAJ,CAAc,CAC5BC,WAAW,CAAE,CACTC,KAAK,CAAE,iBAAU,sBAAV,CAAkC,cAAlC,CADE,CADe,CAI5BC,SAAS,CAAE,0CAJiB,CAK5BC,IAAI,CAAE,CACFC,EAAE,CAAER,CAAG,CAACS,OAAJ,CAAYC,MADd,CALsB,CAQ5BC,cAAc,CAAE,iBAAU,MAAV,CAAkB,MAAlB,CARY,CAAd,CAJqB,CAgBvCT,CAAS,CAACL,gBAAV,CAA2BK,CAAS,CAACU,MAAV,CAAiBC,cAA5C,CAA4D,SAAAf,CAAK,CAAI,CACjE,GAAIA,CAAK,CAACgB,MAAN,CAAaC,MAAjB,CAAyB,CACrB,iBAAU,gBAAV,CAA4B,UAA5B,EAAwCC,IAAxC,CAA6CC,KAA7C,EAAuDC,KAAvD,EACH,CAFD,IAEO,CACH,iBAAU,eAAV,CAA2B,UAA3B,EAAuCF,IAAvC,CAA4C,SAAAG,CAAM,CAAI,CAClD,MAAOC,WAAaC,eAAb,CAA6B,CAChCC,IAAI,CAAE,OAD0B,CAEhCC,OAAO,CAAEJ,CAFuB,CAA7B,CAIV,CALD,EAKGD,KALH,EAMH,CACJ,CAXD,EAaAhB,CAAS,CAACsB,IAAV,EACH,CA9BD,CA+BH,C","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 new template.\n *\n * @module      mod_feedback/createtemplate\n * @copyright   2021 Peter Dias\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    modaltrigger: '[data-action=\"createtemplate\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n    const trigger = document.querySelector(selectors.modaltrigger);\n\n    trigger.addEventListener('click', event => {\n        event.preventDefault();\n        const ele = event.currentTarget;\n\n        const modalForm = new ModalForm({\n            modalConfig: {\n                title: getString('save_as_new_template', 'mod_feedback'),\n            },\n            formClass: 'mod_feedback\\\\form\\\\create_template_form',\n            args: {\n                id: ele.dataset.dataid\n            },\n            saveButtonText: getString('save', 'core')\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('template_saved', 'feedback').then(addToast).catch();\n            } else {\n                getString('saving_failed', 'feedback').then(string => {\n                    return Notification.addNotification({\n                        type: 'error',\n                        message: string\n                    });\n                }).catch();\n            }\n        });\n\n        modalForm.show();\n    });\n};\n"],"file":"createtemplate.min.js"}