-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): limit pagination count, add filters on add consumer modal
- Loading branch information
Showing
7 changed files
with
96 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { | ||
AfterViewInit, | ||
ChangeDetectionStrategy, | ||
ChangeDetectorRef, | ||
Component, | ||
ElementRef, | ||
EventEmitter, | ||
HostListener, | ||
Input, | ||
OnChanges, | ||
Output, | ||
ViewChild | ||
} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-pagination', | ||
templateUrl: './pagination.html', | ||
styleUrls: ['./pagination.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class PaginationComponent implements OnChanges, AfterViewInit { | ||
@ViewChild('paginationWrapper', { static: false }) paginationWrapper: ElementRef; | ||
@Input() collectionSize: number; | ||
@Input() pageSize: number; | ||
@Input() page: number; | ||
@Output() pageChange = new EventEmitter<number>(); | ||
|
||
maxSize = 10; | ||
|
||
constructor(public _cd: ChangeDetectorRef) { } | ||
|
||
ngAfterViewInit() { | ||
this.resize(); | ||
} | ||
|
||
ngOnChanges() { | ||
this.resize(); | ||
} | ||
|
||
onPageChange(n: number) { | ||
this.pageChange.emit(n); | ||
} | ||
|
||
@HostListener('window:resize', ['$event']) | ||
onResize(event) { | ||
this.resize(); | ||
} | ||
|
||
resize() { | ||
if (this.paginationWrapper) { | ||
let wrapperWidth = this.paginationWrapper.nativeElement.clientWidth; | ||
// 75px is approximately the size of a button, 4 buttons are removed (left, right and ellipsis) | ||
let maxPage = Math.trunc(wrapperWidth / 65) - 4; | ||
this.maxSize = maxPage < 10 ? maxPage : 10; | ||
this.maxSize = this.maxSize < 1 ? 1 : this.maxSize; | ||
this._cd.detectChanges(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div #paginationWrapper> | ||
<sui-pagination class="ui right floated" [collectionSize]="collectionSize" [pageSize]="pageSize" [maxSize]="maxSize" | ||
[hasEllipses]="true" (pageChange)="onPageChange($event)" [page]="page"> | ||
</sui-pagination> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import '../../../common'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters