MDL-66076 forumreport_summary: Groups filter made accessible
[moodle.git] / mod / forum / report / summary / amd / build / filters.min.js.map
CommitLineData
cc15134c 1{"version":3,"sources":["../src/filters.js"],"names":["init","root","document","ready","hide","removeClass","clearAll","event","selected","target","parentNode","parentElement","querySelectorAll","forEach","checkbox","checked","on","preventDefault","generateWithFilters","newLink","attr","filterParams","search","substr","submit","selectAll","checkboxdiv","targetdiv","getElementById","deselected","submitWithFilter","containerelement","addClass","referenceElement","querySelector","popperContent","Popper","placement","groupsbutton","groupspopover","classList","remove","setAttribute","add","focus","charCode","keyCode","length"],"mappings":"qKAwBA,OACA,O,mDAEO,GAAMA,CAAAA,CAAI,CAAG,SAACC,CAAD,CAAU,CAC1BA,CAAI,CAAG,cAAEA,CAAF,CAAP,CAIA,cAAEC,QAAF,EAAYC,KAAZ,CAAkB,UAAW,CACzB,cAAE,eAAF,EAAmBC,IAAnB,GACA,cAAE,gBAAF,EAAoBC,WAApB,CAAgC,QAAhC,CACH,CAHD,EAQA,GAAIC,CAAAA,CAAQ,CAAG,SAACC,CAAD,CAAW,CAEtB,GAAIC,CAAAA,CAAQ,CAAGD,CAAK,CAACE,MAAN,CAAaC,UAAb,CAAwBA,UAAxB,CAAmCC,aAAnC,CAAiDC,gBAAjD,CAAkE,kCAAlE,CAAf,CAEAJ,CAAQ,CAACK,OAAT,CAAiB,SAASC,CAAT,CAAmB,CAChCA,CAAQ,CAACC,OAAT,GACH,CAFD,CAGH,CAPD,CAUA,cAAEd,CAAF,EAAQe,EAAR,CAAW,OAAX,CAAoB,eAApB,CAAqC,SAAST,CAAT,CAAgB,CACjDA,CAAK,CAACU,cAAN,GACAX,CAAQ,CAACC,CAAD,CACX,CAHD,EAMA,GAAIW,CAAAA,CAAmB,CAAG,SAACX,CAAD,CAAW,CACjC,GAAIY,CAAAA,CAAO,CAAG,cAAE,cAAF,EAAkBC,IAAlB,CAAuB,QAAvB,CAAd,CAEA,GAAIb,CAAJ,CAAW,CACPA,CAAK,CAACU,cA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CAAuB,CAAvB,CAAP,EACI,IAAK,YAAL,CACIf,CAAS,CAAC,uBAAD,CAAT,CACA,MACJ,IAAK,cAAL,CACInB,CAAQ,CAACC,CAAD,CAAR,CACA,MACJ,IAAK,aAAL,CACIuB,CAAgB,CAAC,wBAAD,CAAhB,CACA,MATR,CAWH,CACJ,CAjBD,CAkBH,CAhIM,C","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 * Module responsible for handling forum summary report filters.\n *\n * @module forumreport_summary/filters\n * @package forumreport_summary\n * @copyright 2019 Michael Hawkins <michaelh@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Popper from 'core/popper';\n\nexport const init = (root) => {\n root = $(root);\n\n // Hide loading spinner and show report once page is ready.\n // This ensures filters can be applied when sorting by columns.\n $(document).ready(function() {\n $('.loading-icon').hide();\n $('#summaryreport').removeClass('hidden');\n });\n\n // Generic filter handlers.\n\n // Called to clear filters.\n var clearAll = (event) => {\n // Clear checkboxes.\n let selected = event.target.parentNode.parentNode.parentElement.querySelectorAll('input[type=\"checkbox\"]:checked');\n\n selected.forEach(function(checkbox) {\n checkbox.checked = false;\n });\n };\n\n // Event handler for clearing filter by clicking option.\n $(root).on(\"click\", \".filter-clear\", function(event) {\n event.preventDefault();\n clearAll(event);\n });\n\n // Called to override click event to trigger a proper generate request with filtering.\n var generateWithFilters = (event) => {\n var newLink = $('#filtersform').attr('action');\n\n if (event) {\n event.preventDefault();\n\n let filterParams = event.target.search.substr(1);\n newLink += '&' + filterParams;\n }\n\n $('#filtersform').attr('action', newLink);\n $('#filtersform').submit();\n };\n\n // Override 'reset table preferences' so it generates with filters.\n $('.resettable').on(\"click\", \"a\", function(event) {\n generateWithFilters(event);\n });\n\n // Override table heading sort links so they generate with filters.\n $('thead').on(\"click\", \"a\", function(event) {\n generateWithFilters(event);\n });\n\n // Override pagination page links so they generate with filters.\n $('.pagination').on(\"click\", \"a\", function(event) {\n generateWithFilters(event);\n });\n\n // Select all checkboxes within a filter section.\n var selectAll = (checkboxdiv) => {\n let targetdiv = document.getElementById(checkboxdiv);\n let deselected = targetdiv.querySelectorAll('input[type=\"checkbox\"]:not(:checked)');\n\n deselected.forEach(function(checkbox) {\n checkbox.checked = true;\n });\n };\n\n // Submit report via filter\n var submitWithFilter = (containerelement) => {\n // Close the container (eg popover).\n $(containerelement).addClass('hidden');\n\n // Submit the filter values and re-generate report.\n generateWithFilters(false);\n };\n\n // Groups filter specific handlers.\n\n // Event handler for clicking select all groups.\n $('#filter-groups-popover .select-all').on('click', function(event) {\n event.preventDefault();\n selectAll('filter-groups-popover');\n });\n\n // Event handler for showing groups filter popover.\n $('#filter-groups-button').on('click', function() {\n // Create popover.\n var referenceElement = document.querySelector('#filter-groups-button'),\n popperContent = document.querySelector('#filter-groups-popover');\n\n new Popper(referenceElement, popperContent, {placement: 'bottom'});\n\n // Show popover and switch focus.\n var groupsbutton = document.getElementById('filter-groups-button'),\n groupspopover = document.getElementById('filter-groups-popover');\n groupspopover.classList.remove('hidden');\n groupsbutton.setAttribute('aria-expanded', true);\n groupsbutton.classList.add('btn-outline-primary');\n groupsbutton.classList.remove('btn-primary');\n groupspopover.querySelector('input').focus();\n });\n\n // Event handler to click save groups filter.\n $(root).on(\"click\", \"#filter-groups-popover .filter-save\", function(event) {\n event.preventDefault();\n submitWithFilter('#filter-groups-popover');\n });\n\n // Event handler to support pressing enter/space on groups filter popover actions.\n $('#filter-groups-popover').on(\"keydown\", \".filter-actions\", function(event) {\n if ((event.charCode === 13 || event.keyCode === 13 || event.charCode === 32 || event.keyCode === 32)\n && event.target.classList.length > 0) {\n event.preventDefault();\n\n switch(event.target.classList[0]) {\n case 'select-all':\n selectAll('filter-groups-popover');\n break;\n case 'filter-clear':\n clearAll(event);\n break;\n case 'filter-save':\n submitWithFilter('#filter-groups-popover');\n break;\n }\n }\n });\n};\n"],"file":"filters.min.js"}