Skip to content

Commit a7c549f

Browse files
authored
feat(autoHide): whether to auto hide the pagination component (#105)
* feat(autoHide): whether to auto hide the pagination component autoHide is true and pageSizeOptions [0]> total does not display pagination update the doc and demo * feat(autoHide): whether to auto hide the pagination component 判断pageSizeOptions最小值
1 parent 4867ebf commit a7c549f

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

devui/pagination/demo/widgets/widgets.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
[canChangePageSize]="true"
3636
[canJumpPage]="true"
3737
[autoFixPageIndex]="false"
38+
[autoHide]="false"
3839
(pageIndexChange)="pageIndexChangeWithoutFix($event)"
3940
(pageSizeChange)="pageSizeChangeWithoutFix($event)"
4041
[pageSizeOptions]="pager.pageSizeOptions"

devui/pagination/doc/api-cn.md

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { PaginationModule } from 'ng-devui/pagination';
3737
| showPageSelector | `boolean` | true | 可选,`极简模式`下是否显示页码下拉 | [极简模式](demo#minimalist-model) |
3838
| haveConfigMenu | `boolean` | false | 可选,`极简模式`下是否显示配置 | [极简模式](demo#minimalist-model) |
3939
| autoFixPageIndex | `boolean` | true | 可选,改变 pageSize 时是否自动修正页码,若`pageSizeChange`事件中会对`pageIndex`做处理,建议设置为`false` | [极简模式](demo#minimalist-model) |
40+
| autoHide | `boolean` | false | 可选,是否自动隐藏, autoHide为 true 并且 pageSizeOptions最小值 > total 不展示分页 | [极简模式](demo#minimalist-model) |
4041

4142
## d-pagination 事件
4243

devui/pagination/doc/api-en.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ In the page:
3737
| lite | `boolean` | false | Optional. Specifies Whether to switch to the simplified mode. | [Simplified mode](demo#minimalist-model) |
3838
| showPageSelector | `boolean` | true | Optional. Whether to display the page number drop-down list in simplified mode. | [Simplified mode](demo#minimalist-model) |
3939
| haveConfigMenu | `boolean` | false | Optional. Whether to display the configuration in simplified mode | [Simplified mode](demo#minimalist-model) |
40-
| 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) |.
40+
| 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) |
41+
| 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) |.
4142

4243
## d-pagination event
4344

devui/pagination/pagination.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="devui-pagination">
1+
<div class="devui-pagination" [hidden]="autoHide && total < minPageSizeOptions">
22
<div *ngIf="canChangePageSize && !lite" class="devui-page-size {{ size ? 'devui-page-size-' + size : '' }}">
33
<d-select
44
[scrollHight]="'200px'"

devui/pagination/pagination.component.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { fromEvent, Subscription } from 'rxjs';
2626
preserveWhitespaces: false,
2727
})
2828
export class PaginationComponent implements OnChanges, AfterViewInit, OnDestroy, OnInit {
29-
static EFFECT_PAGE_RANGE_KEYS = ['total', 'pageSize', 'pageIndex', 'maxItems'];
29+
static EFFECT_PAGE_RANGE_KEYS = ['total', 'pageSize', 'pageIndex', 'maxItems', 'pageSizeOptions'];
3030

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

0 commit comments

Comments
 (0)