Proyectos de Subversion Moodle

Rev

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

{"version":3,"file":"contactdpo.min.js","sources":["../src/contactdpo.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 contacting the site DPO\n *\n * @module      tool_dataprivacy/contactdpo\n * @copyright   2021 Paul Holden <paulh@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 {getString} from 'core/str';\nimport {add as addToast} from 'core/toast';\n\nconst SELECTORS = {\n    CONTACT_DPO: '[data-action=\"contactdpo\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n    const triggerElement = document.querySelector(SELECTORS.CONTACT_DPO);\n\n    triggerElement.addEventListener('click', event => {\n        event.preventDefault();\n\n        const modalForm = new ModalForm({\n            modalConfig: {\n                title: getString('contactdataprotectionofficer', 'tool_dataprivacy'),\n            },\n            formClass: 'tool_dataprivacy\\\\form\\\\contactdpo',\n            saveButtonText: getString('send', 'tool_dataprivacy'),\n            returnFocus: triggerElement,\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('requestsubmitted', 'tool_dataprivacy').then(addToast).catch();\n            } else {\n                const warningMessages = event.detail.warnings.map(warning => warning.message);\n                Notification.addNotification({\n                    type: 'error',\n                    message: warningMessages.join('<br>')\n                });\n            }\n        });\n\n        modalForm.show();\n    });\n};\n"],"names":["SELECTORS","triggerElement","document","querySelector","addEventListener","event","preventDefault","modalForm","ModalForm","modalConfig","title","formClass","saveButtonText","returnFocus","events","FORM_SUBMITTED","detail","result","then","addToast","catch","warningMessages","warnings","map","warning","message","addNotification","type","join","show"],"mappings":";;;;;;;0LA4BMA,sBACW,2CAMG,WACVC,eAAiBC,SAASC,cAAcH,uBAE9CC,eAAeG,iBAAiB,SAASC,QACrCA,MAAMC,uBAEAC,UAAY,IAAIC,mBAAU,CAC5BC,YAAa,CACTC,OAAO,kBAAU,+BAAgC,qBAErDC,UAAW,qCACXC,gBAAgB,kBAAU,OAAQ,oBAClCC,YAAaZ,iBAIjBM,UAAUH,iBAAiBG,UAAUO,OAAOC,gBAAgBV,WACpDA,MAAMW,OAAOC,0BACH,mBAAoB,oBAAoBC,KAAKC,YAAUC,YAC9D,OACGC,gBAAkBhB,MAAMW,OAAOM,SAASC,KAAIC,SAAWA,QAAQC,gCACxDC,gBAAgB,CACzBC,KAAM,QACNF,QAASJ,gBAAgBO,KAAK,cAK1CrB,UAAUsB"}