@@ -5,7 +5,7 @@ import { TranslatePipe } from '@ngx-translate/core';
55import { Button } from 'primeng/button' ;
66import { Card } from 'primeng/card' ;
77import { Message } from 'primeng/message' ;
8- import { TableModule } from 'primeng/table' ;
8+ import { TableModule , TablePageEvent } from 'primeng/table' ;
99
1010import { filter } from 'rxjs' ;
1111
@@ -24,14 +24,13 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
2424import { FormsModule } from '@angular/forms' ;
2525import { Router } from '@angular/router' ;
2626
27- import { UserSelectors } from '@core/store/user' ;
2827import {
2928 AddContributorDialogComponent ,
3029 AddUnregisteredContributorDialogComponent ,
3130 ContributorsTableComponent ,
3231} from '@osf/shared/components/contributors' ;
3332import { DEFAULT_TABLE_PARAMS } from '@osf/shared/constants' ;
34- import { AddContributorType , ContributorPermission , ResourceType } from '@osf/shared/enums' ;
33+ import { AddContributorType , ResourceType } from '@osf/shared/enums' ;
3534import { findChangedItems } from '@osf/shared/helpers' ;
3635import { ContributorDialogAddModel , ContributorModel , TableParameters } from '@osf/shared/models' ;
3736import { CustomConfirmationService , CustomDialogService , ToastService } from '@osf/shared/services' ;
@@ -64,25 +63,17 @@ export class PreprintsContributorsComponent implements OnInit {
6463 contributors = signal < ContributorModel [ ] > ( [ ] ) ;
6564 contributorsTotalCount = select ( ContributorsSelectors . getContributorsTotalCount ) ;
6665 isContributorsLoading = select ( ContributorsSelectors . isContributorsLoading ) ;
67- currentUser = select ( UserSelectors . getCurrentUser ) ;
66+ page = select ( ContributorsSelectors . getContributorsPageNumber ) ;
67+ pageSize = select ( ContributorsSelectors . getContributorsPageSize ) ;
6868
6969 readonly tableParams = computed < TableParameters > ( ( ) => ( {
7070 ...DEFAULT_TABLE_PARAMS ,
7171 totalRecords : this . contributorsTotalCount ( ) ,
7272 paginator : this . contributorsTotalCount ( ) > DEFAULT_TABLE_PARAMS . rows ,
73+ firstRowIndex : ( this . page ( ) - 1 ) * this . pageSize ( ) ,
74+ rows : this . pageSize ( ) ,
7375 } ) ) ;
7476
75- isCurrentUserAdminContributor = computed ( ( ) => {
76- const currentUserId = this . currentUser ( ) ?. id ;
77- const initialContributors = this . initialContributors ( ) ;
78- if ( ! currentUserId ) return false ;
79-
80- return initialContributors . some (
81- ( contributor : ContributorModel ) =>
82- contributor . userId === currentUserId && contributor . permission === ContributorPermission . Admin
83- ) ;
84- } ) ;
85-
8677 actions = createDispatchMap ( {
8778 getContributors : GetAllContributors ,
8879 deleteContributor : DeleteContributor ,
@@ -171,29 +162,30 @@ export class PreprintsContributorsComponent implements OnInit {
171162 }
172163
173164 removeContributor ( contributor : ContributorModel ) {
174- const isDeletingSelf = contributor . userId === this . currentUser ( ) ?. id ;
175-
176165 this . customConfirmationService . confirmDelete ( {
177166 headerKey : 'project.contributors.removeDialog.title' ,
178167 messageKey : 'project.contributors.removeDialog.message' ,
179168 messageParams : { name : contributor . fullName } ,
180169 acceptLabelKey : 'common.buttons.remove' ,
181170 onConfirm : ( ) => {
182171 this . actions
183- . deleteContributor ( this . preprintId ( ) , ResourceType . Preprint , contributor . userId , isDeletingSelf )
172+ . deleteContributor ( this . preprintId ( ) , ResourceType . Preprint , contributor . userId )
184173 . pipe ( takeUntilDestroyed ( this . destroyRef ) )
185174 . subscribe ( {
186175 next : ( ) => {
187176 this . toastService . showSuccess ( 'project.contributors.removeDialog.successMessage' , {
188177 name : contributor . fullName ,
189178 } ) ;
190-
191- if ( isDeletingSelf ) {
192- this . router . navigate ( [ '/' ] ) ;
193- }
194179 } ,
195180 } ) ;
196181 } ,
197182 } ) ;
198183 }
184+
185+ pageChanged ( event : TablePageEvent ) {
186+ const page = Math . floor ( event . first / event . rows ) + 1 ;
187+ const pageSize = event . rows ;
188+
189+ this . actions . getContributors ( this . preprintId ( ) , ResourceType . Preprint , page , pageSize ) ;
190+ }
199191}
0 commit comments