usetemplate.min.js.map 3.66 KB
Newer Older
1
{"version":3,"sources":["../src/usetemplate.js"],"names":["selectors","modaltrigger","init","trigger","document","querySelector","addEventListener","event","preventDefault","modalForm","ModalForm","modalConfig","title","formClass","args","id","getAttribute","templateid","saveButtonText","events","FORM_SUBMITTED","detail","result","window","location","assign","url","Notification","addNotification","type","message","show"],"mappings":"kMAuBA,OACA,O,sDAGMA,CAAAA,CAAS,CAAG,CACdC,YAAY,CAAE,+BADA,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,GAEA,GAAMC,CAAAA,CAAS,CAAG,GAAIC,UAAJ,CAAc,CAC5BC,WAAW,CAAE,CACTC,KAAK,CAAE,iBAAU,mBAAV,CAA+B,cAA/B,CADE,CADe,CAI5BC,SAAS,CAAE,uCAJiB,CAK5BC,IAAI,CAAE,CACFC,EAAE,CAAEZ,CAAO,CAACa,YAAR,CAAqB,aAArB,CADF,CAEFC,UAAU,CAAEd,CAAO,CAACa,YAAR,CAAqB,iBAArB,CAFV,CALsB,CAS5BE,cAAc,CAAE,iBAAU,MAAV,CAAkB,MAAlB,CATY,CAAd,CAAlB,CAaAT,CAAS,CAACH,gBAAV,CAA2BG,CAAS,CAACU,MAAV,CAAiBC,cAA5C,CAA4D,SAAAb,CAAK,CAAI,CACjE,GAAIA,CAAK,CAACc,MAAN,CAAaC,MAAjB,CAAyB,CACrBC,MAAM,CAACC,QAAP,CAAgBC,MAAhB,CAAuBlB,CAAK,CAACc,MAAN,CAAaK,GAApC,CACH,CAFD,IAEO,CACHC,UAAaC,eAAb,CAA6B,CACzBC,IAAI,CAAE,OADmB,CAEzBC,OAAO,CAAG,iBAAU,eAAV,CAA2B,cAA3B,CAFe,CAA7B,CAIH,CACJ,CATD,EAWArB,CAAS,CAACsB,IAAV,EACH,CA5BD,CA6BH,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 using an existing template\n *\n * @module      mod_feedback/usetemplate\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';\n\nconst selectors = {\n    modaltrigger: '[data-action=\"usetemplate\"]',\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\n        const modalForm = new ModalForm({\n            modalConfig: {\n                title: getString('use_this_template', 'mod_feedback'),\n            },\n            formClass: 'mod_feedback\\\\form\\\\use_template_form',\n            args: {\n                id: trigger.getAttribute('data-dataid'),\n                templateid: trigger.getAttribute('data-templateid')\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                window.location.assign(event.detail.url);\n            } else {\n                Notification.addNotification({\n                    type: 'error',\n                    message:  getString('saving_failed', 'mod_feedback')\n                });\n            }\n        });\n\n        modalForm.show();\n    });\n};\n"],"file":"usetemplate.min.js"}