Show multiple team memberships in My Team tab (#23324)
* Enable pagiation to show all a learner's teams on the "My Teams" tab * Selectively hide/show pagination on the "My Teams" tab * Increase "My Teams" page size to 5
This commit is contained in:
@@ -31,10 +31,6 @@ define([
|
||||
teams = TeamSpecHelpers.createMockTeams({results: teamsData}),
|
||||
myTeamsView = createMyTeamsView(teams);
|
||||
TeamSpecHelpers.verifyCards(myTeamsView, teamsData);
|
||||
|
||||
// Verify that there is no header or footer
|
||||
expect(myTeamsView.$('.teams-paging-header').text().trim()).toBe('');
|
||||
expect(myTeamsView.$('.teams-paging-footer').text().trim()).toBe('');
|
||||
});
|
||||
|
||||
it('shows a message when the user is not a member of any teams', function() {
|
||||
@@ -44,6 +40,16 @@ define([
|
||||
expect(myTeamsView.$el.text().trim()).toBe('You are not currently a member of any team.');
|
||||
});
|
||||
|
||||
it('hides pagination when the user is not a member of any teams', function() {
|
||||
var teams = TeamSpecHelpers.createMockTeams({results: []}),
|
||||
myTeamsView = createMyTeamsView(teams);
|
||||
TeamSpecHelpers.verifyCards(myTeamsView, []);
|
||||
|
||||
// Verify that there is no header or footer
|
||||
expect(myTeamsView.$('.teams-paging-header').text().trim()).toBe('');
|
||||
expect(myTeamsView.$('.teams-paging-footer').text().trim()).toBe('');
|
||||
});
|
||||
|
||||
it('refreshes a stale membership collection when rendering', function() {
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
teams = TeamSpecHelpers.createMockTeams({
|
||||
|
||||
@@ -34,15 +34,21 @@
|
||||
},
|
||||
|
||||
createHeaderView: function() {
|
||||
// Never show a pagination header for the "My Team" tab
|
||||
// because there is only ever one team.
|
||||
return null;
|
||||
// hide pagination when learner isn't a member of any teams
|
||||
if (!this.collection.length) {
|
||||
return null;
|
||||
} else {
|
||||
return TeamsView.prototype.createHeaderView.call(this);
|
||||
}
|
||||
},
|
||||
|
||||
createFooterView: function() {
|
||||
// Never show a pagination footer for the "My Team" tab
|
||||
// because there is only ever one team.
|
||||
return null;
|
||||
// hide pagination when learner isn't a member of any teams
|
||||
if (!this.collection.length) {
|
||||
return null;
|
||||
} else {
|
||||
return TeamsView.prototype.createFooterView.call(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
teamEvents: this.teamEvents,
|
||||
course_id: this.context.courseID,
|
||||
username: this.context.userInfo.username,
|
||||
perPage: 2,
|
||||
perPage: 5,
|
||||
parse: true,
|
||||
url: this.context.myTeamsUrl
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ from .serializers import (
|
||||
)
|
||||
from .utils import emit_team_event
|
||||
|
||||
TEAM_MEMBERSHIPS_PER_PAGE = 2
|
||||
TEAM_MEMBERSHIPS_PER_PAGE = 5
|
||||
TOPICS_PER_PAGE = 12
|
||||
MAXIMUM_SEARCH_SIZE = 100000
|
||||
|
||||
@@ -165,7 +165,7 @@ class TeamsDashboardView(GenericAPIView):
|
||||
is_user_org_protected = organization_protection_status == OrganizationProtectionStatus.protected
|
||||
filter_query['organization_protected'] = is_user_org_protected
|
||||
|
||||
user_teams = CourseTeam.objects.filter(**filter_query)
|
||||
user_teams = CourseTeam.objects.filter(**filter_query).order_by('-last_activity_at', 'team_size')
|
||||
user_teams_data = self._serialize_and_paginate(
|
||||
MyTeamsPagination,
|
||||
user_teams,
|
||||
|
||||
Reference in New Issue
Block a user