Skip to content

Commit

Permalink
fix(graphql): translate pagination texts on initial load
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding-SE committed Oct 29, 2019
1 parent 41e321f commit 3ecd9b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, Component, EventEmitter, Injectable, Input, OnDestroy, Optional, Output } from '@angular/core';
import { AfterViewInit, Component, EventEmitter, Input, OnDestroy, Optional, Output } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Subscription } from 'rxjs';

Expand Down Expand Up @@ -47,6 +47,7 @@ export class SlickPaginationComponent implements AfterViewInit, OnDestroy {
/** Constructor */
constructor(private paginationService: PaginationService, @Optional() private translate: TranslateService) {
// translate all the text using ngx-translate or custom locales
this.translateAllUiTexts(this.locales);
if (translate && translate.onLangChange) {
this.subscriptions.push(this.translate.onLangChange.subscribe(() => this.translateAllUiTexts(this.locales)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class PaginationService {
}

goToLastPage(event?: any): Promise<any> {
this._pageNumber = this._pageCount;
this._pageNumber = this._pageCount || 1;
return this.processOnPageChanged(this._pageNumber, event);
}

Expand Down Expand Up @@ -253,7 +253,7 @@ export class PaginationService {
this._dataTo = 0;
this._pageNumber = 0;
} else {
this._dataFrom = (this._pageNumber * this._itemsPerPage) - this._itemsPerPage + 1;
this._dataFrom = this._pageNumber > 1 ? ((this._pageNumber * this._itemsPerPage) - this._itemsPerPage + 1) : 1;
this._dataTo = (this._totalItems < this._itemsPerPage) ? this._totalItems : (this._pageNumber * this._itemsPerPage);
if (this._dataTo > this._totalItems) {
this._dataTo = this._totalItems;
Expand Down

0 comments on commit 3ecd9b9

Please sign in to comment.