@@ -4,7 +4,7 @@ import { TranslatePipe } from '@ngx-translate/core';
44
55import { Button } from 'primeng/button' ;
66import { Select } from 'primeng/select' ;
7- import { TableModule , TablePageEvent } from 'primeng/table' ;
7+ import { TableModule } from 'primeng/table' ;
88
99import { 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 ( ) {
0 commit comments