Skip to content

Commit 4caec3b

Browse files
milanmajchrakclaude
andcommitted
UoE/Add results-per-page selector to statistics tables (DSpace#726)
Re-enable the standard ds-pagination "results per page" selector (gear) so users can choose how many datasets to show per page (10/20/40/60/80/100), reusing the built-in PaginationComponent control. The gear and pagination detail are shown only when a report has more rows than fit on one page; pageSize remains the default. The page slicing already honours the selected size. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 8a67dfe commit 4caec3b

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/app/statistics-page/statistics-table/statistics-table.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ <h2 class="m-1">
77

88
<ds-pagination [paginationOptions]="paginationOptions"
99
[collectionSize]="report.points.length"
10-
[hideGear]="true"
10+
[hideGear]="report.points.length <= pageSize"
1111
[hidePaginationDetail]="report.points.length <= pageSize"
1212
[hideSortOptions]="true"
1313
[retainScrollPosition]="true">

src/app/statistics-page/statistics-table/statistics-table.component.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ describe('StatisticsTableComponent', () => {
148148
expect(pagination).toBeTruthy();
149149
expect(pagination.componentInstance.collectionSize).toEqual(2);
150150
});
151+
152+
it('should hide the page-size selector when everything fits on a single page', () => {
153+
expect(de.query(By.directive(MockPaginationComponent)).componentInstance.hideGear).toBeTrue();
154+
});
151155
});
152156

153157
describe('when the report has more points than the page size', () => {
@@ -175,6 +179,12 @@ describe('StatisticsTableComponent', () => {
175179
.toEqual(numberOfPoints);
176180
});
177181

182+
it('should offer the page-size selector with its options when there is more than one page', () => {
183+
const pagination = de.query(By.directive(MockPaginationComponent)).componentInstance;
184+
expect(pagination.hideGear).toBeFalse();
185+
expect(pagination.paginationOptions.pageSizeOptions).toEqual([10, 20, 40, 60, 80, 100]);
186+
});
187+
178188
it('should only render the first page of points', () => {
179189
expect(de.queryAll(By.css('[data-test="statistics-label"]')).length)
180190
.toEqual(component.pageSize);

src/app/statistics-page/statistics-table/statistics-table.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ export class StatisticsTableComponent implements OnInit {
9696
// Unique per report AND scope so multiple tables paginate independently and a report doesn't pick up
9797
// another scope's page from the URL. report.id is `<dso-uuid>_<reportType>`, e.g. `<uuid>_TotalVisits`.
9898
id: `stats-${this.report.id}`,
99+
// pageSize is the default; users can change it via the ds-pagination "results per page" selector.
99100
pageSize: this.pageSize,
101+
pageSizeOptions: [10, 20, 40, 60, 80, 100],
100102
currentPage: 1,
101103
});
102104

0 commit comments

Comments
 (0)