Proyectos de Subversion Moodle

Rev

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

{"version":3,"file":"createtemplate.min.js","sources":["../src/createtemplate.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 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 {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"],"names":["selectors","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":";;;;;;;0LA4BMA,uBACY,+CAME,KACAC,SAASC,cAAcF,wBAE/BG,iBAAiB,SAASC,QAC9BA,MAAMC,uBACAC,IAAMF,MAAMG,cAEZC,UAAY,IAAIC,mBAAU,CAC5BC,YAAa,CACTC,OAAO,kBAAU,uBAAwB,iBAE7CC,UAAW,2CACXC,KAAM,CACFC,GAAIR,IAAIS,QAAQC,QAEpBC,gBAAgB,kBAAU,OAAQ,UAItCT,UAAUL,iBAAiBK,UAAUU,OAAOC,gBAAgBf,QACpDA,MAAMgB,OAAOC,0BACH,iBAAkB,YAAYC,KAAKC,YAAUC,2BAE7C,gBAAiB,YAAYF,MAAKG,QACjCC,sBAAaC,gBAAgB,CAChCC,KAAM,QACNC,QAASJ,WAEdD,WAIXhB,UAAUsB"}