Skip to content

Commit

Permalink
Merge pull request #3826 from tdonohue/port_3105_to_7x
Browse files Browse the repository at this point in the history
[Port dspace-7_x] Fix for User profile (/profile): only 20 group memberships shown instead of all
  • Loading branch information
tdonohue authored Jan 10, 2025
2 parents fbe4ce5 + 112bed7 commit 6f5864d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
30 changes: 23 additions & 7 deletions src/app/profile-page/profile-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,29 @@ <h1>{{'profile.title' | translate}}</h1>
<button class="btn btn-primary" (click)="updateProfile()"><i class="fas fa-edit"></i> {{'profile.form.submit' | translate}}</button>
</div>

<ng-container *ngVar="(groupsRD$ | async)?.payload?.page as groups">
<div *ngIf="groups?.length > 0">
<h2 class="mt-4">{{'profile.groups.head' | translate}}</h2>
<ul class="list-group list-group-flush">
<li *ngFor="let group of groups" class="list-group-item">{{ dsoNameService.getName(group) }}</li>
</ul>
</div>
<ng-container *ngIf="(groupsRD$ | async) as groupsRD;">
<ng-container *ngTemplateOutlet="groupsRD?.isLoading ? loader : content"></ng-container>
<ng-template #content>
<ds-pagination *ngIf="groupsRD?.payload"
[hideGear]="true"
[hidePagerWhenSinglePage]="true"
[hidePaginationDetail]="true"
[paginationOptions]="optionsGroupsPagination"
[collectionSize]="groupsRD?.payload?.totalElements">
<ng-container *ngIf="groupsRD?.payload?.page as groups">
<div *ngIf="groups?.length > 0">
<h2 class="mt-4">{{ 'profile.groups.head' | translate }}</h2>
<ul class="list-group list-group-flush">
<li *ngFor="let group of groups" class="list-group-item">{{ dsoNameService.getName(group) }}</li>
</ul>
</div>
</ng-container>
</ds-pagination>
</ng-template>
<ng-template #loader>
<ds-loading [showMessage]="false"></ds-loading>
</ng-template>
<ds-error *ngIf="groupsRD?.hasFailed" message="{{ 'error.profile-groups' | translate }}"></ds-error>
</ng-container>

<ng-container *ngVar="(specialGroupsRD$ | async)?.payload?.page as specialGroups">
Expand Down
32 changes: 30 additions & 2 deletions src/app/profile-page/profile-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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',
Expand Down Expand Up @@ -79,6 +86,15 @@ export class ProfilePageComponent implements OnInit {
private currentUser: EPerson;
canChangePassword$: Observable<boolean>;

/**
* Default configuration for group pagination
**/
optionsGroupsPagination = Object.assign(new PaginationComponentOptions(),{
id: 'page_groups',
currentPage: 1,
pageSize: 20,
});

isResearcherProfileEnabled$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);

constructor(private authService: AuthService,
Expand All @@ -88,6 +104,7 @@ export class ProfilePageComponent implements OnInit {
private authorizationService: AuthorizationDataService,
private configurationService: ConfigurationDataService,
public dsoNameService: DSONameService,
private paginationService: PaginationService,
) {
}

Expand All @@ -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();

Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\"https://solr.apache.org/guide/query-syntax-and-parsing.html\" target=\"_blank\">Solr query syntax</a> best practices for further information about this error.",
Expand Down

0 comments on commit 6f5864d

Please sign in to comment.