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

feat/P002271-7725-remove-all-option #550

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions libs/angular-accelerator/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"EDITED": "Bearbeitet",
"SHOWING": "{{first}} - {{last}} von {{totalRecords}}",
"SHOWING_WITH_TOTAL_ON_SERVER": "{{first}} - {{last}} von {{totalRecords}} ({{totalRecordsOnServer}})",
"ALL": "Alle",
"MORE_ACTIONS": "Weitere Aktionen",
"ACTIONS": {
"VIEW": "Anzeigen",
Expand Down Expand Up @@ -159,4 +158,4 @@
"TITLE": "Die Daten konnten nicht geladen werden.",
"MESSAGE": "Dies kann folgende Gründe haben: \n -Die Daten existieren nicht oder nicht mehr.\n - Die Daten konnten aufgrund eines Fehlers im System nicht geladen werden.\n - Ihnen fehlt die nötige Berechtigung um die Daten zu laden.\n Bitte kontaktieren Sie den Support, wenn Sie glauben, dass es sich hierbei um einen Fehler des Systems handelt."
}
}
}
3 changes: 1 addition & 2 deletions libs/angular-accelerator/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"EDITED": "Edited",
"SHOWING": "{{first}} - {{last}} of {{totalRecords}}",
"SHOWING_WITH_TOTAL_ON_SERVER": "{{first}} - {{last}} of {{totalRecords}} ({{totalRecordsOnServer}})",
"ALL": "All",
"MORE_ACTIONS": "More actions",
"ACTIONS": {
"VIEW": "View",
Expand Down Expand Up @@ -159,4 +158,4 @@
"TITLE": "The data could not be loaded.",
"MESSAGE": "This may have the following reasons:\n The data does not exist or no longer exists.\n The data could not be loaded due to an error in the system.\n You do not have the necessary permission to load the data.\n Please contact the support if you think this happened due to a system error."
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[layout]="layout"
[showCurrentPageReport]="true"
currentPageReportTemplate="{{ (totalRecordsOnServer ? currentPageShowingWithTotalOnServerKey : currentPageShowingKey) | translate:params }}"
[rowsPerPageOptions]="(displayedPageSizes$ | async) ?? []"
[rowsPerPageOptions]="this.pageSizes ?? []"
id="dataListGrid_{{name}}"
paginatorDropdownAppendTo="body"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('DataListGridComponent', () => {
return this
})
global.MutationObserver = mutationObserverMock

let fixture: ComponentFixture<DataListGridComponent>
let component: DataListGridComponent
let translateService: TranslateService
Expand All @@ -34,7 +34,6 @@ describe('DataListGridComponent', () => {
OCX_DATA_TABLE: {
SHOWING: '{{first}} - {{last}} of {{totalRecords}}',
SHOWING_WITH_TOTAL_ON_SERVER: '{{first}} - {{last}} of {{totalRecords}} ({{totalRecordsOnServer}})',
ALL: 'All',
},
}

Expand All @@ -43,7 +42,6 @@ describe('DataListGridComponent', () => {
OCX_DATA_TABLE: {
SHOWING: '{{first}} - {{last}} von {{totalRecords}}',
SHOWING_WITH_TOTAL_ON_SERVER: '{{first}} - {{last}} von {{totalRecords}} ({{totalRecordsOnServer}})',
ALL: 'Alle',
},
}

Expand Down Expand Up @@ -293,32 +291,12 @@ describe('DataListGridComponent', () => {
})
})

describe('should display the paginator rowsPerPageOptions -', () => {
it('de', async () => {
window.HTMLElement.prototype.scrollIntoView = jest.fn()
translateService.use('de')
fixture = TestBed.createComponent(DataListGridComponent)
component = fixture.componentInstance
component.data = mockData
component.columns = mockColumns
component.paginator = true
fixture.detectChanges()
const dataListGrid = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness)
const paginator = await dataListGrid.getPaginator()
const rowsPerPageOptions = await paginator.getRowsPerPageOptions()
const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(0)
expect(rowsPerPageOptionsText).toEqual('Alle')
})

it('en', async () => {
window.HTMLElement.prototype.scrollIntoView = jest.fn()
translateService.use('en')
const dataListGrid = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness)
const paginator = await dataListGrid.getPaginator()
const rowsPerPageOptions = await paginator.getRowsPerPageOptions()
const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(0)
expect(rowsPerPageOptionsText).toEqual('All')
})
it('should display the paginator rowsPerPageOptions', async () => {
const dataListGrid = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness)
const paginator = await dataListGrid.getPaginator()
const rowsPerPageOptions = await paginator.getRowsPerPageOptions()
const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(0)
expect(rowsPerPageOptionsText).toEqual('10')
})

const setUpListActionButtonMockData = async () => {
Expand Down Expand Up @@ -356,7 +334,7 @@ describe('DataListGridComponent', () => {
component.viewPermission = 'VIEW'
component.editPermission = 'EDIT'
component.deletePermission = 'DELETE'

fixture.detectChanges()
await fixture.whenStable()
}
Expand Down Expand Up @@ -502,7 +480,7 @@ describe('DataListGridComponent', () => {
component.viewPermission = 'VIEW'
component.editPermission = 'EDIT'
component.deletePermission = 'DELETE'

fixture.detectChanges()
await fixture.whenStable()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,12 @@ export class DataListGridComponent extends DataSortBase implements OnInit, DoChe
@Input() clientSideFiltering = true
@Input() sortStates: DataSortDirection[] = []

displayedPageSizes$: Observable<(number | { showAll: string })[]>
_pageSizes$ = new BehaviorSubject<(number | { showAll: string })[]>([10, 25, 50])
_pageSizes$ = new BehaviorSubject<number[]>([10, 25, 50])
@Input()
get pageSizes(): (number | { showAll: string })[] {
get pageSizes(): number[] {
return this._pageSizes$.getValue()
}
set pageSizes(value: (number | { showAll: string })[]) {
set pageSizes(value: number[]) {
this._pageSizes$.next(value)
}

Expand Down Expand Up @@ -332,9 +331,6 @@ export class DataListGridComponent extends DataSortBase implements OnInit, DoChe
this.fallbackImagePath$ = this.appStateService.currentMfe$.pipe(
map((currentMfe) => this.getFallbackImagePath(currentMfe))
)
this.displayedPageSizes$ = combineLatest([this._pageSizes$, this.translateService.get('OCX_DATA_TABLE.ALL')]).pipe(
map(([pageSizes, translation]) => pageSizes.concat({ showAll: translation }))
)
this.displayedPageSize$ = combineLatest([this._pageSize$, this._pageSizes$]).pipe(
map(([pageSize, pageSizes]) => pageSize ?? pageSizes.find((val): val is number => typeof val === 'number') ?? 50)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
[rows]="displayedPageSize"
[showCurrentPageReport]="true"
currentPageReportTemplate="{{ (totalRecordsOnServer ? currentPageShowingWithTotalOnServerKey : currentPageShowingKey) | translate:params }}"
[rowsPerPageOptions]="(displayedPageSizes$ | async) ?? []"
[rowsPerPageOptions]="this.pageSizes ?? []"
id="dataTable_{{name}}"
(selectionChange)="onSelectionChange($event)"
[selection]="(selectedRows$ | async) ?? []"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('DataTableComponent', () => {
OCX_DATA_TABLE: {
SHOWING: '{{first}} - {{last}} of {{totalRecords}}',
SHOWING_WITH_TOTAL_ON_SERVER: '{{first}} - {{last}} of {{totalRecords}} ({{totalRecordsOnServer}})',
ALL: 'All',
},
}

Expand All @@ -35,7 +34,6 @@ describe('DataTableComponent', () => {
OCX_DATA_TABLE: {
SHOWING: '{{first}} - {{last}} von {{totalRecords}}',
SHOWING_WITH_TOTAL_ON_SERVER: '{{first}} - {{last}} von {{totalRecords}} ({{totalRecordsOnServer}})',
ALL: 'Alle',
},
}

Expand Down Expand Up @@ -272,32 +270,12 @@ describe('DataTableComponent', () => {
})
})

describe('should display the paginator rowsPerPageOptions -', () => {
it('de', async () => {
window.HTMLElement.prototype.scrollIntoView = jest.fn()
translateService.use('de')
fixture = TestBed.createComponent(DataTableComponent)
component = fixture.componentInstance
component.rows = mockData
component.columns = mockColumns
component.paginator = true
fixture.detectChanges()
const dataTable = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness)
const paginator = await dataTable.getPaginator()
const rowsPerPageOptions = await paginator.getRowsPerPageOptions()
const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(0)
expect(rowsPerPageOptionsText).toEqual('Alle')
})

it('en', async () => {
window.HTMLElement.prototype.scrollIntoView = jest.fn()
translateService.use('en')
const dataTable = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness)
const paginator = await dataTable.getPaginator()
const rowsPerPageOptions = await paginator.getRowsPerPageOptions()
const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(0)
expect(rowsPerPageOptionsText).toEqual('All')
})
it('should display the paginator rowsPerPageOptions', async () => {
const dataTable = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness)
const paginator = await dataTable.getPaginator()
const rowsPerPageOptions = await paginator.getRowsPerPageOptions()
const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(0)
expect(rowsPerPageOptionsText).toEqual('10')
})

it('should display 10 rows by default for 1000 rows', async () => {
Expand Down Expand Up @@ -478,8 +456,6 @@ describe('DataTableComponent', () => {
expect(component.editTableRowObserved).toBe(true)
expect(component.deleteTableRowObserved).toBe(true)



const tableActions = await dataTable.getActionButtons()
expect(tableActions.length).toBe(3)
const expectedIcons = ['pi pi-eye', 'pi pi-trash', 'pi pi-pencil']
Expand All @@ -501,8 +477,6 @@ describe('DataTableComponent', () => {
setUpActionButtonMockData()
component.viewActionEnabledField = 'ready'



let tableActions = await dataTable.getActionButtons()
expect(tableActions.length).toBe(3)

Expand All @@ -522,8 +496,6 @@ describe('DataTableComponent', () => {

component.rows = [...tempRows]



tableActions = await dataTable.getActionButtons()

for (const action of tableActions) {
Expand All @@ -544,7 +516,6 @@ describe('DataTableComponent', () => {
expect(component.editTableRowObserved).toBe(true)
expect(component.deleteTableRowObserved).toBe(true)


const tableActions = await dataTable.getActionButtons()
expect(tableActions.length).toBe(3)
const expectedIcons = ['pi pi-eye', 'pi pi-trash', 'pi pi-pencil']
Expand All @@ -565,8 +536,6 @@ describe('DataTableComponent', () => {
setUpActionButtonMockData()
component.viewActionVisibleField = 'ready'



let tableActions = await dataTable.getActionButtons()
expect(tableActions.length).toBe(2)

Expand All @@ -581,8 +550,6 @@ describe('DataTableComponent', () => {

component.rows = [...tempRows]



tableActions = await dataTable.getActionButtons()
expect(tableActions.length).toBe(3)
const expectedIcons = ['pi pi-eye', 'pi pi-trash', 'pi pi-pencil']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,12 @@ export class DataTableComponent extends DataSortBase implements OnInit, AfterCon
@Input() clientSideSorting = true
@Input() sortStates: DataSortDirection[] = [DataSortDirection.ASCENDING, DataSortDirection.DESCENDING]

displayedPageSizes$: Observable<(number | { showAll: string })[]>
_pageSizes$ = new BehaviorSubject<(number | { showAll: string })[]>([10, 25, 50])
_pageSizes$ = new BehaviorSubject<number[]>([10, 25, 50])
@Input()
get pageSizes(): (number | { showAll: string })[] {
get pageSizes(): number[] {
return this._pageSizes$.getValue()
}
set pageSizes(value: (number | { showAll: string })[]) {
set pageSizes(value: number[]) {
this._pageSizes$.next(value)
}
displayedPageSize$: Observable<number>
Expand Down Expand Up @@ -390,9 +389,6 @@ export class DataTableComponent extends DataSortBase implements OnInit, AfterCon
) {
super(locale, translateService)
this.name = this.name || this.router.url.replace(/[^A-Za-z0-9]/, '_')
this.displayedPageSizes$ = combineLatest([this._pageSizes$, this.translateService.get('OCX_DATA_TABLE.ALL')]).pipe(
map(([pageSizes, translation]) => pageSizes.concat({ showAll: translation }))
)
this.displayedPageSize$ = combineLatest([this._pageSize$, this._pageSizes$]).pipe(
map(([pageSize, pageSizes]) => pageSize ?? pageSizes.find((val): val is number => typeof val === 'number') ?? 50)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('DataViewComponent', () => {
return this
})
global.MutationObserver = mutationObserverMock

let component: DataViewComponent
let fixture: ComponentFixture<DataViewComponent>
let dataViewHarness: DataViewHarness
Expand All @@ -37,7 +37,6 @@ describe('DataViewComponent', () => {
OCX_DATA_TABLE: {
SHOWING: '{{first}} - {{last}} of {{totalRecords}}',
SHOWING_WITH_TOTAL_ON_SERVER: '{{first}} - {{last}} of {{totalRecords}} ({{totalRecordsOnServer}})',
ALL: 'All',
},
}

Expand Down
3 changes: 1 addition & 2 deletions libs/portal-integration-angular/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"EDITED": "Bearbeitet",
"SHOWING": "{{first}} - {{last}} von {{totalRecords}}",
"SHOWING_WITH_TOTAL_ON_SERVER": "{{first}} - {{last}} von {{totalRecords}} ({{totalRecordsOnServer}})",
"ALL": "Alle",
"MORE_ACTIONS": "Weitere Aktionen",
"ACTIONS": {
"VIEW": "Anzeigen",
Expand Down Expand Up @@ -180,4 +179,4 @@
"TITLE": "Die Daten konnten nicht geladen werden.",
"MESSAGE": "Dies kann folgende Gründe haben: \n - Die Daten existieren nicht oder nicht mehr. \n - Die Daten konnten aufgrund eines Fehlers im System nicht geladen werden. \n - Ihnen fehlt die nötige Berechtigung um die Daten zu laden. \nBitte kontaktieren Sie den Support, wenn Sie glauben, dass es sich hierbei um einen Fehler des Systems handelt."
}
}
}
3 changes: 1 addition & 2 deletions libs/portal-integration-angular/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"EDITED": "Edited",
"SHOWING": "{{first}} - {{last}} of {{totalRecords}}",
"SHOWING_WITH_TOTAL_ON_SERVER": "{{first}} - {{last}} of {{totalRecords}} ({{totalRecordsOnServer}})",
"ALL": "All",
"MORE_ACTIONS": "More actions",
"ACTIONS": {
"VIEW": "View",
Expand Down Expand Up @@ -180,4 +179,4 @@
"TITLE": "The data could not be loaded.",
"MESSAGE": "This may have the following reasons:\n The data does not exist or no longer exists.\n The data could not be loaded due to an error in the system.\n You do not have the necessary permission to load the data.\n Please contact the support if you think this happened due to a system error."
}
}
}