From 628cf115d635cef799b71824baec28e4fbb6d0f9 Mon Sep 17 00:00:00 2001 From: Maximilian Ollendorff Date: Fri, 18 Oct 2024 15:57:31 +0200 Subject: [PATCH 1/3] fix: remove all option from paginators --- libs/angular-accelerator/assets/i18n/de.json | 3 +-- libs/angular-accelerator/assets/i18n/en.json | 3 +-- .../data-list-grid/data-list-grid.component.html | 2 +- .../data-list-grid/data-list-grid.component.ts | 10 +++------- .../components/data-table/data-table.component.html | 2 +- .../lib/components/data-table/data-table.component.ts | 10 +++------- 6 files changed, 10 insertions(+), 20 deletions(-) diff --git a/libs/angular-accelerator/assets/i18n/de.json b/libs/angular-accelerator/assets/i18n/de.json index 49a2e4bb..4855c30a 100644 --- a/libs/angular-accelerator/assets/i18n/de.json +++ b/libs/angular-accelerator/assets/i18n/de.json @@ -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", @@ -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." } -} \ No newline at end of file +} diff --git a/libs/angular-accelerator/assets/i18n/en.json b/libs/angular-accelerator/assets/i18n/en.json index f31bd1d4..5431cbc0 100644 --- a/libs/angular-accelerator/assets/i18n/en.json +++ b/libs/angular-accelerator/assets/i18n/en.json @@ -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", @@ -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." } -} \ No newline at end of file +} diff --git a/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.html b/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.html index 37e8e9e7..3e480dd9 100644 --- a/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.html +++ b/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.html @@ -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" > diff --git a/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.ts b/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.ts index 22fd801b..67c2664f 100644 --- a/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.ts +++ b/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.ts @@ -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([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) } @@ -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) ) diff --git a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html index df7dc0fc..b3766616 100644 --- a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html +++ b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html @@ -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) ?? []" diff --git a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.ts b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.ts index aff1e5ad..029d8544 100644 --- a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.ts +++ b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.ts @@ -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([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 @@ -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) ) From 83ccd460b3631af7a4722afd03721249a3df58a1 Mon Sep 17 00:00:00 2001 From: Maximilian Ollendorff Date: Fri, 18 Oct 2024 16:20:02 +0200 Subject: [PATCH 2/3] fix: update tests --- .../data-list-grid.component.spec.ts | 40 ++++------------- .../data-table/data-table.component.spec.ts | 45 +++---------------- 2 files changed, 15 insertions(+), 70 deletions(-) diff --git a/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.spec.ts b/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.spec.ts index b64c38fc..23b38982 100644 --- a/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.spec.ts +++ b/libs/angular-accelerator/src/lib/components/data-list-grid/data-list-grid.component.spec.ts @@ -23,7 +23,7 @@ describe('DataListGridComponent', () => { return this }) global.MutationObserver = mutationObserverMock - + let fixture: ComponentFixture let component: DataListGridComponent let translateService: TranslateService @@ -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', }, } @@ -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', }, } @@ -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 () => { @@ -356,7 +334,7 @@ describe('DataListGridComponent', () => { component.viewPermission = 'VIEW' component.editPermission = 'EDIT' component.deletePermission = 'DELETE' - + fixture.detectChanges() await fixture.whenStable() } @@ -502,7 +480,7 @@ describe('DataListGridComponent', () => { component.viewPermission = 'VIEW' component.editPermission = 'EDIT' component.deletePermission = 'DELETE' - + fixture.detectChanges() await fixture.whenStable() } diff --git a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.spec.ts b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.spec.ts index 7fc25fc8..6bb4e400 100644 --- a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.spec.ts +++ b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.spec.ts @@ -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', }, } @@ -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', }, } @@ -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 () => { @@ -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'] @@ -501,8 +477,6 @@ describe('DataTableComponent', () => { setUpActionButtonMockData() component.viewActionEnabledField = 'ready' - - let tableActions = await dataTable.getActionButtons() expect(tableActions.length).toBe(3) @@ -522,8 +496,6 @@ describe('DataTableComponent', () => { component.rows = [...tempRows] - - tableActions = await dataTable.getActionButtons() for (const action of tableActions) { @@ -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'] @@ -565,8 +536,6 @@ describe('DataTableComponent', () => { setUpActionButtonMockData() component.viewActionVisibleField = 'ready' - - let tableActions = await dataTable.getActionButtons() expect(tableActions.length).toBe(2) @@ -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'] From 82a2dc59e510e7d1ba7c65e9b2670befccee470f Mon Sep 17 00:00:00 2001 From: Maximilian Ollendorff Date: Fri, 18 Oct 2024 16:27:51 +0200 Subject: [PATCH 3/3] fix: remove translations --- .../src/lib/components/data-view/data-view.component.spec.ts | 3 +-- libs/portal-integration-angular/assets/i18n/de.json | 3 +-- libs/portal-integration-angular/assets/i18n/en.json | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libs/angular-accelerator/src/lib/components/data-view/data-view.component.spec.ts b/libs/angular-accelerator/src/lib/components/data-view/data-view.component.spec.ts index 0d6fad21..2035ec3a 100644 --- a/libs/angular-accelerator/src/lib/components/data-view/data-view.component.spec.ts +++ b/libs/angular-accelerator/src/lib/components/data-view/data-view.component.spec.ts @@ -27,7 +27,7 @@ describe('DataViewComponent', () => { return this }) global.MutationObserver = mutationObserverMock - + let component: DataViewComponent let fixture: ComponentFixture let dataViewHarness: DataViewHarness @@ -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', }, } diff --git a/libs/portal-integration-angular/assets/i18n/de.json b/libs/portal-integration-angular/assets/i18n/de.json index 3b923f78..3d1424b8 100644 --- a/libs/portal-integration-angular/assets/i18n/de.json +++ b/libs/portal-integration-angular/assets/i18n/de.json @@ -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", @@ -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." } -} \ No newline at end of file +} diff --git a/libs/portal-integration-angular/assets/i18n/en.json b/libs/portal-integration-angular/assets/i18n/en.json index bf8467d7..1b5313f5 100644 --- a/libs/portal-integration-angular/assets/i18n/en.json +++ b/libs/portal-integration-angular/assets/i18n/en.json @@ -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", @@ -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." } -} \ No newline at end of file +}