{"version":3,"file":"confirmcompletion.min.js","sources":["https:\/\/lmsacelab.com\/m45\/mod\/pulse\/amd\/src\/confirmcompletion.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 .\n\n\/**\n * Manual completion confirmation options.\n *\n * @module mod_pulse\/confirmcompletion\n * @copyright 2023, bdecent gmbh bdecent.de\n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\ndefine([\"jquery\", 'core\/str', \"core\/modal_factory\", 'core\/notification', 'core\/ajax', \"core\/fragment\", 'core\/modal_events'],\n (function ($, Str, ModalFactory, notification, Ajax, Fragment, ModalEvents) {\n\n \/**\n * Show mark as completion button confirmation modal.\n * @param {init} contextid\n *\/\n const ButtonConfirmation = function (contextid) {\n if (document.body.classList.contains('path-course-view')) {\n var buttons = document.querySelectorAll('.pulse-user-manualcompletion-btn');\n buttons.forEach(function (element) {\n element.addEventListener('click', function (e) {\n var classList = e.target.className;\n var id = classList.match(\/confirmation-(\\d+)\/);\n if (id) {\n id = id[1];\n getModal(id, contextid);\n }\n });\n });\n }\n };\n\n \/**\n * Get the activity completion confirmation modal.\n *\n * @param {array} id instance id\n * @param {int} contextid Context ID\n *\/\n const getModal = function (id, contextid) {\n var args = { id: id };\n\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: Str.get_string('confirmation', 'pulse'),\n body: '',\n large: false\n }).then(function (modal) {\n modal.show();\n\n Fragment.loadFragment('mod_pulse', 'get_confirmation_content', contextid, args).then(function (html) {\n modal.setBody(html);\n return html;\n }).catch(notification.exception);\n\n modal.setButtonText('save', Str.get_string('yes'));\n\n modal.getRoot().on(ModalEvents.save, function (e) {\n e.preventDefault();\n submitformdata(args);\n modal.getRoot().find('form').submit();\n modal.hide();\n });\n\n modal.getRoot().on(ModalEvents.hidden, function () {\n modal.destroy();\n });\n\n return modal;\n }).catch(notification.exception);\n };\n\n \/**\n * Submit and recieve the message form the modal confirmation on the activity completion.\n *\n * @param {string} params\n *\/\n const submitformdata = function (params) {\n Ajax.call([{\n methodname: 'mod_pulse_manual_completion',\n args: params,\n done: function (response) {\n window.location.reload();\n if (response.message) {\n notification.addNotification({\n message: response.message,\n type: \"success\"\n });\n }\n }\n }]);\n };\n\n return {\n init: function (contextid) {\n ButtonConfirmation(contextid);\n },\n };\n }));\n"],"names":["define","$","Str","ModalFactory","notification","Ajax","Fragment","ModalEvents","getModal","id","contextid","args","create","type","types","SAVE_CANCEL","title","get_string","body","large","then","modal","show","loadFragment","html","setBody","catch","exception","setButtonText","getRoot","on","save","e","preventDefault","submitformdata","find","submit","hide","hidden","destroy","params","call","methodname","done","response","window","location","reload","message","addNotification","init","document","classList","contains","querySelectorAll","forEach","element","addEventListener","target","className","match","ButtonConfirmation"],"mappings":";;;;;;;AAuBAA,qCAAO,CAAC,SAAU,WAAY,qBAAsB,oBAAqB,YAAa,gBAAiB,sBAClG,SAAUC,EAAGC,IAAKC,aAAcC,aAAcC,KAAMC,SAAUC,mBA4BrDC,SAAW,SAAUC,GAAIC,eACvBC,KAAO,CAAEF,GAAIA,IAEjBN,aAAaS,OAAO,CAChBC,KAAMV,aAAaW,MAAMC,YACzBC,MAAOd,IAAIe,WAAW,eAAgB,SACtCC,KAAM,GACNC,OAAO,IACRC,MAAK,SAAUC,cACdA,MAAMC,OAENhB,SAASiB,aAAa,YAAa,2BAA4Bb,UAAWC,MAAMS,MAAK,SAAUI,aAC3FH,MAAMI,QAA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