/
var
/
www
/
html
/
lgpd
/
user
/
amd
/
build
/
Upload File
HOME
{"version":3,"sources":["../src/unified_filter.js"],"names":["define","$","Autocomplete","Str","Notification","SELECTORS","UNIFIED_FILTERS","init","M","util","js_pending","get_strings","key","component","done","langstrings","placeholder","noSelectionString","enhance","then","js_complete","fail","exception","last","val","on","current","listoffilters","textfilters","updatedselectedfilters","each","index","catoption","catandoption","split","length","push","category","option","updatefilters","concat","join","form","submit","getForm","closest"],"mappings":"AAuBAA,OAAM,4BAAC,CAAC,QAAD,CAAW,wBAAX,CAAqC,UAArC,CAAiD,mBAAjD,CAAD,CACE,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAA+BC,CAA/B,CAA6C,IAQ7CC,CAAAA,CAAS,CAAG,CACZC,eAAe,CAAE,kBADL,CARiC,CAkB7CC,CAAI,CAAG,QAAPA,CAAAA,IAAO,EAAW,CAYlBC,CAAC,CAACC,IAAF,CAAOC,UAAP,CAAkB,2BAAlB,EACAP,CAAG,CAACQ,WAAJ,CAZiB,CACb,CACIC,GAAG,CAAE,uBADT,CAEIC,SAAS,CAAE,QAFf,CADa,CAKb,CACID,GAAG,CAAE,kBADT,CAEIC,SAAS,CAAE,QAFf,CALa,CAYjB,EAA4BC,IAA5B,CAAiC,SAASC,CAAT,CAAsB,IAC/CC,CAAAA,CAAW,CAAGD,CAAW,CAAC,CAAD,CADsB,CAE/CE,CAAiB,CAAGF,CAAW,CAAC,CAAD,CAFgB,CAGnDb,CAAY,CAACgB,OAAb,CAAqBb,CAAS,CAACC,eAA/B,IAAsD,qCAAtD,CAA6FU,CAA7F,OACiBC,CADjB,KAECE,IAFD,CAEM,UAAW,CACbX,CAAC,CAACC,IAAF,CAAOW,WAAP,CAAmB,2BAAnB,CAGH,CAND,EAOCC,IAPD,CAOMjB,CAAY,CAACkB,SAPnB,CAQH,CAXD,EAWGD,IAXH,CAWQjB,CAAY,CAACkB,SAXrB,EAaA,GAAIC,CAAAA,CAAI,CAAGtB,C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,CAAO,CAACe,IAAR,CAAa,GAAb,CAAtB,CAAyC,CACrC,KAAKC,IAAL,CAAUC,MAAV,EACH,CACJ,CA5CD,CA6CH,CA1FgD,CAkG7CC,CAAO,CAAG,QAAVA,CAAAA,OAAU,EAAW,CACrB,MAAO3C,CAAAA,CAAC,CAACI,CAAS,CAACC,eAAX,CAAD,CAA6BuC,OAA7B,CAAqC,MAArC,CACV,CApGgD,CAsGjD,MAAmD,CAM/CtC,IAAI,CAAE,eAAW,CACbA,CAAI,EACP,CAR8C,CAgB/CqC,OAAO,CAAE,kBAAW,CAChB,MAAOA,CAAAA,CAAO,EACjB,CAlB8C,CAoBtD,CA3HK,CAAN","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 * Unified filter page JS module for the course participants page.\n *\n * @module core_user/unified_filter\n * @package core_user\n * @copyright 2017 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/form-autocomplete', 'core/str', 'core/notification'],\n function($, Autocomplete, Str, Notification) {\n\n /**\n * Selectors.\n *\n * @access private\n * @type {{UNIFIED_FILTERS: string}}\n */\n var SELECTORS = {\n UNIFIED_FILTERS: '#unified-filters'\n };\n\n /**\n * Init function.\n *\n * @method init\n * @private\n */\n var init = function() {\n var stringkeys = [\n {\n key: 'userfilterplaceholder',\n component: 'moodle'\n },\n {\n key: 'nofiltersapplied',\n component: 'moodle'\n }\n ];\n\n M.util.js_pending('unified_filter_datasource');\n Str.get_strings(stringkeys).done(function(langstrings) {\n var placeholder = langstrings[0];\n var noSelectionString = langstrings[1];\n Autocomplete.enhance(SELECTORS.UNIFIED_FILTERS, true, 'core_user/unified_filter_datasource', placeholder,\n false, true, noSelectionString, true)\n .then(function() {\n M.util.js_complete('unified_filter_datasource');\n\n return;\n })\n .fail(Notification.exception);\n }).fail(Notification.exception);\n\n var last = $(SELECTORS.UNIFIED_FILTERS).val();\n $(SELECTORS.UNIFIED_FILTERS).on('change', function() {\n var current = $(this).val();\n var listoffilters = [];\n var textfilters = [];\n var updatedselectedfilters = false;\n\n $.each(current, function(index, catoption) {\n var catandoption = catoption.split(':', 2);\n if (catandoption.length !== 2) {\n textfilters.push(catoption);\n return true; // Text search filter.\n }\n\n var category = catandoption[0];\n var option = catandoption[1];\n\n // The last option (eg. 'Teacher') out of a category (eg. 'Role') in this loop is the one that was last\n // selected, so we want to use that if there are multiple options from the same category. Eg. The user\n // may have chosen to filter by the 'Student' role, then wanted to filter by the 'Teacher' role - the\n // last option in the category to be selected (in this case 'Teacher') will come last, so will overwrite\n // 'Student' (after this if). We want to let the JS know that the filters have been updated.\n if (typeof listoffilters[category] !== 'undefined') {\n updatedselectedfilters = true;\n }\n\n listoffilters[category] = option;\n return true;\n });\n\n // Check if we have something to remove from the list of filters.\n if (updatedselectedfilters) {\n // Go through and put the list into something we can use to update the list of filters.\n var updatefilters = [];\n for (var category in listoffilters) {\n updatefilters.push(category + \":\" + listoffilters[category]);\n }\n updatefilters = updatefilters.concat(textfilters);\n $(this).val(updatefilters);\n }\n\n // Prevent form from submitting unnecessarily, eg. on blur when no filter is selected.\n if (last.join(',') != current.join(',')) {\n this.form.submit();\n }\n });\n };\n\n /**\n * Return the unified user filter form.\n *\n * @method getForm\n * @return {DOMElement}\n */\n var getForm = function() {\n return $(SELECTORS.UNIFIED_FILTERS).closest('form');\n };\n\n return /** @alias module:core/form-autocomplete */ {\n /**\n * Initialise the unified user filter.\n *\n * @method init\n */\n init: function() {\n init();\n },\n\n /**\n * Return the unified user filter form.\n *\n * @method getForm\n * @return {DOMElement}\n */\n getForm: function() {\n return getForm();\n }\n };\n});\n"],"file":"unified_filter.min.js"}