From 112bed787af3b24d130f2ced0be96a0a3c917118 Mon Sep 17 00:00:00 2001 From: VictorHugoDuranS Date: Fri, 10 Jan 2025 15:35:41 -0600 Subject: [PATCH] Fix for User profile (/profile): only 20 group memberships shown instead of all (#3105) * Add - groups paginated on profile page * Add - groups paginated on profile page * Add - groups paginated on profile page * Add - groups paginated on profile page * Fix UPDATE - Add pagination message error and loader * Update BRANCH * Fix - LINT ERRORS * Fix: Error declaring variable for group pagination * Fix: Remove unnecessary translations for paging groups * Fix: Lint erros * Fix: Remove unnecessary translations --------- Co-authored-by: VictorDuranEscire --- .../profile-page/profile-page.component.html | 30 +++++++++++++---- .../profile-page/profile-page.component.ts | 32 +++++++++++++++++-- src/assets/i18n/en.json5 | 2 ++ 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/src/app/profile-page/profile-page.component.html b/src/app/profile-page/profile-page.component.html index e2769b38ec7..29ccefa2092 100644 --- a/src/app/profile-page/profile-page.component.html +++ b/src/app/profile-page/profile-page.component.html @@ -32,13 +32,29 @@

{{'profile.title' | translate}}

- -
-

{{'profile.groups.head' | translate}}

-
    -
  • {{ dsoNameService.getName(group) }}
  • -
-
+ + + + + +
+

{{ 'profile.groups.head' | translate }}

+
    +
  • {{ dsoNameService.getName(group) }}
  • +
+
+
+
+
+ + + +
diff --git a/src/app/profile-page/profile-page.component.ts b/src/app/profile-page/profile-page.component.ts index 6e693461d27..f8cb30a4478 100644 --- a/src/app/profile-page/profile-page.component.ts +++ b/src/app/profile-page/profile-page.component.ts @@ -9,7 +9,12 @@ import { RemoteData } from '../core/data/remote-data'; import { PaginatedList } from '../core/data/paginated-list.model'; import { filter, switchMap, tap } from 'rxjs/operators'; import { EPersonDataService } from '../core/eperson/eperson-data.service'; -import { getAllSucceededRemoteData, getFirstCompletedRemoteData, getRemoteDataPayload } from '../core/shared/operators'; +import { + getAllCompletedRemoteData, + getAllSucceededRemoteData, + getFirstCompletedRemoteData, + getRemoteDataPayload +} from '../core/shared/operators'; import { hasValue, isNotEmpty } from '../shared/empty.util'; import { followLink } from '../shared/utils/follow-link-config.model'; import { AuthService } from '../core/auth/auth.service'; @@ -19,6 +24,8 @@ import { FeatureID } from '../core/data/feature-authorization/feature-id'; import { ConfigurationDataService } from '../core/data/configuration-data.service'; import { ConfigurationProperty } from '../core/shared/configuration-property.model'; import { DSONameService } from '../core/breadcrumbs/dso-name.service'; +import { PaginationService } from '../core/pagination/pagination.service'; +import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model'; @Component({ selector: 'ds-profile-page', @@ -79,6 +86,15 @@ export class ProfilePageComponent implements OnInit { private currentUser: EPerson; canChangePassword$: Observable; + /** + * Default configuration for group pagination + **/ + optionsGroupsPagination = Object.assign(new PaginationComponentOptions(),{ + id: 'page_groups', + currentPage: 1, + pageSize: 20, + }); + isResearcherProfileEnabled$: BehaviorSubject = new BehaviorSubject(false); constructor(private authService: AuthService, @@ -88,6 +104,7 @@ export class ProfilePageComponent implements OnInit { private authorizationService: AuthorizationDataService, private configurationService: ConfigurationDataService, public dsoNameService: DSONameService, + private paginationService: PaginationService, ) { } @@ -99,7 +116,18 @@ export class ProfilePageComponent implements OnInit { getRemoteDataPayload(), tap((user: EPerson) => this.currentUser = user) ); - this.groupsRD$ = this.user$.pipe(switchMap((user: EPerson) => user.groups)); + this.groupsRD$ = this.paginationService.getCurrentPagination(this.optionsGroupsPagination.id, this.optionsGroupsPagination).pipe( + switchMap((pageOptions: PaginationComponentOptions) => { + return this.epersonService.findById(this.currentUser.id, true, true, followLink('groups',{ + findListOptions: { + elementsPerPage: pageOptions.pageSize, + currentPage: pageOptions.currentPage, + } })); + }), + getAllCompletedRemoteData(), + getRemoteDataPayload(), + switchMap((user: EPerson) => user?.groups), + ); this.canChangePassword$ = this.user$.pipe(switchMap((user: EPerson) => this.authorizationService.isAuthorized(FeatureID.CanChangePassword, user._links.self.href))); this.specialGroupsRD$ = this.authService.getSpecialGroupsFromAuthStatus(); diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index a56f1cd4f2b..f53670c4e37 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -1622,6 +1622,8 @@ "error.recent-submissions": "Error fetching recent submissions", + "error.profile-groups": "Error retrieving profile groups", + "error.search-results": "Error fetching search results", "error.invalid-search-query": "Search query is not valid. Please check Solr query syntax best practices for further information about this error.",