Skip to content

Commit 89d1384

Browse files
committed
fix(contributors): updated contributors table with see more
1 parent e1e4847 commit 89d1384

File tree

26 files changed

+282
-105
lines changed

26 files changed

+282
-105
lines changed

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 & 1 deletion
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,6 +158,10 @@ export class ProjectContributorsStepComponent {
150158
this.stepChange.emit(this.targetStepValue());
151159
}
152160

161+
loadMoreContributors(): void {
162+
this.actions.loadMoreContributors(this.projectId(), ResourceType.Project);
163+
}
164+
153165
private openAddContributorDialog() {
154166
const addedContributorIds = this.projectContributors().map((x) => x.userId);
155167

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 & 10 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';
@@ -60,7 +61,9 @@ import {
6061
GetRequestAccessContributors,
6162
GetResourceDetails,
6263
GetResourceWithChildren,
64+
LoadMoreContributors,
6365
RejectRequestAccess,
66+
ResetContributorsState,
6467
UpdateBibliographyFilter,
6568
UpdateContributorsSearchValue,
6669
UpdatePermissionFilter,
@@ -87,7 +90,7 @@ import { ResourceInfoModel } from './models';
8790
styleUrl: './contributors.component.scss',
8891
changeDetection: ChangeDetectionStrategy.OnPush,
8992
})
90-
export class ContributorsComponent implements OnInit {
93+
export class ContributorsComponent implements OnInit, OnDestroy {
9194
searchControl = new FormControl<string>('');
9295

9396
readonly destroyRef = inject(DestroyRef);
@@ -123,14 +126,15 @@ export class ContributorsComponent implements OnInit {
123126
readonly hasAdminAccess = select(CurrentResourceSelectors.hasResourceAdminAccess);
124127
readonly resourceAccessRequestEnabled = select(CurrentResourceSelectors.resourceAccessRequestEnabled);
125128
readonly currentUser = select(UserSelectors.getCurrentUser);
126-
page = select(ContributorsSelectors.getContributorsPageNumber);
127129
pageSize = select(ContributorsSelectors.getContributorsPageSize);
130+
isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore);
128131

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

@@ -153,6 +157,7 @@ export class ContributorsComponent implements OnInit {
153157
getViewOnlyLinks: FetchViewOnlyLinks,
154158
getResourceDetails: GetResourceDetails,
155159
getContributors: GetAllContributors,
160+
loadMoreContributors: LoadMoreContributors,
156161
updateSearchValue: UpdateContributorsSearchValue,
157162
updatePermissionFilter: UpdatePermissionFilter,
158163
updateBibliographyFilter: UpdateBibliographyFilter,
@@ -166,6 +171,7 @@ export class ContributorsComponent implements OnInit {
166171
acceptRequestAccess: AcceptRequestAccess,
167172
rejectRequestAccess: RejectRequestAccess,
168173
getResourceWithChildren: GetResourceWithChildren,
174+
resetContributorsState: ResetContributorsState,
169175
});
170176

171177
get hasChanges(): boolean {
@@ -187,6 +193,10 @@ export class ContributorsComponent implements OnInit {
187193
this.setSearchSubscription();
188194
}
189195

196+
ngOnDestroy(): void {
197+
this.actions.resetContributorsState();
198+
}
199+
190200
private setSearchSubscription() {
191201
this.searchControl.valueChanges
192202
.pipe(debounceTime(500), distinctUntilChanged(), takeUntilDestroyed(this.destroyRef))
@@ -383,11 +393,8 @@ export class ContributorsComponent implements OnInit {
383393
});
384394
}
385395

386-
pageChanged(event: TablePageEvent) {
387-
const page = Math.floor(event.first / event.rows) + 1;
388-
const pageSize = event.rows;
389-
390-
this.actions.getContributors(this.resourceId(), this.resourceType(), page, pageSize);
396+
loadMoreContributors(): void {
397+
this.actions.loadMoreContributors(this.resourceId(), this.resourceType());
391398
}
392399

393400
createViewLink() {

src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
[(contributors)]="contributors"
2020
[tableParams]="tableParams()"
2121
[isLoading]="isLoading()"
22+
[isLoadingMore]="isLoadingMore()"
2223
[showEmployment]="false"
2324
[showEducation]="false"
2425
[hasAdminAccess]="hasAdminAccess()"
2526
[currentUserId]="currentUser()?.id"
2627
(remove)="removeContributor($event)"
27-
(pageChanged)="pageChanged($event)"
28+
(loadMore)="loadMoreContributors()"
2829
></osf-contributors-table>
2930

3031
@if (hasChanges) {

src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts

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

55
import { Button } from 'primeng/button';
66
import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';
7-
import { TablePageEvent } from 'primeng/table';
87

98
import { filter } from 'rxjs';
109

@@ -41,6 +40,7 @@ import {
4140
ContributorsSelectors,
4241
DeleteContributor,
4342
GetAllContributors,
43+
LoadMoreContributors,
4444
UpdateBibliographyFilter,
4545
UpdateContributorsSearchValue,
4646
UpdatePermissionFilter,
@@ -70,16 +70,17 @@ export class ContributorsDialogComponent implements OnInit {
7070
contributorsTotalCount = select(ContributorsSelectors.getContributorsTotalCount);
7171
hasAdminAccess = select(MetadataSelectors.hasAdminAccess);
7272
contributors = signal<ContributorModel[]>([]);
73-
page = select(ContributorsSelectors.getContributorsPageNumber);
73+
isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore);
7474
pageSize = select(ContributorsSelectors.getContributorsPageSize);
7575

7676
currentUser = select(UserSelectors.getCurrentUser);
7777

7878
readonly tableParams = computed<TableParameters>(() => ({
7979
...DEFAULT_TABLE_PARAMS,
8080
totalRecords: this.contributorsTotalCount(),
81-
paginator: this.contributorsTotalCount() > DEFAULT_TABLE_PARAMS.rows,
82-
firstRowIndex: (this.page() - 1) * this.pageSize(),
81+
paginator: false,
82+
scrollable: true,
83+
firstRowIndex: 0,
8384
rows: this.pageSize(),
8485
}));
8586

@@ -92,6 +93,7 @@ export class ContributorsDialogComponent implements OnInit {
9293
addContributor: AddContributor,
9394
bulkAddContributors: BulkAddContributors,
9495
bulkUpdateContributors: BulkUpdateContributors,
96+
loadMoreContributors: LoadMoreContributors,
9597
});
9698

9799
private readonly resourceType: ResourceType;
@@ -117,6 +119,7 @@ export class ContributorsDialogComponent implements OnInit {
117119
}
118120

119121
ngOnInit(): void {
122+
this.actions.getContributors(this.resourceId, this.resourceType);
120123
this.setSearchSubscription();
121124
}
122125

@@ -206,11 +209,8 @@ export class ContributorsDialogComponent implements OnInit {
206209
});
207210
}
208211

209-
pageChanged(event: TablePageEvent) {
210-
const page = Math.floor(event.first / event.rows) + 1;
211-
const pageSize = event.rows;
212-
213-
this.actions.getContributors(this.resourceId, this.resourceType, page, pageSize);
212+
loadMoreContributors(): void {
213+
this.actions.loadMoreContributors(this.resourceId, this.resourceType);
214214
}
215215

216216
cancel() {

src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ <h2>{{ 'project.overview.metadata.contributors' | translate }}</h2>
1212
[(contributors)]="contributors"
1313
[tableParams]="tableParams()"
1414
[isLoading]="isContributorsLoading()"
15+
[isLoadingMore]="isLoadingMore()"
1516
(remove)="removeContributor($event)"
16-
(pageChanged)="pageChanged($event)"
17+
(loadMore)="loadMoreContributors()"
1718
/>
1819
<div class="flex justify-content-end mt-3">
1920
@if (hasChanges) {

0 commit comments

Comments
 (0)