diff --git a/kolibri/core/auth/api.py b/kolibri/core/auth/api.py index 1b14162e92..3d49cfc8fb 100644 --- a/kolibri/core/auth/api.py +++ b/kolibri/core/auth/api.py @@ -298,6 +298,8 @@ class FacilityUserViewSet(ValuesViewset): DjangoFilterBackend, filters.SearchFilter, ) + order_by_field = "username" + queryset = FacilityUser.objects.all() serializer_class = FacilityUserSerializer filter_class = FacilityUserFilter @@ -338,6 +340,7 @@ def consolidate(self, items, queryset): roles.append(role) item["roles"] = roles output.append(item) + output = sorted(output, key=lambda x: x[self.order_by_field]) return output def set_password_if_needed(self, instance, serializer): diff --git a/kolibri/plugins/facility/assets/src/modules/userManagement/handlers.js b/kolibri/plugins/facility/assets/src/modules/userManagement/handlers.js index 9aed40c494..393de407cf 100644 --- a/kolibri/plugins/facility/assets/src/modules/userManagement/handlers.js +++ b/kolibri/plugins/facility/assets/src/modules/userManagement/handlers.js @@ -1,3 +1,4 @@ +import pickBy from 'lodash/pickBy'; import { FacilityUserResource } from 'kolibri.resources'; import samePageCheckGenerator from 'kolibri.utils.samePageCheckGenerator'; import { _userState } from '../mappers'; @@ -6,7 +7,13 @@ export function showUserPage(store, toRoute) { store.dispatch('preparePage'); const facilityId = toRoute.params.facility_id || store.getters.activeFacilityId; return FacilityUserResource.fetchCollection({ - getParams: { member_of: facilityId, page_size: 30 }, + getParams: pickBy({ + member_of: facilityId, + page: toRoute.query.page || 1, + page_size: toRoute.query.page_size || 30, + search: toRoute.query.search && toRoute.query.search.trim(), + user_type: toRoute.query.user_type, + }), force: true, }).only( samePageCheckGenerator(store), diff --git a/kolibri/plugins/facility/assets/src/views/PaginatedListContainerWithBackend.vue b/kolibri/plugins/facility/assets/src/views/PaginatedListContainerWithBackend.vue index 610fe36750..ea2ea1e08f 100644 --- a/kolibri/plugins/facility/assets/src/views/PaginatedListContainerWithBackend.vue +++ b/kolibri/plugins/facility/assets/src/views/PaginatedListContainerWithBackend.vue @@ -9,32 +9,29 @@ :layout12="{ span: 5, alignment: 'right' }" class="text-filter" > - +
- +