mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-68868 core_user: Final deprecation of participants unified filter
This commit is contained in:
parent
24f97edd91
commit
7a9de2cb24
10 changed files with 7 additions and 591 deletions
11
user/amd/build/unified_filter.min.js
vendored
11
user/amd/build/unified_filter.min.js
vendored
|
@ -1,11 +0,0 @@
|
|||
/**
|
||||
* Unified filter page JS module for the course participants page.
|
||||
*
|
||||
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
|
||||
* @module core_user/unified_filter
|
||||
* @copyright 2017 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define("core_user/unified_filter",["jquery","core/form-autocomplete","core/str","core/notification"],(function($,Autocomplete,Str,Notification){var SELECTORS_UNIFIED_FILTERS="#unified-filters";return{init:function(){!function(){M.util.js_pending("unified_filter_datasource"),Str.get_strings([{key:"userfilterplaceholder",component:"moodle"},{key:"nofiltersapplied",component:"moodle"}]).done((function(langstrings){var placeholder=langstrings[0],noSelectionString=langstrings[1];Autocomplete.enhance(SELECTORS_UNIFIED_FILTERS,!0,"core_user/unified_filter_datasource",placeholder,!1,!0,noSelectionString,!0).then((function(){M.util.js_complete("unified_filter_datasource")})).fail(Notification.exception)})).fail(Notification.exception);var last=$(SELECTORS_UNIFIED_FILTERS).val();$(SELECTORS_UNIFIED_FILTERS).on("change",(function(){var current=$(this).val(),listoffilters=[],textfilters=[],updatedselectedfilters=!1;if($.each(current,(function(index,catoption){var catandoption=catoption.split(":",2);if(2!==catandoption.length)return textfilters.push(catoption),!0;var category=catandoption[0],option=catandoption[1];return void 0!==listoffilters[category]&&(updatedselectedfilters=!0),listoffilters[category]=option,!0})),updatedselectedfilters){var updatefilters=[];for(var category in listoffilters)updatefilters.push(category+":"+listoffilters[category]);updatefilters=updatefilters.concat(textfilters),$(this).val(updatefilters)}last.join(",")!=current.join(",")&&this.form.submit()}))}()},getForm:function(){return $(SELECTORS_UNIFIED_FILTERS).closest("form")}}}));
|
||||
|
||||
//# sourceMappingURL=unified_filter.min.js.map
|
File diff suppressed because one or more lines are too long
12
user/amd/build/unified_filter_datasource.min.js
vendored
12
user/amd/build/unified_filter_datasource.min.js
vendored
|
@ -1,12 +0,0 @@
|
|||
/**
|
||||
* Datasource for the core_user/unified_filter.
|
||||
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
|
||||
*
|
||||
* This module is compatible with core/form-autocomplete.
|
||||
*
|
||||
* @copyright 2017 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define("core_user/unified_filter_datasource",["jquery","core/ajax","core/notification"],(function($,Ajax,Notification){return{list:function(selector,query){var filteredOptions=[],el=$(selector),originalOptions=$(selector).data("originaloptionsjson"),selectedFilters=el.val();$.each(originalOptions,(function(index,option){return""!==query.trim()&&-1===option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase())||$.inArray(option.value,selectedFilters)>-1||filteredOptions.push(option),!0}));var deferred=new $.Deferred;return deferred.resolve(filteredOptions),deferred.promise()},processResults:function(selector,results){var options=[];return $.each(results,(function(index,data){options.push({value:data.value,label:data.label})})),options},transport:function(selector,query,callback){this.list(selector,query).then(callback).catch(Notification.exception)}}}));
|
||||
|
||||
//# sourceMappingURL=unified_filter_datasource.min.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"unified_filter_datasource.min.js","sources":["../src/unified_filter_datasource.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 * Datasource for the core_user/unified_filter.\n * @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.\n *\n * This module is compatible with core/form-autocomplete.\n *\n * @copyright 2017 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {\n\n return /** @alias module:core_user/unified_filter_datasource */ {\n /**\n * List filter options.\n *\n * @param {String} selector The select element selector.\n * @param {String} query The query string.\n * @return {Promise}\n */\n list: function(selector, query) {\n var filteredOptions = [];\n\n var el = $(selector);\n var originalOptions = $(selector).data('originaloptionsjson');\n var selectedFilters = el.val();\n $.each(originalOptions, function(index, option) {\n // Skip option if it does not contain the query string.\n if (query.trim() !== '' && option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) === -1) {\n return true;\n }\n // Skip filters that have already been selected.\n if ($.inArray(option.value, selectedFilters) > -1) {\n return true;\n }\n\n filteredOptions.push(option);\n return true;\n });\n\n var deferred = new $.Deferred();\n deferred.resolve(filteredOptions);\n\n return deferred.promise();\n },\n\n /**\n * Process the results for auto complete elements.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {Array} results An array or results.\n * @return {Array} New array of results.\n */\n processResults: function(selector, results) {\n var options = [];\n $.each(results, function(index, data) {\n options.push({\n value: data.value,\n label: data.label\n });\n });\n return options;\n },\n\n /**\n * Source of data for Ajax element.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {String} query The query string.\n * @param {Function} callback A callback function receiving an array of results.\n */\n /* eslint-disable promise/no-callback-in-promise */\n transport: function(selector, query, callback) {\n this.list(selector, query).then(callback).catch(Notification.exception);\n }\n };\n\n});\n"],"names":["define","$","Ajax","Notification","list","selector","query","filteredOptions","el","originalOptions","data","selectedFilters","val","each","index","option","trim","label","toLocaleLowerCase","indexOf","inArray","value","push","deferred","Deferred","resolve","promise","processResults","results","options","transport","callback","then","catch","exception"],"mappings":";;;;;;;;;AAyBAA,6CAAO,CAAC,SAAU,YAAa,sBAAsB,SAASC,EAAGC,KAAMC,oBAEH,CAQ5DC,KAAM,SAASC,SAAUC,WACjBC,gBAAkB,GAElBC,GAAKP,EAAEI,UACPI,gBAAkBR,EAAEI,UAAUK,KAAK,uBACnCC,gBAAkBH,GAAGI,MACzBX,EAAEY,KAAKJ,iBAAiB,SAASK,MAAOC,cAEf,KAAjBT,MAAMU,SAA0F,IAAzED,OAAOE,MAAMC,oBAAoBC,QAAQb,MAAMY,sBAItEjB,EAAEmB,QAAQL,OAAOM,MAAOV,kBAAoB,GAIhDJ,gBAAgBe,KAAKP,SAPV,SAWXQ,SAAW,IAAItB,EAAEuB,gBACrBD,SAASE,QAAQlB,iBAEVgB,SAASG,WAUpBC,eAAgB,SAAStB,SAAUuB,aAC3BC,QAAU,UACd5B,EAAEY,KAAKe,SAAS,SAASd,MAAOJ,MAC5BmB,QAAQP,KAAK,CACTD,MAAOX,KAAKW,MACZJ,MAAOP,KAAKO,WAGbY,SAWXC,UAAW,SAASzB,SAAUC,MAAOyB,eAC5B3B,KAAKC,SAAUC,OAAO0B,KAAKD,UAAUE,MAAM9B,aAAa+B"}
|
|
@ -1,149 +0,0 @@
|
|||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unified filter page JS module for the course participants page.
|
||||
*
|
||||
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
|
||||
* @module core_user/unified_filter
|
||||
* @copyright 2017 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/form-autocomplete', 'core/str', 'core/notification'],
|
||||
function($, Autocomplete, Str, Notification) {
|
||||
|
||||
/**
|
||||
* Selectors.
|
||||
*
|
||||
* @access private
|
||||
* @type {{UNIFIED_FILTERS: string}}
|
||||
*/
|
||||
var SELECTORS = {
|
||||
UNIFIED_FILTERS: '#unified-filters'
|
||||
};
|
||||
|
||||
/**
|
||||
* Init function.
|
||||
*
|
||||
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
|
||||
* @method init
|
||||
* @private
|
||||
*/
|
||||
var init = function() {
|
||||
var stringkeys = [
|
||||
{
|
||||
key: 'userfilterplaceholder',
|
||||
component: 'moodle'
|
||||
},
|
||||
{
|
||||
key: 'nofiltersapplied',
|
||||
component: 'moodle'
|
||||
}
|
||||
];
|
||||
|
||||
M.util.js_pending('unified_filter_datasource');
|
||||
Str.get_strings(stringkeys).done(function(langstrings) {
|
||||
var placeholder = langstrings[0];
|
||||
var noSelectionString = langstrings[1];
|
||||
Autocomplete.enhance(SELECTORS.UNIFIED_FILTERS, true, 'core_user/unified_filter_datasource', placeholder,
|
||||
false, true, noSelectionString, true)
|
||||
.then(function() {
|
||||
M.util.js_complete('unified_filter_datasource');
|
||||
|
||||
return;
|
||||
})
|
||||
.fail(Notification.exception);
|
||||
}).fail(Notification.exception);
|
||||
|
||||
var last = $(SELECTORS.UNIFIED_FILTERS).val();
|
||||
$(SELECTORS.UNIFIED_FILTERS).on('change', function() {
|
||||
var current = $(this).val();
|
||||
var listoffilters = [];
|
||||
var textfilters = [];
|
||||
var updatedselectedfilters = false;
|
||||
|
||||
$.each(current, function(index, catoption) {
|
||||
var catandoption = catoption.split(':', 2);
|
||||
if (catandoption.length !== 2) {
|
||||
textfilters.push(catoption);
|
||||
return true; // Text search filter.
|
||||
}
|
||||
|
||||
var category = catandoption[0];
|
||||
var option = catandoption[1];
|
||||
|
||||
// The last option (eg. 'Teacher') out of a category (eg. 'Role') in this loop is the one that was last
|
||||
// selected, so we want to use that if there are multiple options from the same category. Eg. The user
|
||||
// may have chosen to filter by the 'Student' role, then wanted to filter by the 'Teacher' role - the
|
||||
// last option in the category to be selected (in this case 'Teacher') will come last, so will overwrite
|
||||
// 'Student' (after this if). We want to let the JS know that the filters have been updated.
|
||||
if (typeof listoffilters[category] !== 'undefined') {
|
||||
updatedselectedfilters = true;
|
||||
}
|
||||
|
||||
listoffilters[category] = option;
|
||||
return true;
|
||||
});
|
||||
|
||||
// Check if we have something to remove from the list of filters.
|
||||
if (updatedselectedfilters) {
|
||||
// Go through and put the list into something we can use to update the list of filters.
|
||||
var updatefilters = [];
|
||||
for (var category in listoffilters) {
|
||||
updatefilters.push(category + ":" + listoffilters[category]);
|
||||
}
|
||||
updatefilters = updatefilters.concat(textfilters);
|
||||
$(this).val(updatefilters);
|
||||
}
|
||||
|
||||
// Prevent form from submitting unnecessarily, eg. on blur when no filter is selected.
|
||||
if (last.join(',') != current.join(',')) {
|
||||
this.form.submit();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the unified user filter form.
|
||||
*
|
||||
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
|
||||
* @method getForm
|
||||
* @return {DOMElement}
|
||||
*/
|
||||
var getForm = function() {
|
||||
return $(SELECTORS.UNIFIED_FILTERS).closest('form');
|
||||
};
|
||||
|
||||
return /** @alias module:core/form-autocomplete */ {
|
||||
/**
|
||||
* Initialise the unified user filter.
|
||||
*
|
||||
* @method init
|
||||
*/
|
||||
init: function() {
|
||||
init();
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the unified user filter form.
|
||||
*
|
||||
* @method getForm
|
||||
* @return {DOMElement}
|
||||
*/
|
||||
getForm: function() {
|
||||
return getForm();
|
||||
}
|
||||
};
|
||||
});
|
|
@ -1,93 +0,0 @@
|
|||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Datasource for the core_user/unified_filter.
|
||||
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
|
||||
*
|
||||
* This module is compatible with core/form-autocomplete.
|
||||
*
|
||||
* @copyright 2017 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {
|
||||
|
||||
return /** @alias module:core_user/unified_filter_datasource */ {
|
||||
/**
|
||||
* List filter options.
|
||||
*
|
||||
* @param {String} selector The select element selector.
|
||||
* @param {String} query The query string.
|
||||
* @return {Promise}
|
||||
*/
|
||||
list: function(selector, query) {
|
||||
var filteredOptions = [];
|
||||
|
||||
var el = $(selector);
|
||||
var originalOptions = $(selector).data('originaloptionsjson');
|
||||
var selectedFilters = el.val();
|
||||
$.each(originalOptions, function(index, option) {
|
||||
// Skip option if it does not contain the query string.
|
||||
if (query.trim() !== '' && option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) === -1) {
|
||||
return true;
|
||||
}
|
||||
// Skip filters that have already been selected.
|
||||
if ($.inArray(option.value, selectedFilters) > -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
filteredOptions.push(option);
|
||||
return true;
|
||||
});
|
||||
|
||||
var deferred = new $.Deferred();
|
||||
deferred.resolve(filteredOptions);
|
||||
|
||||
return deferred.promise();
|
||||
},
|
||||
|
||||
/**
|
||||
* Process the results for auto complete elements.
|
||||
*
|
||||
* @param {String} selector The selector of the auto complete element.
|
||||
* @param {Array} results An array or results.
|
||||
* @return {Array} New array of results.
|
||||
*/
|
||||
processResults: function(selector, results) {
|
||||
var options = [];
|
||||
$.each(results, function(index, data) {
|
||||
options.push({
|
||||
value: data.value,
|
||||
label: data.label
|
||||
});
|
||||
});
|
||||
return options;
|
||||
},
|
||||
|
||||
/**
|
||||
* Source of data for Ajax element.
|
||||
*
|
||||
* @param {String} selector The selector of the auto complete element.
|
||||
* @param {String} query The query string.
|
||||
* @param {Function} callback A callback function receiving an array of results.
|
||||
*/
|
||||
/* eslint-disable promise/no-callback-in-promise */
|
||||
transport: function(selector, query, callback) {
|
||||
this.list(selector, query).then(callback).catch(Notification.exception);
|
||||
}
|
||||
};
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue