Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(paging): ability to jump to page n with page links (closes #496) #544

Merged
merged 11 commits into from
May 4, 2017

Conversation

jeremysmartt
Copy link
Collaborator

@jeremysmartt jeremysmartt commented May 2, 2017

Description

Data table paging - Capability to jump to page n. A new parameter 'pageLinkCount' on the Paging-Bar Component that is a number and will create the amount of page links that can be clicked on to jump to a certain page.

Also added all the other missing unit tests for all the other paging parameters.

Closes #496

What's included?

  • modified: src/app/components/components/paging/paging.component.html
  • modified: src/app/components/components/paging/paging.component.ts
  • modified: src/platform/core/paging/paging-bar.component.html
  • modified: src/platform/core/paging/paging-bar.component.ts
  • new file: src/platform/core/paging/paging-bar.component.spec.ts

Test Steps

  • Checkout Branch
  • ng serve
  • edit src/app/components/components/paging/paging.component.html
  • In the td-paging-bar example change pageLinkCount="5" to different values
  • See the page link change on the page
  • Click through and see that for example when pageLinkCount="5" clicking 1,2,3 don't shift the links but clicking 4,5 shift the numbers to the left
  • Click all the way to the end
  • See that clicking that last numbers don't cause a shift
  • Scroll down in the page and make sure the documentation makes sense

General Tests for Every PR

  • ng serve --aot still works.
  • npm run lint passes.
  • npm test passes and code coverage is not lower.
  • npm run build still works.
Screenshots or link to CodePen/Plunker/JSfiddle

new covalent paginator

Data table paging - Capability to jump to page n.  A new parameter 'pageLinkCount' on the Paging-Bar Component that is a number and will create the amount of page links that can be clicked on to jump to a certain page.

Closes #496
@jeremysmartt jeremysmartt changed the title feat: Paging: Jump to page n feat: Paging: Jump to Page n May 2, 2017
@@ -12,16 +12,19 @@
<ng-content></ng-content>
</div>
<div class="td-paging-bar-navigation">
<button md-icon-button type="button" *ngIf="firstLast" [disabled]="isMinPage()" (click)="firstPage()">
<button id="firstPageButton" md-icon-button type="button" *ngIf="firstLast" [disabled]="isMinPage()" (click)="firstPage()">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when using id's, it can get tricky since there will be id duplication when using 2 td-paging-bar components on screen, so we have to dynamically create an id (could be a number) and increase it on every constructor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like [id]="'td-paging-bar-' + id + '-first-page'"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code updated

<md-icon>{{ isRTL ? 'skip_next' : 'skip_previous' }}</md-icon>
</button>
<button md-icon-button type="button" [disabled]="isMinPage()" (click)="prevPage()">
<md-icon>{{ isRTL ? 'navigate_next' : 'navigate_before' }}</md-icon>
</button>
<ng-template *ngIf="pageLinkCount > 0" let-link let-index="index" ngFor [ngForOf]="pageLinks">
<button id="{{'pageLinkCount' + index}}" md-icon-button type="button" [color]="page === link ? 'accent' : ''" (click)="navigateToPage(link)">{{link}}</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, and we can probably do [id]="'td-paging-bar-' + id + '-page-link-' + index"

});
});

@Component({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the most part, its good to separate test cases like you did. But we can make the inputs dynamic so we change them in the unit test on the fly and see if what we expected happens.

e.g.

What should happen if i change pageSizeAll to false on the fly and then back

or

What should happen if i change the pageLinks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code checked in for this

* _calculatePageLinks?: function
* Calculates the page links that should be shown to the user based on the current state of the paginator
*/
private _calculatePageLinks(): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fancee 🍷

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎩

@emoralesb05 emoralesb05 changed the title feat: Paging: Jump to Page n feat(paging): ability to jump to page n with page links (closes #496) May 3, 2017
@emoralesb05 emoralesb05 added this to the Beta 4 milestone May 3, 2017
@emoralesb05
Copy link
Contributor

LGTM 💥

@emoralesb05 emoralesb05 merged commit 459dcb3 into develop May 4, 2017
@emoralesb05 emoralesb05 deleted the feature/jump-to-page-n branch May 4, 2017 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants