AutorÃa | Ultima modificación | Ver Log |
{"version":3,"file":"admin.min.js","sources":["../src/admin.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 * Comments admin management\n *\n * @module core_comment/admin\n * @copyright 2022 Paul Holden <paulh@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n\"use strict\";\n\nimport {disp
atchEvent} from 'core/event_dispatcher';\nimport Notification from 'core/notification';\nimport Pending from 'core/pending';\nimport {prefetchStrings} from 'core/prefetch';\nimport {getString} from 'core/str';\nimport {deleteComment, deleteComments} from 'core_comment/repository';\nimport * as reportEvents from 'core_reportbuilder/local/events';\nimport * as reportSelectors from 'core_reportbuilder/local/selectors';\n\nconst Selectors = {\n commentDelete: '[data-action=\"comment-delete\"]',\n commentDeleteChecked: '[data-togglegroup=\"report-select-all\"][data-toggle=\"slave\"]:checked',\n commentDeleteSelected: '[data-action=\"comment-delete-selected\"]',\n};\n\n/**\n * Initialise module\n */\nexport const init = () => {\n prefetchStrings('core_admin', [\n 'confirmdeletecomments',\n ]);\n\n prefetchStrings('core', [\n 'delete',\n 'deleteselected'\n ]);\n\n document.addEventListener('click', event => {\n const commentDelete = event.target.closest(Selectors.
commentDelete);\n if (commentDelete) {\n event.preventDefault();\n\n // Use triggerElement to return focus to the action menu toggle.\n const triggerElement = commentDelete.closest('.dropdown').querySelector('.dropdown-toggle');\n Notification.saveCancelPromise(\n getString('delete', 'core'),\n getString('confirmdeletecomments', 'core_admin'),\n getString('delete', 'core'),\n {triggerElement}\n ).then(() => {\n const pendingPromise = new Pending('core_comment/comment:delete');\n const reportElement = event.target.closest(reportSelectors.regions.report);\n\n return deleteComment(commentDelete.dataset.commentId)\n .then(() => {\n dispatchEvent(reportEvents.tableReload, {preservePagination: true}, reportElement);\n return pendingPromise.resolve();\n })\n
.catch(Notification.exception);\n }).catch(() => {\n return;\n });\n }\n\n const commentDeleteSelected = event.target.closest(Selectors.commentDeleteSelected);\n if (commentDeleteSelected) {\n event.preventDefault();\n\n const reportElement = document.querySelector(reportSelectors.regions.report);\n const commentDeleteChecked = reportElement.querySelectorAll(Selectors.commentDeleteChecked);\n if (commentDeleteChecked.length === 0) {\n return;\n }\n\n Notification.saveCancelPromise(\n getString('deleteselected', 'core'),\n getString('confirmdeletecomments', 'core_admin'),\n getString('delete', 'core'),\n {triggerElement: commentDeleteSelected}\n ).then(() => {\n const pendingPromise = new Pending('core_comment/comments:delete');\n const deleteCommentIds = [...comme
ntDeleteChecked].map(check => check.value);\n\n return deleteComments(deleteCommentIds)\n .then(() => {\n dispatchEvent(reportEvents.tableReload, {preservePagination: true}, reportElement);\n return pendingPromise.resolve();\n })\n .catch(Notification.exception);\n }).catch(() => {\n return;\n });\n }\n });\n};\n"],"names":["Selectors","document","addEventListener","event","commentDelete","target","closest","preventDefault","triggerElement","querySelector","saveCancelPromise","then","pendingPromise","Pending","reportElement","reportSelectors","regions","report","dataset","commentId","reportEvents","tableReload","preservePagination","resolve","catch","Notification","exception","commentDeleteSelected","commentDeleteChecked","querySelectorAll","length","deleteCommentIds","map","check","value"],"mappings":"0nDAkCMA,wBACa,iCADbA,+BAEoB,sEAFpBA,gCAGqB,
wDAMP,mCACA,aAAc,CAC1B,wDAGY,OAAQ,CACpB,SACA,mBAGJC,SAASC,iBAAiB,SAASC,cACzBC,cAAgBD,MAAME,OAAOC,QAAQN,4BACvCI,cAAe,CACfD,MAAMI,uBAGAC,eAAiBJ,cAAcE,QAAQ,aAAaG,cAAc,0CAC3DC,mBACT,kBAAU,SAAU,SACpB,kBAAU,wBAAyB,eACnC,kBAAU,SAAU,QACpB,CAACF,eAAAA,iBACHG,MAAK,WACGC,eAAiB,IAAIC,iBAAQ,+BAC7BC,cAAgBX,MAAME,OAAOC,QAAQS,gBAAgBC,QAAQC,eAE5D,6BAAcb,cAAcc,QAAQC,WACtCR,MAAK,yCACYS,aAAaC,YAAa,CAACC,oBAAoB,GAAOR,eAC7DF,eAAeW,aAEzBC,MAAMC,sBAAaC,cACzBF,OAAM,eAKPG,sBAAwBxB,MAAME,OAAOC,QAAQN,oCAC/C2B,sBAAuB,CACvBxB,MAAMI,uBAEAO,cAAgBb,SAASQ,cAAcM,gBAAgBC,QAAQC,QAC/DW,qBAAuBd,cAAce,iBAAiB7B,mCACxB,IAAhC4B,qBAAqBE,oCAIZpB,mBACT,kBAAU,iBAAkB,SAC5B,kBAAU,wBAAyB,eACnC,kBAAU,SAAU,QACpB,CAACF,eAAgBmB,wBACnBhB,MAAK,WACGC,eAAiB,IAAIC,iBAAQ,gCAC7BkB,iBAAmB,IAAIH,sBAAsBI,KAAIC,OAASA,MAAMC,eAE/D,8BAAeH,kBACjBpB,MAAK,yCACYS,aAAaC,YAAa,CAACC,oBAAoB,GAAOR,eAC7DF,eAAeW,aAEzBC,MAAMC,sBAAaC,cACzBF,OAAM"}