Skip to content

Commit 5ad8c5a

Browse files
authored
Merge pull request #699 from nsemets/fix/ANG-9238-v2
[ANG-9238] P3.3 - Contributors displays are not displaying when there are > 10 listed
2 parents 6e30deb + a2d922e commit 5ad8c5a

File tree

61 files changed

+573
-267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+573
-267
lines changed

jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ module.exports = {
5050
extensionsToTreatAsEsm: ['.ts'],
5151
coverageThreshold: {
5252
global: {
53-
branches: 24.1,
54-
functions: 28.73,
55-
lines: 56.52,
56-
statements: 56.82,
53+
branches: 29.01,
54+
functions: 32.75,
55+
lines: 60.28,
56+
statements: 60.77,
5757
},
5858
},
5959
watchPathIgnorePatterns: [

src/app/core/constants/ngxs-states.constant.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { FilesState } from '@osf/features/files/store';
66
import { MetadataState } from '@osf/features/metadata/store';
77
import { ProjectOverviewState } from '@osf/features/project/overview/store';
88
import { RegistrationsState } from '@osf/features/project/registrations/store';
9-
import { AddonsState, CurrentResourceState, WikiState } from '@osf/shared/stores';
9+
import { AddonsState, ContributorsState, CurrentResourceState, WikiState } from '@osf/shared/stores';
1010
import { BannersState } from '@osf/shared/stores/banners';
1111
import { GlobalSearchState } from '@shared/stores/global-search';
1212
import { InstitutionsState } from '@shared/stores/institutions';
@@ -36,4 +36,5 @@ export const STATES = [
3636
GlobalSearchState,
3737
BannersState,
3838
LinkedProjectsState,
39+
ContributorsState,
3940
];

src/app/features/collections/collections.routes.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@ import { authGuard } from '@osf/core/guards';
66
import { AddToCollectionState } from '@osf/features/collections/store/add-to-collection';
77
import { CollectionsModerationState } from '@osf/features/moderation/store/collections-moderation';
88
import { ConfirmLeavingGuard } from '@shared/guards';
9-
import {
10-
BookmarksState,
11-
CitationsState,
12-
ContributorsState,
13-
NodeLinksState,
14-
ProjectsState,
15-
SubjectsState,
16-
} from '@shared/stores';
9+
import { BookmarksState, CitationsState, NodeLinksState, ProjectsState, SubjectsState } from '@shared/stores';
1710
import { CollectionsState } from '@shared/stores/collections';
1811

1912
export const collectionsRoutes: Routes = [
@@ -47,7 +40,7 @@ export const collectionsRoutes: Routes = [
4740
import('@osf/features/collections/components/add-to-collection/add-to-collection.component').then(
4841
(mod) => mod.AddToCollectionComponent
4942
),
50-
providers: [provideStates([ProjectsState, CollectionsState, AddToCollectionState, ContributorsState])],
43+
providers: [provideStates([ProjectsState, CollectionsState, AddToCollectionState])],
5144
canActivate: [authGuard],
5245
canDeactivate: [ConfirmLeavingGuard],
5346
},

src/app/features/collections/components/add-to-collection/add-to-collection.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ <h1 class="collections-heading flex align-items-center">{{ collectionProvider()?
3232
/>
3333

3434
<osf-project-contributors-step
35+
[projectId]="selectedProject()?.id"
3536
[stepperActiveValue]="stepperActiveValue()"
3637
[targetStepValue]="AddToCollectionSteps.ProjectContributors"
3738
[isDisabled]="isProjectContributorsDisabled()"

src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ <h3>{{ 'collections.addToCollection.projectContributors' | translate }}</h3>
4242
[(contributors)]="projectContributors"
4343
[tableParams]="tableParams()"
4444
[isLoading]="isContributorsLoading()"
45+
[isLoadingMore]="isLoadingMore()"
4546
(remove)="handleRemoveContributor($event)"
47+
(loadMore)="loadMoreContributors()"
4648
></osf-contributors-table>
4749

4850
<div class="flex justify-content-end gap-3 mt-4 w-full">

src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
BulkUpdateContributors,
4141
ContributorsSelectors,
4242
DeleteContributor,
43+
LoadMoreContributors,
4344
ProjectsSelectors,
4445
} from '@osf/shared/stores';
4546

@@ -61,20 +62,26 @@ export class ProjectContributorsStepComponent {
6162
readonly contributorsTotalCount = select(ContributorsSelectors.getContributorsTotalCount);
6263
readonly selectedProject = select(ProjectsSelectors.getSelectedProject);
6364
readonly currentUser = select(UserSelectors.getCurrentUser);
65+
isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore);
6466

6567
private initialContributors = select(ContributorsSelectors.getContributors);
6668
readonly projectContributors = signal<ContributorModel[]>([]);
69+
pageSize = select(ContributorsSelectors.getContributorsPageSize);
6770

6871
readonly tableParams = computed<TableParameters>(() => ({
6972
...DEFAULT_TABLE_PARAMS,
7073
totalRecords: this.contributorsTotalCount(),
71-
paginator: this.contributorsTotalCount() > DEFAULT_TABLE_PARAMS.rows,
74+
paginator: false,
75+
scrollable: true,
76+
firstRowIndex: 0,
77+
rows: this.pageSize(),
7278
}));
7379

7480
stepperActiveValue = input.required<number>();
7581
targetStepValue = input.required<number>();
7682
isDisabled = input.required<boolean>();
7783
isProjectMetadataSaved = input<boolean>(false);
84+
projectId = input<string | undefined>();
7885

7986
stepChange = output<number>();
8087
contributorsSaved = output<void>();
@@ -84,6 +91,7 @@ export class ProjectContributorsStepComponent {
8491
bulkAddContributors: BulkAddContributors,
8592
bulkUpdateContributors: BulkUpdateContributors,
8693
deleteContributor: DeleteContributor,
94+
loadMoreContributors: LoadMoreContributors,
8795
});
8896

8997
constructor() {
@@ -150,14 +158,15 @@ export class ProjectContributorsStepComponent {
150158
this.stepChange.emit(this.targetStepValue());
151159
}
152160

153-
private openAddContributorDialog() {
154-
const addedContributorIds = this.projectContributors().map((x) => x.userId);
161+
loadMoreContributors(): void {
162+
this.actions.loadMoreContributors(this.projectId(), ResourceType.Project);
163+
}
155164

165+
private openAddContributorDialog() {
156166
this.customDialogService
157167
.open(AddContributorDialogComponent, {
158168
header: 'project.contributors.addDialog.addRegisteredContributor',
159169
width: '448px',
160-
data: addedContributorIds,
161170
})
162171
.onClose.pipe(
163172
filter((res: ContributorDialogAddModel) => !!res),

src/app/features/contributors/contributors.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ <h1 class="py-5 px-3 md:px-5 xl:px-4">{{ 'navigation.contributors' | translate }
6363
class="w-full"
6464
[(contributors)]="contributors"
6565
[isLoading]="isContributorsLoading()"
66+
[isLoadingMore]="isLoadingMore()"
6667
[tableParams]="tableParams()"
6768
[hasAdminAccess]="hasAdminAccess()"
6869
[currentUserId]="currentUser()?.id"
6970
[showCurator]="true"
7071
[showInfo]="true"
7172
[resourceType]="resourceType()"
7273
(remove)="removeContributor($event)"
73-
(pageChanged)="pageChanged($event)"
74+
(loadMore)="loadMoreContributors()"
7475
></osf-contributors-table>
7576

7677
@if (hasChanges) {

src/app/features/contributors/contributors.component.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { TranslatePipe } from '@ngx-translate/core';
44

55
import { Button } from 'primeng/button';
66
import { Select } from 'primeng/select';
7-
import { TableModule, TablePageEvent } from 'primeng/table';
7+
import { TableModule } from 'primeng/table';
88

99
import { debounceTime, distinctUntilChanged, filter, map, of, switchMap } from 'rxjs';
1010

@@ -15,6 +15,7 @@ import {
1515
DestroyRef,
1616
effect,
1717
inject,
18+
OnDestroy,
1819
OnInit,
1920
signal,
2021
} from '@angular/core';
@@ -61,7 +62,9 @@ import {
6162
GetRequestAccessContributors,
6263
GetResourceDetails,
6364
GetResourceWithChildren,
65+
LoadMoreContributors,
6466
RejectRequestAccess,
67+
ResetContributorsState,
6568
UpdateBibliographyFilter,
6669
UpdateContributorsSearchValue,
6770
UpdatePermissionFilter,
@@ -88,7 +91,7 @@ import { ResourceInfoModel } from './models';
8891
styleUrl: './contributors.component.scss',
8992
changeDetection: ChangeDetectionStrategy.OnPush,
9093
})
91-
export class ContributorsComponent implements OnInit {
94+
export class ContributorsComponent implements OnInit, OnDestroy {
9295
searchControl = new FormControl<string>('');
9396

9497
readonly destroyRef = inject(DestroyRef);
@@ -124,14 +127,15 @@ export class ContributorsComponent implements OnInit {
124127
readonly hasAdminAccess = select(CurrentResourceSelectors.hasResourceAdminAccess);
125128
readonly resourceAccessRequestEnabled = select(CurrentResourceSelectors.resourceAccessRequestEnabled);
126129
readonly currentUser = select(UserSelectors.getCurrentUser);
127-
page = select(ContributorsSelectors.getContributorsPageNumber);
128130
pageSize = select(ContributorsSelectors.getContributorsPageSize);
131+
isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore);
129132

130133
readonly tableParams = computed<TableParameters>(() => ({
131134
...DEFAULT_TABLE_PARAMS,
132135
totalRecords: this.contributorsTotalCount(),
133-
paginator: this.contributorsTotalCount() > DEFAULT_TABLE_PARAMS.rows,
134-
firstRowIndex: (this.page() - 1) * this.pageSize(),
136+
paginator: false,
137+
scrollable: true,
138+
firstRowIndex: 0,
135139
rows: this.pageSize(),
136140
}));
137141

@@ -154,6 +158,7 @@ export class ContributorsComponent implements OnInit {
154158
getViewOnlyLinks: FetchViewOnlyLinks,
155159
getResourceDetails: GetResourceDetails,
156160
getContributors: GetAllContributors,
161+
loadMoreContributors: LoadMoreContributors,
157162
updateSearchValue: UpdateContributorsSearchValue,
158163
updatePermissionFilter: UpdatePermissionFilter,
159164
updateBibliographyFilter: UpdateBibliographyFilter,
@@ -168,6 +173,7 @@ export class ContributorsComponent implements OnInit {
168173
acceptRequestAccess: AcceptRequestAccess,
169174
rejectRequestAccess: RejectRequestAccess,
170175
getResourceWithChildren: GetResourceWithChildren,
176+
resetContributorsState: ResetContributorsState,
171177
});
172178

173179
get hasChanges(): boolean {
@@ -189,6 +195,10 @@ export class ContributorsComponent implements OnInit {
189195
this.setSearchSubscription();
190196
}
191197

198+
ngOnDestroy(): void {
199+
this.actions.resetContributorsState();
200+
}
201+
192202
private setSearchSubscription() {
193203
this.searchControl.valueChanges
194204
.pipe(debounceTime(500), distinctUntilChanged(), takeUntilDestroyed(this.destroyRef))
@@ -247,7 +257,6 @@ export class ContributorsComponent implements OnInit {
247257
}
248258

249259
openAddContributorDialog() {
250-
const addedContributorIds = this.initialContributors().map((x) => x.userId);
251260
const resourceDetails = this.resourceDetails();
252261
const resourceId = this.resourceId();
253262
const rootParentId = resourceDetails.rootParentId ?? resourceId;
@@ -267,7 +276,6 @@ export class ContributorsComponent implements OnInit {
267276
header: 'project.contributors.addDialog.addRegisteredContributor',
268277
width: '448px',
269278
data: {
270-
addedContributorIds,
271279
components,
272280
resourceName: resourceDetails.title,
273281
parentResourceName: resourceDetails.parent?.title,
@@ -401,11 +409,8 @@ export class ContributorsComponent implements OnInit {
401409
});
402410
}
403411

404-
pageChanged(event: TablePageEvent) {
405-
const page = Math.floor(event.first / event.rows) + 1;
406-
const pageSize = event.rows;
407-
408-
this.actions.getContributors(this.resourceId(), this.resourceType(), page, pageSize);
412+
loadMoreContributors(): void {
413+
this.actions.loadMoreContributors(this.resourceId(), this.resourceType());
409414
}
410415

411416
createViewLink() {

src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ <h2>{{ 'project.overview.metadata.contributors' | translate }}</h2>
1212
}
1313
</div>
1414

15-
@if (contributors()) {
16-
<div class="inline-flex flex-wrap gap-1 line-height-2 mt-4">
17-
<osf-contributors-list [contributors]="contributors()"></osf-contributors-list>
15+
@if (contributors().length) {
16+
<div class="flex mt-4">
17+
<osf-contributors-list
18+
[contributors]="contributors()"
19+
[isLoading]="isLoading()"
20+
[hasLoadMore]="hasMoreContributors()"
21+
(loadMoreContributors)="loadMoreContributors.emit()"
22+
></osf-contributors-list>
1823
</div>
1924
}
2025
</p-card>

src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import { ContributorModel } from '@osf/shared/models';
1515
changeDetection: ChangeDetectionStrategy.OnPush,
1616
})
1717
export class MetadataContributorsComponent {
18-
openEditContributorDialog = output<void>();
1918
contributors = input<ContributorModel[]>([]);
19+
isLoading = input(false);
20+
hasMoreContributors = input(false);
2021
readonly = input<boolean>(false);
22+
23+
openEditContributorDialog = output<void>();
24+
loadMoreContributors = output<void>();
2125
}

0 commit comments

Comments
 (0)