Skip to content

Commit ed95e63

Browse files
author
Vitor Durante
committed
Add and use ngx-pagination template that follows AdminBSB's style
1 parent f13ffa0 commit ed95e63

File tree

6 files changed

+85
-7
lines changed

6 files changed

+85
-7
lines changed

angular/src/app/roles/roles.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ <h2>
4545
</table>
4646

4747
<div class="text-align: center;" *ngIf="totalItems > pageSize">
48-
<pagination-controls (pageChange)="getDataPage($event)" id="server"></pagination-controls>
48+
<abp-pagination-controls (pageChange)="getDataPage($event)" id="server"></abp-pagination-controls>
4949
</div>
5050
<button type="button" data-toggle="modal" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right" (click)="createRole()">
5151
<i class="material-icons">add</i>
@@ -56,4 +56,4 @@ <h2>
5656
</div>
5757

5858
<create-role-modal #createRoleModal (modalSave)="refresh()"></create-role-modal>
59-
<edit-role-modal #editRoleModal (modalSave)="refresh()"></edit-role-modal>
59+
<edit-role-modal #editRoleModal (modalSave)="refresh()"></edit-role-modal>

angular/src/app/tenants/tenants.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ <h2>
5252
</table>
5353

5454
<div class="text-align: center;" *ngIf="totalItems > pageSize">
55-
<pagination-controls (pageChange)="getDataPage($event)" id="server"></pagination-controls>
55+
<abp-pagination-controls (pageChange)="getDataPage($event)" id="server"></abp-pagination-controls>
5656
</div>
5757
<button type="button" data-toggle="modal" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right" (click)="createTenant()">
5858
<i class="material-icons">add</i>

angular/src/app/users/users.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ <h2>
5656
<!-- ******************************************************** -->
5757

5858
<div class="text-align: center;" *ngIf="totalItems > pageSize">
59-
<pagination-controls (pageChange)="getDataPage($event)" id="server"></pagination-controls>
59+
<abp-pagination-controls (pageChange)="getDataPage($event)" id="server"></abp-pagination-controls>
6060
</div>
6161
<button type="button" data-toggle="modal" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right" (click)="createUser()">
6262
<i class="material-icons">add</i>
@@ -67,4 +67,4 @@ <h2>
6767
</div>
6868

6969
<create-user-modal #createUserModal (modalSave)="refresh()"></create-user-modal>
70-
<edit-user-modal #editUserModal (modalSave)="refresh()"></edit-user-modal>
70+
<edit-user-modal #editUserModal (modalSave)="refresh()"></edit-user-modal>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<pagination-template #p="paginationApi"
2+
[id]="id"
3+
[maxSize]="maxSize"
4+
(pageChange)="pageChange.emit($event)">
5+
<nav>
6+
<ul class="pagination"
7+
role="navigation"
8+
*ngIf="!(autoHide && p.pages.length <= 1)">
9+
10+
<li [class.disabled]="p.isFirstPage()" *ngIf="directionLinks">
11+
<a *ngIf="!p.isFirstPage()"
12+
(click)="p.previous()">
13+
<i class="material-icons">chevron_left</i>
14+
</a>
15+
<a *ngIf="p.isFirstPage()">
16+
<i class="material-icons">chevron_left</i>
17+
</a>
18+
</li>
19+
20+
<li [class.active]="p.getCurrent() === page.value"
21+
*ngFor="let page of p.pages">
22+
<a (click)="p.setCurrent(page.value)">{{ page.label }}</a>
23+
</li>
24+
25+
<li [class.disabled]="p.isLastPage()"
26+
*ngIf="directionLinks">
27+
<a *ngIf="!p.isLastPage()"
28+
(click)="p.next()">
29+
<i class="material-icons">chevron_right</i>
30+
</a>
31+
<a *ngIf="p.isLastPage()">
32+
<i class="material-icons">chevron_right</i>
33+
</a>
34+
</li>
35+
</ul>
36+
</nav>
37+
38+
</pagination-template>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core'
2+
3+
@Component({
4+
selector: 'abp-pagination-controls',
5+
templateUrl: './abp-pagination-controls.component.html'
6+
})
7+
export class AbpPaginationControlsComponent {
8+
@Input() id: string;
9+
@Input() maxSize = 7;
10+
11+
@Input()
12+
get directionLinks(): boolean {
13+
return this._directionLinks;
14+
}
15+
16+
set directionLinks(value: boolean) {
17+
this._directionLinks = !!value && <any>value !== 'false';
18+
}
19+
20+
@Input()
21+
get autoHide(): boolean {
22+
return this._autoHide;
23+
}
24+
25+
set autoHide(value: boolean) {
26+
this._autoHide = !!value && <any>value !== 'false';
27+
}
28+
@Input() previousLabel = 'Previous';
29+
@Input() nextLabel = 'Next';
30+
@Input() screenReaderPaginationLabel = 'Pagination';
31+
@Input() screenReaderPageLabel = 'page';
32+
@Input() screenReaderCurrentLabel = `You're on page`;
33+
@Output() pageChange: EventEmitter<number> = new EventEmitter<number>();
34+
35+
private _directionLinks = true;
36+
private _autoHide = false;
37+
}

angular/src/shared/shared.module.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { AppUrlService } from './nav/app-url.service';
88
import { AppAuthService } from './auth/app-auth.service';
99
import { AppRouteGuard } from './auth/auth-route-guard';
1010
import { MaterialInput } from 'shared/directives/material-input.directive';
11+
import { AbpPaginationControlsComponent } from './pagination/abp-pagination-controls.component';
1112

1213
@NgModule({
1314
imports: [
@@ -16,10 +17,12 @@ import { MaterialInput } from 'shared/directives/material-input.directive';
1617
RouterModule
1718
],
1819
declarations: [
19-
MaterialInput
20+
MaterialInput,
21+
AbpPaginationControlsComponent
2022
],
2123
exports: [
22-
MaterialInput
24+
MaterialInput,
25+
AbpPaginationControlsComponent
2326
]
2427
})
2528
export class SharedModule {

0 commit comments

Comments
 (0)