From f2e1b532489ad43a1d476bd957157009fc841f33 Mon Sep 17 00:00:00 2001 From: nsemets Date: Tue, 14 Apr 2026 15:15:36 +0300 Subject: [PATCH] fix(contributors): updated show load more logic for contributors --- .../project-contributors-step.component.html | 1 + .../project-contributors-step.component.ts | 7 +++--- .../contributors/contributors.component.html | 1 + .../contributors/contributors.component.ts | 5 +++-- .../contributors-dialog.component.html | 1 + .../contributors-dialog.component.ts | 2 ++ .../preprints-contributors.component.html | 1 + .../preprints-contributors.component.ts | 1 + .../registries-contributors.component.html | 1 + .../registries-contributors.component.ts | 1 + .../contributors-table.component.html | 22 +++++++++---------- .../contributors-table.component.ts | 7 +----- 12 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.html b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.html index bc0195260..43d53e657 100644 --- a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.html +++ b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.html @@ -42,6 +42,7 @@

{{ 'collections.addToCollection.projectContributors' | translate }}

[(contributors)]="projectContributors" [tableParams]="tableParams()" [isLoading]="isContributorsLoading()" + [showLoadMore]="hasMoreContributors()" [isLoadingMore]="isLoadingMore()" (remove)="handleRemoveContributor($event)" (loadMore)="loadMoreContributors()" diff --git a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts index 6fcba6f9a..a552d4206 100644 --- a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts +++ b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts @@ -62,15 +62,16 @@ export class ProjectContributorsStepComponent { private readonly customConfirmationService = inject(CustomConfirmationService); private readonly router = inject(Router); + readonly currentUser = select(UserSelectors.getCurrentUser); readonly isContributorsLoading = select(ContributorsSelectors.isContributorsLoading); readonly contributorsTotalCount = select(ContributorsSelectors.getContributorsTotalCount); readonly selectedProject = select(ProjectsSelectors.getSelectedProject); - readonly currentUser = select(UserSelectors.getCurrentUser); - isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore); + readonly isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore); + readonly hasMoreContributors = select(ContributorsSelectors.hasMoreContributors); + readonly pageSize = select(ContributorsSelectors.getContributorsPageSize); private initialContributors = select(ContributorsSelectors.getContributors); readonly projectContributors = signal([]); - pageSize = select(ContributorsSelectors.getContributorsPageSize); readonly tableParams = computed(() => ({ ...DEFAULT_TABLE_PARAMS, diff --git a/src/app/features/contributors/contributors.component.html b/src/app/features/contributors/contributors.component.html index 2f43f5b60..fbcd27799 100644 --- a/src/app/features/contributors/contributors.component.html +++ b/src/app/features/contributors/contributors.component.html @@ -67,6 +67,7 @@

{{ 'navigation.contributors' | translate } [tableParams]="tableParams()" [hasAdminAccess]="hasAdminAccess()" [currentUserId]="currentUser()?.id" + [showLoadMore]="hasMoreContributors()" [showCurator]="true" [showInfo]="true" [resourceType]="resourceType()" diff --git a/src/app/features/contributors/contributors.component.ts b/src/app/features/contributors/contributors.component.ts index 9be8e6435..14e627c84 100644 --- a/src/app/features/contributors/contributors.component.ts +++ b/src/app/features/contributors/contributors.component.ts @@ -134,11 +134,12 @@ export class ContributorsComponent implements OnInit, OnDestroy { readonly isContributorsLoading = select(ContributorsSelectors.isContributorsLoading); readonly contributorsTotalCount = select(ContributorsSelectors.getContributorsTotalCount); readonly isViewOnlyLinksLoading = select(ViewOnlyLinkSelectors.isViewOnlyLinksLoading); + readonly isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore); + readonly pageSize = select(ContributorsSelectors.getContributorsPageSize); + readonly hasMoreContributors = select(ContributorsSelectors.hasMoreContributors); readonly hasAdminAccess = select(CurrentResourceSelectors.hasResourceAdminAccess); readonly resourceAccessRequestEnabled = select(CurrentResourceSelectors.resourceAccessRequestEnabled); readonly currentUser = select(UserSelectors.getCurrentUser); - pageSize = select(ContributorsSelectors.getContributorsPageSize); - isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore); readonly tableParams = computed(() => ({ ...DEFAULT_TABLE_PARAMS, diff --git a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.html b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.html index 4ff339220..787fa2208 100644 --- a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.html +++ b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.html @@ -20,6 +20,7 @@ [tableParams]="tableParams()" [isLoading]="isLoading()" [isLoadingMore]="isLoadingMore()" + [showLoadMore]="hasMoreContributors()" [showEmployment]="false" [showEducation]="false" [hasAdminAccess]="hasAdminAccess()" diff --git a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts index f9a6d0b3d..f02aa55fe 100644 --- a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts +++ b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts @@ -75,7 +75,9 @@ export class ContributorsDialogComponent implements OnInit { hasAdminAccess = select(MetadataSelectors.hasAdminAccess); contributors = signal([]); isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore); + hasMoreContributors = select(ContributorsSelectors.hasMoreContributors); pageSize = select(ContributorsSelectors.getContributorsPageSize); + changesMade = signal(false); currentUser = select(UserSelectors.getCurrentUser); diff --git a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.html b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.html index 76023ffe3..cee666a6f 100644 --- a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.html +++ b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.html @@ -12,6 +12,7 @@

{{ 'common.labels.contributors' | translate }}

[(contributors)]="contributors" [tableParams]="tableParams()" [isLoading]="isContributorsLoading()" + [showLoadMore]="hasMoreContributors()" [isLoadingMore]="isLoadingMore()" (remove)="removeContributor($event)" (loadMore)="loadMoreContributors()" diff --git a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts index aad0b7305..6ac337dd1 100644 --- a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts +++ b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts @@ -64,6 +64,7 @@ export class PreprintsContributorsComponent implements OnInit { readonly contributors = signal([]); readonly contributorsTotalCount = select(ContributorsSelectors.getContributorsTotalCount); readonly isContributorsLoading = select(ContributorsSelectors.isContributorsLoading); + readonly hasMoreContributors = select(ContributorsSelectors.hasMoreContributors); readonly isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore); readonly pageSize = select(ContributorsSelectors.getContributorsPageSize); diff --git a/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.html b/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.html index 6006754c0..725d9005b 100644 --- a/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.html +++ b/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.html @@ -6,6 +6,7 @@

{{ 'common.labels.contributors' | translate }}

[(contributors)]="contributors" [tableParams]="tableParams()" [isLoading]="isContributorsLoading()" + [showLoadMore]="hasMoreContributors()" [isLoadingMore]="isLoadingMore()" (remove)="removeContributor($event)" (loadMore)="loadMoreContributors()" diff --git a/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts b/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts index af89f0281..a2e1f3542 100644 --- a/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts +++ b/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts @@ -68,6 +68,7 @@ export class RegistriesContributorsComponent implements OnInit, OnDestroy { isContributorsLoading = select(ContributorsSelectors.isContributorsLoading); contributorsTotalCount = select(ContributorsSelectors.getContributorsTotalCount); + hasMoreContributors = select(ContributorsSelectors.hasMoreContributors); isLoadingMore = select(ContributorsSelectors.isContributorsLoadingMore); pageSize = select(ContributorsSelectors.getContributorsPageSize); diff --git a/src/app/shared/components/contributors/contributors-table/contributors-table.component.html b/src/app/shared/components/contributors/contributors-table/contributors-table.component.html index daaa9ba85..36b516a90 100644 --- a/src/app/shared/components/contributors/contributors-table/contributors-table.component.html +++ b/src/app/shared/components/contributors/contributors-table/contributors-table.component.html @@ -174,19 +174,19 @@ } + - @if (showLoadMore() && index === contributors().length - 1) { + + @if (showLoadMore()) { - -
- -
+ + } diff --git a/src/app/shared/components/contributors/contributors-table/contributors-table.component.ts b/src/app/shared/components/contributors/contributors-table/contributors-table.component.ts index 80fcb5528..d41244e28 100644 --- a/src/app/shared/components/contributors/contributors-table/contributors-table.component.ts +++ b/src/app/shared/components/contributors/contributors-table/contributors-table.component.ts @@ -50,6 +50,7 @@ export class ContributorsTableComponent { showEducation = input(true); showEmployment = input(true); showInfo = input(false); + showLoadMore = input(false); resourceType = input(ResourceType.Project); currentUserId = input(undefined); @@ -69,12 +70,6 @@ export class ContributorsTableComponent { deactivatedContributors = computed(() => this.contributors().some((contributor) => contributor.deactivated)); - showLoadMore = computed(() => { - const currentLoadedItems = this.contributors().length; - const totalRecords = this.tableParams().totalRecords; - return currentLoadedItems > 0 && currentLoadedItems < totalRecords; - }); - removeContributor(contributor: ContributorModel) { this.remove.emit(contributor); }