Skip to content

Commit

Permalink
feat(backend): extract Pagination into its own Service to expose methods
Browse files Browse the repository at this point in the history
- with this new Service, user can now programmatically change page from its application since the Pagination Service is now exposed to the outside
  • Loading branch information
ghiscoding-SE committed Oct 4, 2019
1 parent 388503d commit 4a4a708
Show file tree
Hide file tree
Showing 13 changed files with 982 additions and 250 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { AngularUtilService } from '../services/angularUtil.service';
import { SlickgridConfig } from './../slickgrid-config';
import { FilterFactory } from './../filters/filterFactory';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule, TranslateService } from '@ngx-translate/core';

import { SlickgridConfig } from './../slickgrid-config';
import { FilterFactory } from './../filters/filterFactory';

import { AngularSlickgridComponent } from './angular-slickgrid.component';
import { SlickPaginationComponent } from './slick-pagination.component';
import { CollectionService } from '../services/collection.service';
import {
AngularUtilService,
ExportService,
ExtensionService,
FilterService,
GridService,
GridEventService,
GridStateService,
GroupingAndColspanService,
PaginationService,
ResizerService,
SharedService,
SortService
Expand Down Expand Up @@ -81,6 +83,7 @@ describe('App Component', () => {
GridEventService,
GridStateService,
GroupingAndColspanService,
PaginationService,
ResizerService,
SharedService,
TranslateService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { GridEventService } from './../services/gridEvent.service';
import { GridService } from './../services/grid.service';
import { GridStateService } from './../services/gridState.service';
import { GroupingAndColspanService } from './../services/groupingAndColspan.service';
import { PaginationService } from '../services/pagination.service';
import { ResizerService } from './../services/resizer.service';
import { SharedService } from '../services/shared.service';
import { SortService } from './../services/sort.service';
Expand Down Expand Up @@ -88,6 +89,7 @@ const slickgridEventPrefix = 'sg';
GroupItemMetaProviderExtension,
HeaderButtonExtension,
HeaderMenuExtension,
PaginationService,
ResizerService,
RowDetailViewExtension,
RowMoveManagerExtension,
Expand Down Expand Up @@ -165,6 +167,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
private gridEventService: GridEventService,
private gridStateService: GridStateService,
private groupingAndColspanService: GroupingAndColspanService,
private paginationService: PaginationService,
private resizer: ResizerService,
private sharedService: SharedService,
private sortService: SortService,
Expand Down Expand Up @@ -196,6 +199,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
this.gridEventService.dispose();
this.gridStateService.dispose();
this.groupingAndColspanService.dispose();
this.paginationService.dispose();
this.resizer.dispose();
this.sortService.dispose();
if (this._eventHandler && this._eventHandler.unsubscribeAll) {
Expand Down Expand Up @@ -345,6 +349,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
gridStateService: this.gridStateService,
gridService: this.gridService,
groupingService: this.groupingAndColspanService,
paginationService: this.paginationService,
resizerService: this.resizer,
sortService: this.sortService,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,51 @@
<div class="slick-pagination">
<div class="slick-pagination-nav">
<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item" [ngClass]="(pageNumber === 1 || totalItems === 0) ? 'disabled' : ''">
<a class="page-link icon-seek-first fa fa-angle-double-left" aria-label="First" (click)="changeToFirstPage($event)">
</a>
</li>
<li class="page-item" [ngClass]="(pageNumber === 1 || totalItems === 0) ? 'disabled' : ''">
<a class="page-link icon-seek-prev fa fa-angle-left" aria-label="Previous" (click)="changeToPreviousPage($event)">
</a>
</li>
</ul>
</nav>
<div class="slick-pagination" *ngIf="pager">
<div class="slick-pagination-nav">
<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item" [ngClass]="(pager?.pageNumber === 1 || pager?.totalItems === 0) ? 'disabled' : ''">
<a class="page-link icon-seek-first fa fa-angle-double-left" aria-label="First"
(click)="changeToFirstPage($event)">
</a>
</li>
<li class="page-item" [ngClass]="(pager?.pageNumber === 1 || pager?.totalItems === 0) ? 'disabled' : ''">
<a class="page-link icon-seek-prev fa fa-angle-left" aria-label="Previous"
(click)="changeToPreviousPage($event)">
</a>
</li>
</ul>
</nav>

<div class="slick-page-number">
<span>{{textPage}}</span>
<input type="text" class="form-control" [value]="pageNumber" size="1" [readOnly]="totalItems === 0" (change)="changeToCurrentPage($event)">
<span>{{textOf}}</span><span> {{pageCount}}</span>
</div>

<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item" [ngClass]="(pageNumber === pageCount || totalItems === 0) ? 'disabled' : ''">
<a class="page-link icon-seek-next text-center fa fa-lg fa-angle-right" aria-label="Next" (click)="changeToNextPage($event)">
</a>
</li>
<li class="page-item" [ngClass]="(pageNumber === pageCount || totalItems === 0) ? 'disabled' : ''">
<a class="page-link icon-seek-end fa fa-lg fa-angle-double-right" aria-label="Last" (click)="changeToLastPage($event)">
</a>
</li>
</ul>
</nav>
<div class="slick-page-number">
<span>{{textPage}}</span>
<input type="text" class="form-control" [value]="pager?.pageNumber" size="1" [readOnly]="pager?.totalItems === 0"
(change)="changeToCurrentPage($event)">
<span>{{textOf}}</span><span> {{pager?.pageCount}}</span>
</div>
<span class="slick-pagination-settings">
<select id="items-per-page-label" [value]="itemsPerPage" (change)="onChangeItemPerPage($event)">
<option value="{{pageSize}}" *ngFor="let pageSize of paginationPageSizes;">{{pageSize}}</option>
</select>
<span>{{textItemsPerPage}}</span>,
<span class="slick-pagination-count">
<span>{{dataFrom}}-{{dataTo}} {{textOf}} {{totalItems}} {{textItems}}</span>
</span>

<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item"
[ngClass]="(pager?.pageNumber === pager?.pageCount || pager?.totalItems === 0) ? 'disabled' : ''">
<a class="page-link icon-seek-next text-center fa fa-lg fa-angle-right" aria-label="Next"
(click)="changeToNextPage($event)">
</a>
</li>
<li class="page-item"
[ngClass]="(pager?.pageNumber === pager?.pageCount || pager?.totalItems === 0) ? 'disabled' : ''">
<a class="page-link icon-seek-end fa fa-lg fa-angle-double-right" aria-label="Last"
(click)="changeToLastPage($event)">
</a>
</li>
</ul>
</nav>
</div>
<span class="slick-pagination-settings">
<select id="items-per-page-label" [value]="pager?.itemsPerPage" (change)="changeItemPerPage($event)">
<option value="{{pageSize}}" *ngFor="let pageSize of pager?.availablePageSizes;">{{pageSize}}</option>
</select>
<span>{{textItemsPerPage}}</span>,
<span class="slick-pagination-count">
<span>{{pager?.from}}-{{pager?.to}} {{textOf}} {{pager?.totalItems}} {{textItems}}</span>
</span>
</div>
</span>
</div>
Loading

0 comments on commit 4a4a708

Please sign in to comment.