Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"usetemplate.min.js","sources":["../src/usetemplate.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 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 {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"],"names":["selectors","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","addNotification","type","message","show"],"mappings":";;;;;;;0LA2BMA,uBACY,4CAME,WACVC,QAAUC,SAASC,cAAcH,wBAEvCC,QAAQG,iBAAiB,SAASC,QAC9BA,MAAMC,uBAEAC,UAAY,IAAIC,mBAAU,CAC5BC,YAAa,CACTC,OAAO,kBAAU,oBAAqB,iBAE1CC,UAAW,wCACXC,KAAM,CACFC,GAAIZ,QAAQa,aAAa,eACzBC,WAAYd,QAAQa,aAAa,oBAErCE,gBAAgB,kBAAU,OAAQ,UAItCT,UAAUH,iBAAiBG,UAAUU,OAAOC,gBAAgBb,QACpDA,MAAMc,OAAOC,OACbC,OAAOC,SAASC,OAAOlB,MAAMc,OAAOK,2BAEvBC,gBAAgB,CACzBC,KAAM,QACNC,SAAU,kBAAU,gBAAiB,qBAKjDpB,UAAUqB"}