Skip to content

Commit

Permalink
SAK-46235 Excel exported by Roster2 tool does not sort correctly the …
Browse files Browse the repository at this point in the history
…groups where each student belongs (sakaiproject#9872)
  • Loading branch information
josecebe authored Sep 28, 2021
1 parent a010026 commit 72bb78c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions roster2/tool/src/handlebars/members_table.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@
<td class="roster-groups-cell">
{{#if hasGroups}}
<div class="roster-group-cell">
{{#if singleGroup}}
<a href="javascript:;" class="roster-group-link" data-groupid="{{singleGroup.id}}">{{singleGroup.title}}</a>
{{else}}
{{#if groups.[1]}}
<span class="skip">{{tr 'screenreader_comboBox'}}</span>
<select class="roster-groups-selector">
<option value="all">{{tr 'member_group_all_option'}}</option>
{{#each groups}}
<option value="{{id}}">{{title}}</option>
{{/each}}
</select>
{{else}}
<a href="javascript:;" class="roster-group-link" data-groupid="{{groups.[0].id}}">{{groups.[0].title}}</a>
{{/if}}
</div>
{{else}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
package org.sakaiproject.roster.api;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;

import lombok.Data;
Expand Down Expand Up @@ -78,10 +80,16 @@ public void addGroup(String groupId, String groupTitle) {
}

public String getGroupsToString() {
return groups.values().stream().collect(Collectors.joining(","));
return this.getGroups().values().stream().collect(Collectors.joining(","));
}

public String getEid() {
return eid == null ? userId : eid;
}

public Map<String, String> getGroups() {
this.groups = this.groups.entrySet().stream().sorted(Entry.comparingByValue()).
collect(Collectors.toMap(Entry::getKey, Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
return this.groups;
}
}
11 changes: 4 additions & 7 deletions roster2/tool/src/webapp/js/roster.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,10 @@ roster.renderMembership = function (options) {

var groupIds = Object.keys(m.groups);
m.hasGroups = groupIds.length > 0;
m.singleGroup = null;
if (groupIds.length === 1) {
var singleGroupId = groupIds[0];
m.singleGroup = { id: singleGroupId, title: m.groups[singleGroupId] };
} else {
m.groups = groupIds.reduce((acc, id) => { acc.push({id: id, title: m.groups[id]}); return acc; }, []);
}
m.groups = groupIds.reduce((acc, id) => { acc.push({id: id, title: m.groups[id]}); return acc; }, []);
m.groups.sort(function (a, b) {
return a.title.localeCompare(b.title);
});

if (roster.showVisits) {
if (m.totalSiteVisits > 0) {
Expand Down

0 comments on commit 72bb78c

Please sign in to comment.