Skip to content

Commit

Permalink
fix index not chanegs on UI
Browse files Browse the repository at this point in the history
  • Loading branch information
rrchai committed Jan 16, 2024
1 parent 60c4fd7 commit 72b8061
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ <h3>
/>
</div>
<openchallenges-paginator
*ngIf="challenges.length > 0"
#paginator
[pageNumber]="selectedPageNumber || defaultPageNumber"
[pageSize]="selectedPageSize || defaultPageSize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class ChallengeSearchComponent
);
this.searchedTerms = params['searchTerms'];
this.selectedPageNumber = +params['pageNumber'] || this.defaultPageNumber;
this.selectedPageSize = +params['pageSize'] || this.defaultPageSize;
this.selectedPageSize = this.defaultPageSize; // no available pageSize options for users
this.sortedBy = params['sort'] || this.defaultSortedBy;

const defaultQuery: ChallengeSearchQuery = {
Expand Down Expand Up @@ -309,6 +309,7 @@ export class ChallengeSearchComponent
// update challenges and total number of results
this.searchResultsCount = page.totalElements;
this.challenges = page.challenges;
console.log(this.paginator.pageNumber);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
[showCurrentPageReport]="true"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} results"
(onPageChange)="onPageChange($event)"
[alwaysShow]="false"
></p-paginator>
10 changes: 5 additions & 5 deletions libs/openchallenges/ui/src/lib/paginator/paginator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Output,
EventEmitter,
ViewChild,
OnInit,
} from '@angular/core';
import {
Paginator,
Expand All @@ -18,7 +19,7 @@ import {
templateUrl: './paginator.component.html',
styleUrls: ['./paginator.component.scss'],
})
export class PaginatorComponent {
export class PaginatorComponent implements OnInit {
@Input({ required: true }) pageNumber = 0; // index of the new page
@Input({ required: false }) pageLinkSize = 5;
@Input({ required: true }) pageSize = 0; // number of items to display in new page
Expand All @@ -29,10 +30,9 @@ export class PaginatorComponent {

itemIndex = 0; // index of the first item in the new page

// change itemIndex's value will not dynamically trigger selection updates - seems a primeng issue
// ngOnInit(): void {
// this.itemIndex = this.pageNumber * this.pageSize;
// }
ngOnInit(): void {
this.itemIndex = this.pageNumber * this.pageSize;
}

onPageChange(event: any): void {
this.pageChange.emit(event);
Expand Down

0 comments on commit 72b8061

Please sign in to comment.