Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: paginator All option displayed only for one element #263

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,12 @@
[rows]="pageSize"
[showCurrentPageReport]="true"
currentPageReportTemplate="{{ (totalRecordsOnServer ? currentPageShowingWithTotalOnServerKey : currentPageShowingKey) | translate:params }}"
[rowsPerPageOptions]="[10, 25, 50, rows?.length]"
[rowsPerPageOptions]="[10, 25, 50, { showAll: ('OCX_DATA_TABLE.ALL' | translate)}]"
id="dataTable_{{name}}"
(selectionChange)="onSelectionChange($event)"
[selection]="(selectedRows$ | async) || []"
[scrollable]="true"
>
<ng-template let-item pTemplate="paginatordropdownitem">
{{ item.value === rows?.length ? ("OCX_DATA_TABLE.ALL" | translate) : item.value }}
</ng-template>
<ng-template pTemplate="header">
<tr>
<th style="width: 4rem" scope="col" *ngIf="selectionChangedObserved">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ describe('DataTableComponent', () => {
const dataTable = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness)
const paginator = await dataTable.getPaginator()
const rowsPerPageOptions = await paginator.getRowsPerPageOptions()
const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(3)
const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(0)
expect(rowsPerPageOptionsText).toEqual('Alle')
})

Expand All @@ -289,11 +289,33 @@ describe('DataTableComponent', () => {
const dataTable = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness)
const paginator = await dataTable.getPaginator()
const rowsPerPageOptions = await paginator.getRowsPerPageOptions()
const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(3)
const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(0)
expect(rowsPerPageOptionsText).toEqual('All')
})
})

it('should display 10 rows by default for 1000 rows', async () => {
component.rows = Array.from(Array(1000).keys()).map((number) => {
return {
id: number,
name: number,
}
})
component.columns = [
{
columnType: ColumnType.NUMBER,
id: 'name',
nameKey: 'COLUMN_HEADER_NAME.NAME',
},
]
component.paginator = true
fixture.detectChanges()

const dataTable = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness)
const rows = await dataTable.getRows()
expect(rows.length).toBe(10)
})

describe('Table row selection', () => {
it('should initially show a table without selection checkboxes', async () => {
expect(dataTable).toBeTruthy()
Expand Down
Loading