Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: (Core) Add missed controls into Pagination component and fix sma…
…ll issue (#4183) * fix pagination issue, update docs, add select default items per page * add text alternative * fix PR note * fix pagination service test * small improvement for shown pages
- Loading branch information
1 parent
b006c66
commit d6864be
Showing
14 changed files
with
478 additions
and
184 deletions.
There are no files selected for viewing
37 changes: 21 additions & 16 deletions
37
apps/docs/src/app/core/component-docs/pagination/examples/pagination-example.component.ts
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
37 changes: 37 additions & 0 deletions
37
...rc/app/core/component-docs/pagination/examples/pagination-per-page-example.component.html
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,37 @@ | ||
<div> | ||
<h5><code>[itemsPerPage]=15</code> Default property for items per page</h5> | ||
<fd-pagination | ||
fd-toolbar-item | ||
[totalItems]="totalItems" | ||
[itemsPerPage]="15" | ||
[currentPage]="currentPage1" | ||
(pageChangeStart)="pageChanged1($event)" | ||
></fd-pagination> | ||
</div> | ||
<div> | ||
<h5><code>[itemsPerPageOptions]="[4,8,16]"</code> - Default select template for items per page options</h5> | ||
<fd-pagination | ||
fd-toolbar-item | ||
[totalItems]="totalItems" | ||
[itemsPerPageOptions]="[4,8,16]" | ||
[currentPage]="currentPage2" | ||
(pageChangeStart)="pageChanged2($event)" | ||
></fd-pagination> | ||
</div> | ||
<div> | ||
<h5>Custom items per page - list of buttons</h5> | ||
<fd-pagination | ||
fd-toolbar-item | ||
[totalItems]="totalItems" | ||
[currentPage]="currentPage3" | ||
[itemsPerPageTemplate]="itemsPerPageCustom" | ||
(pageChangeStart)="pageChanged3($event)" | ||
#pagination | ||
></fd-pagination> | ||
|
||
<ng-template #itemsPerPageCustom let-onSelect="onSelect"> | ||
<fd-segmented-button> | ||
<button fd-button [label]="count" [class.is-selected]="pagination.itemsPerPage === count" *ngFor="let count of [2,5,100]" (click)="onSelect(count)"></button> | ||
</fd-segmented-button> | ||
</ng-template> | ||
</div> |
22 changes: 22 additions & 0 deletions
22
.../src/app/core/component-docs/pagination/examples/pagination-per-page-example.component.ts
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,22 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'fd-pagination-per-page-example', | ||
templateUrl: './pagination-per-page-example.component.html' | ||
}) | ||
export class PaginationPerPageExampleComponent { | ||
totalItems = 50; | ||
currentPage1 = 1; | ||
currentPage2 = 1; | ||
currentPage3 = 1; | ||
|
||
pageChanged1(event: number): void { | ||
this.currentPage1 = event; | ||
} | ||
pageChanged2(event: number): void { | ||
this.currentPage2 = event; | ||
} | ||
pageChanged3(event: number): void { | ||
this.currentPage3 = event; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...s/src/app/core/component-docs/pagination/examples/pagination-showing-example.component.ts
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,26 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'fd-pagination-showing-example', | ||
template: ` | ||
<fd-pagination | ||
[totalItems]="totalItems" | ||
[displayTextTemplate]="customDisplayTextTemplate" | ||
[itemsPerPage]="itemsPerPage" | ||
[currentPage]="currentPage" | ||
(pageChangeStart)="pageChanged($event)" | ||
></fd-pagination> | ||
<ng-template #customDisplayTextTemplate let-showing="showing"> | ||
From {{ showing.from }} to {{ showing.to }}. Total items {{ showing.of }} | ||
</ng-template> | ||
` | ||
}) | ||
export class PaginationShowingExampleComponent { | ||
totalItems = 50; | ||
itemsPerPage = 10; | ||
currentPage = 1; | ||
|
||
pageChanged(event: number): void { | ||
this.currentPage = event; | ||
} | ||
} |
42 changes: 39 additions & 3 deletions
42
apps/docs/src/app/core/component-docs/pagination/pagination-docs.component.html
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 |
---|---|---|
@@ -1,17 +1,53 @@ | ||
<fd-docs-section-title [id]="'def'" [componentName]="'pagination'"> | ||
Pagination | ||
<fd-docs-section-title id="def" componentName="pagination"> | ||
Basic Pagination | ||
</fd-docs-section-title> | ||
<component-example> | ||
<fd-pagination-example></fd-pagination-example> | ||
</component-example> | ||
<code-example [exampleFiles]="paginationBasic"></code-example> | ||
|
||
<separator></separator> | ||
|
||
<fd-docs-section-title id="def" componentName="pagination"> | ||
Pagination showing items | ||
</fd-docs-section-title> | ||
<description> | ||
Pagination with custom showing template | ||
<ul> | ||
<li>Set <code>[displayTextTemplate]</code> property to specify the display template for showing items.</li> | ||
</ul> | ||
</description> | ||
<component-example> | ||
<fd-pagination-showing-example></fd-pagination-showing-example> | ||
</component-example> | ||
<code-example [exampleFiles]="paginationShowing"></code-example> | ||
|
||
<separator></separator> | ||
|
||
<fd-docs-section-title id="def" componentName="pagination"> | ||
Pagination with per page select. | ||
</fd-docs-section-title> | ||
<description> | ||
Pagination with custom showing template | ||
<ul> | ||
<li>Set <code>[itemsPerPage]</code> property to number of items per page. It's equal 10 by default.</li> | ||
<li>Set <code>[itemsPerPageOptions]</code> property to array of numbers for items per page select.</li> | ||
<li>Set <code>[itemsPerPageTemplate]</code> property to custom template. | ||
You will have <code>onSelect</code> property to interact with component. | ||
This property has higher priority than <code>[itemsPerPageOptions]</code>.</li> | ||
</ul> | ||
</description> | ||
<component-example> | ||
<fd-pagination-per-page-example></fd-pagination-per-page-example> | ||
</component-example> | ||
<code-example [exampleFiles]="paginationPerPageSrc"></code-example> | ||
|
||
<separator></separator> | ||
|
||
<playground [schema]="schema" [schemaInitialValues]="data" (onFormChanges)="onSchemaValues($event)"> | ||
<fd-pagination | ||
[totalItems]="data.properties.totalItems" | ||
[itemsPerPage]="data.properties.itemsPerPage" | ||
[currentPage]="data.properties.currentPage" | ||
[displayText]="data.properties.displayText" | ||
></fd-pagination> | ||
</playground> |
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
Oops, something went wrong.