Skip to content

feat(autoHide): whether to auto hide the pagination component #105

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

Merged
merged 2 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions devui/pagination/demo/widgets/widgets.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
[canChangePageSize]="true"
[canJumpPage]="true"
[autoFixPageIndex]="false"
[autoHide]="false"
(pageIndexChange)="pageIndexChangeWithoutFix($event)"
(pageSizeChange)="pageSizeChangeWithoutFix($event)"
[pageSizeOptions]="pager.pageSizeOptions"
Expand Down
1 change: 1 addition & 0 deletions devui/pagination/doc/api-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { PaginationModule } from 'ng-devui/pagination';
| showPageSelector | `boolean` | true | 可选,`极简模式`下是否显示页码下拉 | [极简模式](demo#minimalist-model) |
| haveConfigMenu | `boolean` | false | 可选,`极简模式`下是否显示配置 | [极简模式](demo#minimalist-model) |
| autoFixPageIndex | `boolean` | true | 可选,改变 pageSize 时是否自动修正页码,若`pageSizeChange`事件中会对`pageIndex`做处理,建议设置为`false` | [极简模式](demo#minimalist-model) |
| autoHide | `boolean` | false | 可选,是否自动隐藏, autoHide为 true 并且 pageSizeOptions最小值 > total 不展示分页 | [极简模式](demo#minimalist-model) |

## d-pagination 事件

Expand Down
3 changes: 2 additions & 1 deletion devui/pagination/doc/api-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ In the page:
| lite | `boolean` | false | Optional. Specifies Whether to switch to the simplified mode. | [Simplified mode](demo#minimalist-model) |
| showPageSelector | `boolean` | true | Optional. Whether to display the page number drop-down list in simplified mode. | [Simplified mode](demo#minimalist-model) |
| haveConfigMenu | `boolean` | false | Optional. Whether to display the configuration in simplified mode | [Simplified mode](demo#minimalist-model) |
| autoFixPageIndex | `boolean` | true | Optional. Indicates whether to automatically correct the page number when the page size is changed. If the pageIndex is processed in the `pageSizeChange` event, you are advised to set the value to `false` | [Simplified Mode](demo#minimalist-model) |.
| autoFixPageIndex | `boolean` | true | Optional. Indicates whether to automatically correct the page number when the page size is changed. If the pageIndex is processed in the `pageSizeChange` event, you are advised to set the value to `false` | [Simplified Mode](demo#minimalist-model) |
| autoHide | `boolean` | false | Optional, whether to hide automatically, autoHide is true minimum value of pageSizeOptions > total do not show pagination | [Simplified Mode](demo#minimalist-model) |.

## d-pagination event

Expand Down
2 changes: 1 addition & 1 deletion devui/pagination/pagination.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="devui-pagination">
<div class="devui-pagination" [hidden]="autoHide && total < minPageSizeOptions">
<div *ngIf="canChangePageSize && !lite" class="devui-page-size {{ size ? 'devui-page-size-' + size : '' }}">
<d-select
[scrollHight]="'200px'"
Expand Down
8 changes: 7 additions & 1 deletion devui/pagination/pagination.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { fromEvent, Subscription } from 'rxjs';
preserveWhitespaces: false,
})
export class PaginationComponent implements OnChanges, AfterViewInit, OnDestroy, OnInit {
static EFFECT_PAGE_RANGE_KEYS = ['total', 'pageSize', 'pageIndex', 'maxItems'];
static EFFECT_PAGE_RANGE_KEYS = ['total', 'pageSize', 'pageIndex', 'maxItems', 'pageSizeOptions'];

/**
* 【可选】每页显示最大条目数量,默认10条
Expand Down Expand Up @@ -103,6 +103,11 @@ export class PaginationComponent implements OnChanges, AfterViewInit, OnDestroy,
@Input() showPageSelector = true;
@Input() haveConfigMenu = false;
@Input() autoFixPageIndex = true;
/**
* 是否自动隐藏
*/
@Input() autoHide = false;
minPageSizeOptions: number;
litePaginatorIndex: { value: number, label: string } | null;
litePaginatorOptions: any[] = [];
private litePaginatorOptionsLengthCache = 0;
Expand Down Expand Up @@ -235,6 +240,7 @@ export class PaginationComponent implements OnChanges, AfterViewInit, OnDestroy,
ngOnChanges(changes: SimpleChanges): void {
const shouldUpdateRanges = PaginationComponent.EFFECT_PAGE_RANGE_KEYS.some(key => !!changes[key]);
if (shouldUpdateRanges) {
this.minPageSizeOptions = Math.min(...this.pageSizeOptions);
this.totalPage = this.getTotalPage();
if (!this.showTruePageIndex) {
this.pageIndex = Math.max(Math.min(this.pageIndex, this.totalPage), 1);
Expand Down