mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-80241 grade: update user filtering by matched properties.
Invert the previous logic, which maintained a "banned" list of fields, to instead only try to filter on those fields that are explicitly defined to support that.
This commit is contained in:
parent
d3ad77e476
commit
0a66e9a3f8
2
user/amd/build/comboboxsearch/user.min.js
vendored
2
user/amd/build/comboboxsearch/user.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -30,7 +30,6 @@ export default class UserSearch extends search_combobox {
|
||||
|
||||
courseID;
|
||||
groupID;
|
||||
bannedFilterFields = ['profileimageurlsmall', 'profileimageurl', 'id', 'link', 'matchingField', 'matchingFieldName'];
|
||||
|
||||
// A map of user profile field names that is human-readable.
|
||||
profilestringmap = null;
|
||||
@ -118,8 +117,9 @@ export default class UserSearch extends search_combobox {
|
||||
* @returns {Array} The users that match the given criteria.
|
||||
*/
|
||||
async filterDataset(filterableData) {
|
||||
const stringMap = await this.getStringMap();
|
||||
return filterableData.filter((user) => Object.keys(user).some((key) => {
|
||||
if (user[key] === "" || user[key] === null || this.bannedFilterFields.includes(key)) {
|
||||
if (user[key] === "" || user[key] === null || !stringMap.get(key)) {
|
||||
return false;
|
||||
}
|
||||
return user[key].toString().toLowerCase().includes(this.getPreppedSearchTerm());
|
||||
@ -145,9 +145,10 @@ export default class UserSearch extends search_combobox {
|
||||
const preppedSearchTerm = this.getPreppedSearchTerm();
|
||||
const searchTerm = this.getSearchTerm();
|
||||
|
||||
if (valueString.includes(preppedSearchTerm) && !this.bannedFilterFields.includes(key)) {
|
||||
// Ensure we have a good string, otherwise fallback to the key.
|
||||
user.matchingFieldName = stringMap.get(key) ?? key;
|
||||
// Ensure we match only on expected keys.
|
||||
const matchingFieldName = stringMap.get(key);
|
||||
if (matchingFieldName && valueString.includes(preppedSearchTerm)) {
|
||||
user.matchingFieldName = matchingFieldName;
|
||||
|
||||
// Safely prepare our matching results.
|
||||
const escapedValueString = valueString.replace(/</g, '<');
|
||||
@ -282,6 +283,7 @@ export default class UserSearch extends search_combobox {
|
||||
if (!this.profilestringmap) {
|
||||
const requiredStrings = [
|
||||
'username',
|
||||
'fullname',
|
||||
'firstname',
|
||||
'lastname',
|
||||
'email',
|
||||
|
Loading…
x
Reference in New Issue
Block a user