MDL-66890 forumreport_summary: Improved filter close keyboard response
[moodle.git] / mod / forum / report / summary / amd / build / filters.min.js.map
1 {"version":3,"sources":["../src/filters.js"],"names":["init","root","jqRoot","document","ready","hide","removeClass","generateWithFilters","event","newLink","attr","preventDefault","filterParams","target","search","substr","submit","on","submitWithFilter","containerelement","Y","use","M","core_formchangechecker","reset_form_dirty_state","addClass","updateCalendarPosition","referenceid","referenceElement","querySelector","popperContent","Selectors","filters","date","calendar","style","removeProperty","Popper","placement","closeOpenFilters","openFilterButton","openFilter","classList","add","setAttribute","remove","CustomEvents","events","activate","group","selectall","deselected","querySelectorAll","checkbox","forEach","checked","clear","selected","trigger","popover","closeListener","e","id","closest","keyCode","KeyCodes","enter","space","removeEventListener","escCloseListener","addEventListener","escape","save","popcheckboxes","popcheckbox","filtersform","forms","saveid","getAttribute","focus","filtersForm","datesPopover","fromEnabled","toEnabled","elements","value","args","data","push","Ajax","call","methodname","done","result","fromTimestamp","toTimestamp","key","timestamp","warningdiv","getElementById","calendariconfrom","calendariconto"],"mappings":"wRAwBA,OACA,OACA,OACA,OACA,OACA,OACA,O,mDAEO,GAAMA,CAAAA,CAAI,CAAG,SAACC,CAAD,CAAU,CAC1B,GAAIC,CAAAA,CAAM,CAAG,cAAED,CAAF,CAAb,CAIA,cAAEE,QAAF,EAAYC,KAAZ,CAAkB,UAAW,CACzB,cAAE,eAAF,EAAmBC,IAAnB,GACA,cAAE,gBAAF,EAAoBC,WAApB,CAAgC,QAAhC,CACH,CAHD,EAQA,GAAMC,CAAAA,CAAmB,CAAG,SAACC,CAAD,CAAW,CACnC,GAAIC,CAAAA,CAAO,CAAG,cAAE,cAAF,EAAkBC,IAAlB,CAAuB,QAAvB,CAAd,CAEA,GAAIF,CAAJ,CAAW,CACPA,CAAK,CAACG,cAAN,GAEA,GAAIC,CAAAA,CAAY,CAAGJ,CAAK,CAACK,MAAN,CAAaC,MAAb,CAAoBC,MAApB,CAA2B,CAA3B,CAAnB,CACAN,CAAO,EAAI,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AACgG,cAAT,CAAwB,sBAAxB,CAAnB,CACAD,CAAU,CAACxD,SAAX,CAAqBG,MAArB,CAA4B,QAA5B,EACAqD,CAAU,CAACxD,SAAX,CAAqBC,GAArB,CAAyB,SAAzB,CACH,CAJD,IAIO,CACHqC,CAAW,CAACI,QAAZ,CAAqB,qBAArB,EAA4CC,KAA5C,CAAoDS,CAApD,CACAd,CAAW,CAACI,QAAZ,CAAqB,mBAArB,EAA0CC,KAA1C,CAAkDH,CAAlD,CACAF,CAAW,CAACI,QAAZ,CAAqB,mBAArB,EAA0CC,KAA1C,CAAkDU,CAAlD,CACAf,CAAW,CAACI,QAAZ,CAAqB,iBAArB,EAAwCC,KAAxC,CAAgDF,CAAhD,CAGAjE,CAAgB,CAAC,uBAAD,CACnB,CACJ,CA1BD,CA2BH,CACJ,CA1ED,EA4EAhB,CAAM,CAACe,EAAP,CAAU6B,UAAaC,MAAb,CAAoBC,QAA9B,CAAwCjB,UAAUC,OAAV,CAAkBC,IAAlB,CAAuBmE,gBAA/D,CAAiF,UAAW,CACxF1E,CAAsB,CAACK,UAAUC,OAAV,CAAkBC,IAAlB,CAAuBmE,gBAAxB,CACzB,CAFD,EAIAlG,CAAM,CAACe,EAAP,CAAU6B,UAAaC,MAAb,CAAoBC,QAA9B,CAAwCjB,UAAUC,OAAV,CAAkBC,IAAlB,CAAuBoE,cAA/D,CAA+E,UAAW,CACtF3E,CAAsB,CAACK,UAAUC,OAAV,CAAkBC,IAAlB,CAAuBoE,cAAxB,CACzB,CAFD,CAGH,CA7RM,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';\nimport CustomEvents from 'core/custom_interaction_events';\nimport Selectors from 'forumreport_summary/selectors';\nimport Y from 'core/yui';\nimport Ajax from 'core/ajax';\nimport KeyCodes from 'core/key_codes';\n\nexport const init = (root) => {\n    let jqRoot = $(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 override click event to trigger a proper generate request with filtering.\n    const generateWithFilters = (event) => {\n        let 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    // Submit report via filter\n    const submitWithFilter = (containerelement) => {\n        // Disable the dates filter mform checker to prevent any changes triggering a warning to the user.\n        Y.use('moodle-core-formchangechecker', function() {\n            M.core_formchangechecker.reset_form_dirty_state();\n        });\n\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    // Use popper to override date mform calendar position.\n    const updateCalendarPosition = (referenceid) => {\n        let referenceElement = document.querySelector(referenceid),\n            popperContent = document.querySelector(Selectors.filters.date.calendar);\n\n        popperContent.style.removeProperty(\"z-index\");\n        new Popper(referenceElement, popperContent, {placement: 'bottom'});\n    };\n\n    // Close the relevant filter.\n    const closeOpenFilters = (openFilterButton, openFilter) => {\n        openFilter.classList.add('hidden');\n        openFilter.setAttribute('data-openfilter', 'false');\n\n        openFilterButton.classList.add('btn-primary');\n        openFilterButton.classList.remove('btn-outline-primary');\n        openFilterButton.setAttribute('aria-expanded', false);\n    };\n\n    // Groups filter specific handlers.\n\n    // Event handler for clicking select all groups.\n    jqRoot.on(CustomEvents.events.activate, Selectors.filters.group.selectall, function() {\n        let deselected = root.querySelectorAll(Selectors.filters.group.checkbox + ':not(:checked)');\n        deselected.forEach(function(checkbox) {\n            checkbox.checked = true;\n        });\n    });\n\n    // Event handler for clearing filter by clicking option.\n    jqRoot.on(CustomEvents.events.activate, Selectors.filters.group.clear, function() {\n        // Clear checkboxes.\n        let selected = root.querySelectorAll(Selectors.filters.group.checkbox + ':checked');\n        selected.forEach(function(checkbox) {\n            checkbox.checked = false;\n        });\n    });\n\n    // Event handler for showing groups filter popover.\n    jqRoot.on(CustomEvents.events.activate, Selectors.filters.group.trigger, function() {\n        // Create popover.\n        let referenceElement = root.querySelector(Selectors.filters.group.trigger),\n            popperContent = root.querySelector(Selectors.filters.group.popover);\n\n        new Popper(referenceElement, popperContent, {placement: 'bottom'});\n\n        // Show popover.\n        popperContent.classList.remove('hidden');\n        popperContent.setAttribute('data-openfilter', 'true');\n\n        // Change to outlined button.\n        referenceElement.classList.add('btn-outline-primary');\n        referenceElement.classList.remove('btn-primary');\n\n        // Let screen readers know that it's now expanded.\n        referenceElement.setAttribute('aria-expanded', true);\n\n        // Add listeners to handle closing filter.\n        const closeListener = e => {\n            if (e.target.id !== referenceElement.id && popperContent !== e.target.closest('[data-openfilter=\"true\"]') &&\n                    (typeof e.keyCode === 'undefined' || e.keyCode === KeyCodes.enter || e.keyCode === KeyCodes.space)) {\n                closeOpenFilters(referenceElement, popperContent);\n                document.removeEventListener('click', closeListener);\n                document.removeEventListener('keyup', closeListener);\n                document.removeEventListener('keyup', escCloseListener);\n            }\n        };\n\n        document.addEventListener('click', closeListener);\n        document.addEventListener('keyup', closeListener);\n\n        const escCloseListener = e => {\n            if (e.keyCode === KeyCodes.escape) {\n                closeOpenFilters(referenceElement, popperContent);\n                document.removeEventListener('keyup', escCloseListener);\n                document.removeEventListener('click', closeListener);\n            }\n        };\n\n        document.addEventListener('keyup', escCloseListener);\n    });\n\n    // Event handler to click save groups filter.\n    jqRoot.on(CustomEvents.events.activate, Selectors.filters.group.save, function() {\n        // Copy the saved values into the form before submitting.\n        let popcheckboxes = root.querySelectorAll(Selectors.filters.group.checkbox);\n\n        popcheckboxes.forEach(function(popcheckbox) {\n            let filtersform = document.forms.filtersform,\n                saveid = popcheckbox.getAttribute('data-saveid');\n\n            filtersform.querySelector(`#${saveid}`).checked = popcheckbox.checked;\n        });\n\n        submitWithFilter('#filter-groups-popover');\n    });\n\n    // Dates filter specific handlers.\n\n   // Event handler for showing dates filter popover.\n    jqRoot.on(CustomEvents.events.activate, Selectors.filters.date.trigger, function() {\n\n        // Create popover.\n        let referenceElement = root.querySelector(Selectors.filters.date.trigger),\n            popperContent = root.querySelector(Selectors.filters.date.popover);\n\n        new Popper(referenceElement, popperContent, {placement: 'bottom'});\n\n        // Show popover and move focus.\n        popperContent.classList.remove('hidden');\n        popperContent.setAttribute('data-openfilter', 'true');\n        popperContent.querySelector('[name=\"filterdatefrompopover[enabled]\"]').focus();\n\n        // Change to outlined button.\n        referenceElement.classList.add('btn-outline-primary');\n        referenceElement.classList.remove('btn-primary');\n\n        // Let screen readers know that it's now expanded.\n        referenceElement.setAttribute('aria-expanded', true);\n\n        // Add listener to handle closing filter.\n        const closeListener = e => {\n            if (e.target.id !== referenceElement.id && popperContent !== e.target.closest('[data-openfilter=\"true\"]') &&\n                    (typeof e.keyCode === 'undefined' || e.keyCode === KeyCodes.enter || e.keyCode === KeyCodes.space)) {\n                closeOpenFilters(referenceElement, popperContent);\n                document.removeEventListener('click', closeListener);\n                document.removeEventListener('keyup', closeListener);\n                document.removeEventListener('keyup', escCloseListener);\n            }\n        };\n\n        document.addEventListener('click', closeListener);\n        document.addEventListener('keyup', closeListener);\n\n        const escCloseListener = e => {\n            if (e.keyCode === KeyCodes.escape) {\n                closeOpenFilters(referenceElement, popperContent);\n                document.removeEventListener('keyup', escCloseListener);\n                document.removeEventListener('click', closeListener);\n            }\n        };\n\n        document.addEventListener('keyup', escCloseListener);\n    });\n\n    // Event handler to save dates filter.\n    jqRoot.on(CustomEvents.events.activate, Selectors.filters.date.save, function() {\n        // Populate the hidden form inputs to submit the data.\n        let filtersForm = document.forms.filtersform;\n        const datesPopover = root.querySelector(Selectors.filters.date.popover);\n        const fromEnabled = datesPopover.querySelector('[name=\"filterdatefrompopover[enabled]\"]').checked ? 1 : 0;\n        const toEnabled = datesPopover.querySelector('[name=\"filterdatetopopover[enabled]\"]').checked ? 1 : 0;\n\n        if (!fromEnabled && !toEnabled) {\n            // Update the elements in the filter form.\n            filtersForm.elements['datefrom[timestamp]'].value = 0;\n            filtersForm.elements['datefrom[enabled]'].value = fromEnabled;\n            filtersForm.elements['dateto[timestamp]'].value = 0;\n            filtersForm.elements['dateto[enabled]'].value = toEnabled;\n\n            // Submit the filter values and re-generate report.\n            submitWithFilter('#filter-dates-popover');\n        } else {\n            let args = {data: []};\n\n            if (fromEnabled) {\n                args.data.push({\n                    'key': 'from',\n                    'year': datesPopover.querySelector('[name=\"filterdatefrompopover[year]\"]').value,\n                    'month': datesPopover.querySelector('[name=\"filterdatefrompopover[month]\"]').value,\n                    'day': datesPopover.querySelector('[name=\"filterdatefrompopover[day]\"]').value,\n                    'hour': 0,\n                    'minute': 0\n                });\n            }\n\n            if (toEnabled) {\n                args.data.push({\n                    'key': 'to',\n                    'year': datesPopover.querySelector('[name=\"filterdatetopopover[year]\"]').value,\n                    'month': datesPopover.querySelector('[name=\"filterdatetopopover[month]\"]').value,\n                    'day': datesPopover.querySelector('[name=\"filterdatetopopover[day]\"]').value,\n                    'hour': 23,\n                    'minute': 59\n                });\n            }\n\n            const request = {\n                methodname: 'core_calendar_get_timestamps',\n                args: args\n            };\n\n            Ajax.call([request])[0].done(function(result) {\n                let fromTimestamp = 0,\n                    toTimestamp = 0;\n\n                result['timestamps'].forEach(function(data){\n                    if (data.key === 'from') {\n                        fromTimestamp = data.timestamp;\n                    } else if (data.key === 'to') {\n                        toTimestamp = data.timestamp;\n                    }\n                });\n\n                // Display an error if the from date is later than the do date.\n                if (toTimestamp > 0 && fromTimestamp > toTimestamp) {\n                    const warningdiv = document.getElementById('dates-filter-warning');\n                    warningdiv.classList.remove('hidden');\n                    warningdiv.classList.add('d-block');\n                } else {\n                    filtersForm.elements['datefrom[timestamp]'].value = fromTimestamp;\n                    filtersForm.elements['datefrom[enabled]'].value = fromEnabled;\n                    filtersForm.elements['dateto[timestamp]'].value = toTimestamp;\n                    filtersForm.elements['dateto[enabled]'].value = toEnabled;\n\n                    // Submit the filter values and re-generate report.\n                    submitWithFilter('#filter-dates-popover');\n                }\n            });\n        }\n    });\n\n    jqRoot.on(CustomEvents.events.activate, Selectors.filters.date.calendariconfrom, function() {\n        updateCalendarPosition(Selectors.filters.date.calendariconfrom);\n    });\n\n    jqRoot.on(CustomEvents.events.activate, Selectors.filters.date.calendariconto, function() {\n        updateCalendarPosition(Selectors.filters.date.calendariconto);\n    });\n};\n"],"file":"filters.min.js"}