Skip to content

Commit 3c224e8

Browse files
committed
Simplify code of pagination interface
1 parent b7b946d commit 3c224e8

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

client/app/src/shared/components/paginated-interface/paginated-interface.component.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,33 +49,24 @@ export class PaginatedInterfaceComponent<T> implements AfterViewInit, DoCheck, O
4949
constructor(private iterableDiffers: IterableDiffers) {}
5050

5151
ngAfterViewInit(): void {
52-
this.updatePaginatedItems();
52+
this.update();
5353
}
5454

5555
ngDoCheck(): void {
5656
const changes = this.differ.diff(this.items);
5757
if (changes) {
58-
this.updatePaginatedItems();
58+
this.update();
5959
}
6060
}
6161

6262
ngOnChanges(changes: SimpleChanges): void {
6363
if (changes['items'] || changes['filter'] || changes['orderBy'] || changes['orderDesc']) {
64-
this.currentPage = 1;
65-
this.updatePaginatedItems();
64+
this.update();
6665
}
6766
}
6867

69-
onSearchChange(): void {
70-
this.currentPage = 1; // reset page on search change
71-
this.updatePaginatedItems();
72-
}
73-
74-
onPaginationChange(): void {
75-
this.updatePaginatedItems();
76-
}
77-
78-
private updatePaginatedItems(): void {
68+
update(): void {
69+
this.currentPage = 1;
7970
this.filteredItems = [...this.items];
8071

8172
// Apply optional filter object

0 commit comments

Comments
 (0)