Skip to content

Commit

Permalink
SAK-40567 Roster doesn't display when two users with same display nam…
Browse files Browse the repository at this point in the history
…e are in site (sakaiproject#5973)
  • Loading branch information
Miguel Pellicer authored Sep 11, 2018
1 parent 9582bbb commit 987d9f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ public Map<String, String> getSearchIndex(String siteId, String userId, String g

if (MapUtils.isEmpty(index)) {
final List<RosterMember> membership = getMembership(userId, siteId, groupId, roleId, enrollmentSetId, enrollmentStatus);
index = membership.stream().collect(Collectors.toMap(RosterMember::getDisplayName , RosterMember::getUserId));
index = membership.stream().collect(Collectors.toMap(RosterMember::getUserId, RosterMember::getDisplayName));
cache.put(siteId+groupId, index);
}

Expand Down
29 changes: 13 additions & 16 deletions roster2/src/webapp/js/roster.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,22 +507,18 @@

if (query !== roster.i18n.roster_search_text && query !== "") {
var userIds = [];
var userId = roster.searchIndex[query];
if (!userId) {
roster.searchIndexKeys.forEach(function (displayName) {

var regex = new RegExp(query, 'i');
if (regex.test(displayName)) {
userIds.push(roster.searchIndex[displayName]);
}
});

if (userIds.length > 5) {
// Limit to 5 users
userIds = userIds.slice(0, 5);
var i = 0;
roster.searchIndexValues.forEach(function (displayName) {
var regex = new RegExp(query, 'i');
if (regex.test(displayName)) {
userIds.push(roster.searchIndexKeys[i]);
}
} else {
userIds.push(userId);
i++;
});

if (userIds.length > 5) {
// Limit to 5 users
userIds = userIds.slice(0, 5);
}

if (userIds.length > 0) {
Expand Down Expand Up @@ -557,7 +553,7 @@
});

field.autocomplete({
source: roster.searchIndexKeys,
source: roster.searchIndexValues,
select: function (event, ui) {
roster.search(ui.item.value);
}
Expand Down Expand Up @@ -830,6 +826,7 @@
success: function (data) {
roster.searchIndex = data.data;
roster.searchIndexKeys = Object.keys(data.data);
roster.searchIndexValues = Object.values(data.data);
// Now switch into the requested state
roster.switchState(roster.state, roster);
},
Expand Down

0 comments on commit 987d9f1

Please sign in to comment.