AutorÃa | Ultima modificación | Ver Log |
{"version":3,"file":"index.min.js","sources":["../src/index.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 * @module core_group/index\n * @copyright 2022 Matthew Hilton <matthewhilton@catalyst-au.net>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport GroupPicker from \"./grouppicker\";\n\nconst grou
pPicker = new GroupPicker();\n\n/**\n * Initialise page.\n */\nexport const init = () => {\n // Init event listeners.\n groupPicker.getDomElement().addEventListener(\"change\", updateBulkActionButtons);\n\n // Call initially to set initial button state.\n updateBulkActionButtons();\n};\n\n/**\n * Updates the bulk action buttons depending on specific conditions.\n */\nexport const updateBulkActionButtons = () => {\n const groupsSelected = groupPicker.getSelectedValues();\n const aGroupIsSelected = groupsSelected.length !== 0;\n\n // Collate the conditions where each button is enabled/disabled.\n const bulkActionsEnabledStatuses = {\n 'enablemessaging': aGroupIsSelected,\n 'disablemessaging': aGroupIsSelected\n };\n\n // Update the status of each button.\n Object.entries(bulkActionsEnabledStatuses).map(([buttonId, enabled]) => setElementEnabled(buttonId, enabled));\n};\n\n/**\n * Adds or removes the given element's disabled attribute.\n * @param {string} domElemen
tId ID of the dom element (without the #)\n * @param {bool} enabled If false, the disable attribute is applied, else it is removed.\n */\nexport const setElementEnabled = (domElementId, enabled) => {\n const element = document.getElementById(domElementId);\n\n if (!element) {\n // If there is no element, we do nothing.\n // The element could be purposefully hidden or removed.\n return;\n }\n\n if (!enabled) {\n element.setAttribute('disabled', 'disabled');\n } else {\n element.removeAttribute('disabled');\n }\n};\n"],"names":["groupPicker","getDomElement","addEventListener","updateBulkActionButtons","aGroupIsSelected","getSelectedValues","length","bulkActionsEnabledStatuses","Object","entries","map","_ref","buttonId","enabled","setElementEnabled","domElementId","element","document","getElementById","removeAttribute","setAttribute"],"mappings":";;;;;oJAsBMA,YAAc,6FAKA,KAEhBA,YAAYC,gBAAgBC,iBAAiB,SAAUC,yBAGvDA,iCAMSA,wBAA0B,WAE7BC,iBAA6C,IAD5BJ,YAAYK,oBACKC,
OAGlCC,2BAA6B,iBACZH,kCACCA,kBAIxBI,OAAOC,QAAQF,4BAA4BG,KAAIC,WAAEC,SAAUC,qBAAaC,kBAAkBF,SAAUC,4EAQ3FC,kBAAoB,CAACC,aAAcF,iBACtCG,QAAUC,SAASC,eAAeH,cAEnCC,UAMAH,QAGDG,QAAQG,gBAAgB,YAFxBH,QAAQI,aAAa,WAAY"}