Skip to content

Commit

Permalink
fix: paging bar ui issues on cart
Browse files Browse the repository at this point in the history
  • Loading branch information
SGrueber committed Mar 15, 2024
1 parent 6a0f9e3 commit cc23804
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 21 deletions.
12 changes: 7 additions & 5 deletions src/app/shared/components/common/paging/paging.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
<ul class="pagination">
<li class="page-item">
<button
type="button"
class="btn btn-primary mb-0"
[disabled]="currentPage === 1"
(click)="setPage(currentPage - 1)"
[attr.aria-label]="'navigation.paging.previous_page.aria_label' | translate"
[title]="'navigation.paging.previous_page.label' | translate"
[attr.aria-disabled]="currentPage === 1"
data-testing-id="paging-previous-button"
>
Expand All @@ -21,10 +22,10 @@
<a
*ngIf="p !== -1; else more"
[attr.aria-current]="p === currentPage ? 'page' : null"
[attr.aria-label]="
[title]="
p === currentPage
? ('navigation.paging.current_page.aria_label' | translate : { '0': p })
: ('navigation.paging.go_to_page.aria_label' | translate : { '0': p })
? ('navigation.paging.current_page.label' | translate : { '0': p })
: ('navigation.paging.go_to_page.label' | translate : { '0': p })
"
tabindex="0"
(click)="setPage(p)"
Expand All @@ -35,10 +36,11 @@
</li>
<li class="page-item">
<button
type="button"
class="btn btn-primary m-0"
[disabled]="currentPage === lastPage"
[title]="'navigation.paging.next_page.label' | translate"
(click)="setPage(currentPage + 1)"
[attr.aria-label]="'navigation.paging.next_page.aria_label' | translate"
[attr.aria-disabled]="currentPage === lastPage"
data-testing-id="paging-next-button"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { spy, verify } from 'ts-mockito';

import { PagingComponent } from './paging.component';

window.scrollTo = jest.fn();

describe('Paging Component', () => {
let component: PagingComponent;
let fixture: ComponentFixture<PagingComponent>;
Expand All @@ -27,6 +29,10 @@ describe('Paging Component', () => {
component.lastPage = 10;
});

afterAll(() => {
jest.clearAllMocks();
});

it('should be created', () => {
expect(component).toBeTruthy();
expect(element).toBeTruthy();
Expand Down
4 changes: 4 additions & 0 deletions src/app/shared/components/common/paging/paging.component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ViewportScroller } from '@angular/common';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';

@Component({
Expand All @@ -14,6 +15,8 @@ export class PagingComponent implements OnChanges {

pageIndices: number[] = [];

constructor(private scroller: ViewportScroller) {}

ngOnChanges(): void {
if (this.currentPage && this.lastPage) {
this.pageIndices = this.getPages(this.currentPage, this.lastPage);
Expand All @@ -26,6 +29,7 @@ export class PagingComponent implements OnChanges {
*/
setPage(page: number) {
this.goToPage.emit(page);
this.scroller.scrollToPosition([0, 0]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
</div>

<div *ngIf="showPagingBar" class="row">
<div
class="col-12 d-flex grey-panel align-items-center flex-column flex-md-row justify-content-between px-3 py-2 mb-3"
>
<span>{{ 'shopping_cart.paging.items.label' | translate : { '0': lineItems.length } }}</span>
<div class="d-flex w-100 grey-panel align-items-center flex-wrap justify-content-between px-3 py-2 mb-3">
<span class="text-nowrap">{{ 'shopping_cart.paging.items.label' | translate : { '0': lineItems.length } }}</span>
<ish-paging [currentPage]="currentPage" [lastPage]="lastPage" (goToPage)="goToPage($event)" />
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/assets/i18n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -907,10 +907,10 @@
"modal.heading.remove.order.template": "Produkt aus Bestellvorlage entfernen",
"navigation.main.aria_label": "Hauptnavigation",
"navigation.paging.aria_label": "Seitennavigation",
"navigation.paging.current_page.aria_label": "Aktuelle Seite: {{0}}",
"navigation.paging.go_to_page.aria_label": "Zu Seite {{0}} gehen",
"navigation.paging.next_page.aria_label": "Zur nächsten Seite gehen",
"navigation.paging.previous_page.aria_label": "Zur vorherigen Seite gehen",
"navigation.paging.current_page.label": "Aktuelle Seite: {{0}}",
"navigation.paging.go_to_page.label": "Zu Seite {{0}} gehen",
"navigation.paging.next_page.label": "Zur nächsten Seite gehen",
"navigation.paging.previous_page.label": "Zur vorherigen Seite gehen",
"order.tracking.error": "Leider konnte keine Bestellung mit Ihren Daten gefunden werden.",
"order_template.create.heading": "Bestellvorlage anlegen",
"payment.error.PaymentInstrumentAlreadyExists": "Das Zahlungsmittel konnte nicht angelegt werden. Zahlungsdaten mit den angegebenen Parametern sind bereits vorhanden.",
Expand Down
8 changes: 4 additions & 4 deletions src/assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -907,10 +907,10 @@
"modal.heading.remove.order.template": "Remove Product From Order Template",
"navigation.main.aria_label": "Main navigation",
"navigation.paging.aria_label": "Page navigation",
"navigation.paging.current_page.aria_label": "Current page: {{0}}",
"navigation.paging.go_to_page.aria_label": "Go to page {{0}}",
"navigation.paging.next_page.aria_label": "Go to next page",
"navigation.paging.previous_page.aria_label": "Go to previous page",
"navigation.paging.current_page.label": "Current page: {{0}}",
"navigation.paging.go_to_page.label": "Go to page {{0}}",
"navigation.paging.next_page.label": "Go to next page",
"navigation.paging.previous_page.label": "Go to previous page",
"order.tracking.error": "Unfortunately, we could not locate an order with the information you provided.",
"order_template.create.heading": "Create Order Template",
"payment.error.PaymentInstrumentAlreadyExists": "The payment instrument could not be created. Payment data with the given parameters already exists.",
Expand Down
8 changes: 4 additions & 4 deletions src/assets/i18n/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -907,10 +907,10 @@
"modal.heading.remove.order.template": "Supprimer le produit du modèle de commande",
"navigation.main.aria_label": "Navigation principale",
"navigation.paging.aria_label": "Navigation dans les pages",
"navigation.paging.current_page.aria_label": "Page actuelle : {{0}}",
"navigation.paging.go_to_page.aria_label": "Aller à la page {{0}}",
"navigation.paging.next_page.aria_label": "Aller à la page suivante",
"navigation.paging.previous_page.aria_label": "Aller à la page précédente",
"navigation.paging.current_page.label": "Page actuelle : {{0}}",
"navigation.paging.go_to_page.label": "Aller à la page {{0}}",
"navigation.paging.next_page.label": "Aller à la page suivante",
"navigation.paging.previous_page.label": "Aller à la page précédente",
"order.tracking.error": "Malheureusement, nous n’avons pas pu localiser une commande avec les informations que vous avez fournies.",
"order_template.create.heading": "Créer un modèle de commande",
"payment.error.PaymentInstrumentAlreadyExists": "Le moyen de paiement n’a pas pu être mis en place. Les données de paiement avec les paramètres fournis existent déjà.",
Expand Down

0 comments on commit cc23804

Please sign in to comment.