Skip to content

Commit 21dacd6

Browse files
committed
fix(contributors): added see more for contributors list
1 parent 89d1384 commit 21dacd6

24 files changed

+226
-83
lines changed

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
}

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export class ContributorsDialogComponent implements OnInit {
7272
contributors = signal<ContributorModel[]>([]);
7373
isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore);
7474
pageSize = select(ContributorsSelectors.getContributorsPageSize);
75+
changesMade = signal<boolean>(false);
7576

7677
currentUser = select(UserSelectors.getCurrentUser);
7778

@@ -150,9 +151,10 @@ export class ContributorsDialogComponent implements OnInit {
150151
this.actions
151152
.bulkAddContributors(this.resourceId, this.resourceType, res.data)
152153
.pipe(takeUntilDestroyed(this.destroyRef))
153-
.subscribe(() =>
154-
this.toastService.showSuccess('project.contributors.toastMessages.multipleAddSuccessMessage')
155-
);
154+
.subscribe(() => {
155+
this.changesMade.set(true);
156+
this.toastService.showSuccess('project.contributors.toastMessages.multipleAddSuccessMessage');
157+
});
156158
}
157159
}
158160
});
@@ -175,7 +177,10 @@ export class ContributorsDialogComponent implements OnInit {
175177
const params = { name: res.data[0].fullName };
176178

177179
this.actions.addContributor(this.resourceId, this.resourceType, res.data[0]).subscribe({
178-
next: () => this.toastService.showSuccess('project.contributors.toastMessages.addSuccessMessage', params),
180+
next: () => {
181+
this.changesMade.set(true);
182+
this.toastService.showSuccess('project.contributors.toastMessages.addSuccessMessage', params);
183+
},
179184
});
180185
}
181186
});
@@ -195,12 +200,13 @@ export class ContributorsDialogComponent implements OnInit {
195200
.pipe(takeUntilDestroyed(this.destroyRef))
196201
.subscribe({
197202
next: () => {
203+
this.changesMade.set(true);
198204
this.toastService.showSuccess('project.contributors.removeDialog.successMessage', {
199205
name: contributor.fullName,
200206
});
201207

202208
if (isDeletingSelf) {
203-
this.dialogRef.close();
209+
this.dialogRef.close(this.changesMade());
204210
this.router.navigate(['/']);
205211
}
206212
},
@@ -218,7 +224,7 @@ export class ContributorsDialogComponent implements OnInit {
218224
}
219225

220226
onClose(): void {
221-
this.dialogRef.close();
227+
this.dialogRef.close(this.changesMade());
222228
}
223229

224230
onSave(): void {
@@ -227,8 +233,9 @@ export class ContributorsDialogComponent implements OnInit {
227233
this.actions
228234
.bulkUpdateContributors(this.resourceId, this.resourceType, updatedContributors)
229235
.pipe(takeUntilDestroyed(this.destroyRef))
230-
.subscribe(() =>
231-
this.toastService.showSuccess('project.contributors.toastMessages.multipleUpdateSuccessMessage')
232-
);
236+
.subscribe(() => {
237+
this.changesMade.set(true);
238+
this.toastService.showSuccess('project.contributors.toastMessages.multipleUpdateSuccessMessage');
239+
});
233240
}
234241
}

src/app/features/metadata/metadata.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
<osf-metadata-contributors
3939
(openEditContributorDialog)="openEditContributorDialog()"
4040
[contributors]="bibliographicContributors()"
41+
[isLoading]="isContributorsLoading()"
42+
[hasMoreContributors]="hasMoreContributors()"
4143
[readonly]="!hasWriteAccess()"
44+
(loadMoreContributors)="handleLoadMoreContributors()"
4245
/>
4346

4447
<osf-metadata-resource-information

src/app/features/metadata/metadata.component.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ import {
2828
FetchResourceInstitutions,
2929
FetchSelectedSubjects,
3030
FetchSubjects,
31-
GetAllContributors,
31+
GetBibliographicContributors,
3232
InstitutionsSelectors,
33+
LoadMoreBibliographicContributors,
3334
SubjectsSelectors,
3435
UpdateContributorsSearchValue,
3536
UpdateResourceInstitutions,
@@ -124,8 +125,9 @@ export class MetadataComponent implements OnInit {
124125
metadata = select(MetadataSelectors.getResourceMetadata);
125126
isMetadataLoading = select(MetadataSelectors.getLoading);
126127
customItemMetadata = select(MetadataSelectors.getCustomItemMetadata);
127-
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributors);
128-
isContributorsLoading = select(ContributorsSelectors.isContributorsLoading);
128+
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributorsList);
129+
isContributorsLoading = select(ContributorsSelectors.isBibliographicContributorsLoading);
130+
hasMoreContributors = select(ContributorsSelectors.hasMoreBibliographicContributors);
129131
cedarRecords = select(MetadataSelectors.getCedarRecords);
130132
cedarTemplates = select(MetadataSelectors.getCedarTemplates);
131133
selectedSubjects = select(SubjectsSelectors.getSelectedSubjects);
@@ -152,7 +154,8 @@ export class MetadataComponent implements OnInit {
152154
updateResourceLicense: UpdateResourceLicense,
153155
getCustomItemMetadata: GetCustomItemMetadata,
154156
updateCustomItemMetadata: UpdateCustomItemMetadata,
155-
getContributors: GetAllContributors,
157+
getContributors: GetBibliographicContributors,
158+
loadMoreBibliographicContributors: LoadMoreBibliographicContributors,
156159
updateResourceInstitutions: UpdateResourceInstitutions,
157160
fetchResourceInstitutions: FetchResourceInstitutions,
158161
createDoi: CreateDoi,
@@ -172,7 +175,6 @@ export class MetadataComponent implements OnInit {
172175
isLoading = computed(
173176
() =>
174177
this.isMetadataLoading() ||
175-
this.isContributorsLoading() ||
176178
this.areInstitutionsLoading() ||
177179
this.isSubmitting() ||
178180
this.areResourceInstitutionsSubmitting()
@@ -320,23 +322,24 @@ export class MetadataComponent implements OnInit {
320322
this.actions.updateMetadata(this.resourceId, this.resourceType(), { tags });
321323
}
322324

325+
handleLoadMoreContributors(): void {
326+
this.actions.loadMoreBibliographicContributors(this.resourceId, this.resourceType());
327+
}
328+
323329
openEditContributorDialog(): void {
324330
this.customDialogService
325331
.open(ContributorsDialogComponent, {
326332
header: 'project.metadata.contributors.editContributors',
327-
width: '600px',
333+
width: '800px',
328334
data: {
329335
resourceId: this.resourceId,
330336
resourceType: this.resourceType(),
331337
},
332338
})
333-
.onClose.subscribe((result) => {
334-
if (result) {
335-
this.actions.getResourceMetadata(this.resourceId, this.resourceType());
336-
this.toastService.showSuccess('project.metadata.contributors.updateSucceed');
339+
.onClose.subscribe((changesMade) => {
340+
if (changesMade) {
341+
this.actions.getContributors(this.resourceId, this.resourceType());
337342
}
338-
339-
this.actions.updateContributorsSearchValue(null);
340343
});
341344
}
342345

src/app/features/preprints/components/preprint-details/general-information/general-information.component.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
<h3>{{ 'preprints.preprintStepper.review.sections.metadata.authors' | translate }}</h3>
88

99
<div class="flex flex-column gap-1 line-height-2 md:flex-row">
10-
<osf-contributors-list [contributors]="bibliographicContributors()"></osf-contributors-list>
11-
12-
@if (areContributorsLoading()) {
13-
<p-skeleton width="10rem" height="1.25rem" />
14-
}
10+
<osf-contributors-list
11+
[contributors]="bibliographicContributors()"
12+
[isLoading]="areContributorsLoading()"
13+
[hasLoadMore]="hasMoreBibliographicContributors()"
14+
(loadMoreContributors)="handleLoadMoreContributors()"
15+
></osf-contributors-list>
1516
</div>
1617
</section>
1718

src/app/features/preprints/components/preprint-details/general-information/general-information.component.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import { ResourceType } from '@osf/shared/enums';
2222
import {
2323
ContributorsSelectors,
2424
FetchResourceInstitutions,
25-
GetAllContributors,
25+
GetBibliographicContributors,
2626
InstitutionsSelectors,
27+
LoadMoreBibliographicContributors,
2728
ResetContributorsState,
2829
} from '@osf/shared/stores';
2930

@@ -53,10 +54,11 @@ export class GeneralInformationComponent implements OnDestroy {
5354
readonly PreregLinkInfo = PreregLinkInfo;
5455

5556
private actions = createDispatchMap({
56-
getContributors: GetAllContributors,
57+
getBibliographicContributors: GetBibliographicContributors,
5758
resetContributorsState: ResetContributorsState,
5859
fetchPreprintById: FetchPreprintById,
5960
fetchResourceInstitutions: FetchResourceInstitutions,
61+
loadMoreBibliographicContributors: LoadMoreBibliographicContributors,
6062
});
6163

6264
preprintProvider = input.required<PreprintProviderDetails | undefined>();
@@ -67,9 +69,9 @@ export class GeneralInformationComponent implements OnDestroy {
6769

6870
affiliatedInstitutions = select(InstitutionsSelectors.getResourceInstitutions);
6971

70-
contributors = select(ContributorsSelectors.getContributors);
71-
areContributorsLoading = select(ContributorsSelectors.isContributorsLoading);
72-
bibliographicContributors = computed(() => this.contributors().filter((contributor) => contributor.isBibliographic));
72+
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributorsList);
73+
areContributorsLoading = select(ContributorsSelectors.isBibliographicContributorsLoading);
74+
hasMoreBibliographicContributors = select(ContributorsSelectors.hasMoreBibliographicContributors);
7375

7476
skeletonData = Array.from({ length: 5 }, () => null);
7577

@@ -80,12 +82,16 @@ export class GeneralInformationComponent implements OnDestroy {
8082
const preprint = this.preprint();
8183
if (!preprint) return;
8284

83-
this.actions.getContributors(this.preprint()!.id, ResourceType.Preprint);
85+
this.actions.getBibliographicContributors(this.preprint()!.id, ResourceType.Preprint);
8486
this.actions.fetchResourceInstitutions(this.preprint()!.id, ResourceType.Preprint);
8587
});
8688
}
8789

8890
ngOnDestroy(): void {
8991
this.actions.resetContributorsState();
9092
}
93+
94+
handleLoadMoreContributors(): void {
95+
this.actions.loadMoreBibliographicContributors(this.preprint()?.id, ResourceType.Preprint);
96+
}
9197
}

src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ <h3>{{ 'preprints.details.reasonForWithdrawal' | translate }}</h3>
1313
<h3>{{ 'preprints.preprintStepper.review.sections.metadata.authors' | translate }}</h3>
1414

1515
<div class="flex flex-column gap-1 line-height-2 md:flex-row">
16-
<osf-contributors-list [contributors]="bibliographicContributors()"></osf-contributors-list>
17-
18-
@if (areContributorsLoading()) {
19-
<p-skeleton width="10rem" height="1.25rem" />
20-
}
16+
<osf-contributors-list
17+
[contributors]="bibliographicContributors()"
18+
[isLoading]="areContributorsLoading()"
19+
[hasLoadMore]="hasMoreBibliographicContributors()"
20+
(loadMoreContributors)="loadMoreContributors()"
21+
></osf-contributors-list>
2122
</div>
2223
</section>
2324

src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import { InterpolatePipe } from '@osf/shared/pipes';
2020
import {
2121
ContributorsSelectors,
2222
FetchSelectedSubjects,
23-
GetAllContributors,
23+
GetBibliographicContributors,
24+
LoadMoreBibliographicContributors,
2425
ResetContributorsState,
2526
SubjectsSelectors,
2627
} from '@osf/shared/stores';
@@ -53,10 +54,11 @@ export class PreprintTombstoneComponent implements OnDestroy {
5354
readonly PreregLinkInfo = PreregLinkInfo;
5455

5556
private actions = createDispatchMap({
56-
getContributors: GetAllContributors,
57+
getBibliographicContributors: GetBibliographicContributors,
5758
resetContributorsState: ResetContributorsState,
5859
fetchPreprintById: FetchPreprintById,
5960
fetchSubjects: FetchSelectedSubjects,
61+
loadMoreBibliographicContributors: LoadMoreBibliographicContributors,
6062
});
6163
private router = inject(Router);
6264

@@ -67,9 +69,9 @@ export class PreprintTombstoneComponent implements OnDestroy {
6769
preprint = select(PreprintSelectors.getPreprint);
6870
isPreprintLoading = select(PreprintSelectors.isPreprintLoading);
6971

70-
contributors = select(ContributorsSelectors.getContributors);
71-
areContributorsLoading = select(ContributorsSelectors.isContributorsLoading);
72-
bibliographicContributors = computed(() => this.contributors().filter((contributor) => contributor.isBibliographic));
72+
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributorsList);
73+
areContributorsLoading = select(ContributorsSelectors.isBibliographicContributorsLoading);
74+
hasMoreBibliographicContributors = select(ContributorsSelectors.hasMoreBibliographicContributors);
7375
subjects = select(SubjectsSelectors.getSelectedSubjects);
7476
areSelectedSubjectsLoading = select(SubjectsSelectors.areSelectedSubjectsLoading);
7577

@@ -88,7 +90,7 @@ export class PreprintTombstoneComponent implements OnDestroy {
8890
const preprint = this.preprint();
8991
if (!preprint) return;
9092

91-
this.actions.getContributors(this.preprint()!.id, ResourceType.Preprint);
93+
this.actions.getBibliographicContributors(this.preprint()?.id, ResourceType.Preprint);
9294
this.actions.fetchSubjects(this.preprint()!.id, ResourceType.Preprint);
9395
});
9496
}
@@ -100,4 +102,8 @@ export class PreprintTombstoneComponent implements OnDestroy {
100102
tagClicked(tag: string) {
101103
this.router.navigate(['/search'], { queryParams: { search: tag } });
102104
}
105+
106+
loadMoreContributors(): void {
107+
this.actions.loadMoreBibliographicContributors(this.preprint()?.id, ResourceType.Preprint);
108+
}
103109
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ <h2>{{ 'preprints.preprintStepper.review.sections.metadata.title' | translate }}
6262
<section class="flex flex-column gap-2">
6363
<h3>{{ 'common.labels.contributors' | translate }}</h3>
6464

65-
<osf-contributors-list [contributors]="bibliographicContributors()"></osf-contributors-list>
65+
<osf-contributors-list
66+
[contributors]="bibliographicContributors()"
67+
[isLoading]="areContributorsLoading()"
68+
[hasLoadMore]="hasMoreBibliographicContributors()"
69+
(loadMoreContributors)="loadMoreContributors()"
70+
></osf-contributors-list>
6671
</section>
6772

6873
@if (affiliatedInstitutions().length) {

0 commit comments

Comments
 (0)