Skip to content

Commit

Permalink
feat(module:table): add nzHideOnSinglePage property (NG-ZORRO#1585)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored and vthinkxie committed Jun 2, 2018
1 parent 7815815 commit afe3080
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/table/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The data passed to `[nzData]` will be export with [Template Context](https://ang
| nzShowQuickJumper | Determine whether you can jump to pages directly | boolean | false |
| nzShowSizeChanger | Determine whether `nzPageSize` can be changed | boolean | false |
| nzShowTotal | To display the total number and range | `TemplateRef<{ $implicit: number, range: [ number, number ] }>` | - |
| nzHideOnSinglePage | Whether to hide pager on single page | boolean | false |

### th

Expand Down
1 change: 1 addition & 0 deletions components/table/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Table 组件同时具备了易用性和高度可定制性
| nzShowQuickJumper | 是否可以快速跳转至某页 | boolean | false |
| nzShowSizeChanger | 是否可以改变 `nzPageSize` | boolean | false |
| nzShowTotal | 用于显示数据总量和当前数据范围 | `TemplateRef<{ $implicit: number, range: [ number, number ] }>` | - |
| nzHideOnSinglePage | 只有一页时是否隐藏分页器 | boolean | false |

### th

Expand Down
1 change: 1 addition & 0 deletions components/table/nz-table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
[nzShowSizeChanger]="nzShowSizeChanger"
[nzPageSizeOptions]="nzPageSizeOptions"
[nzShowQuickJumper]="nzShowQuickJumper"
[nzHideOnSinglePage]="nzHideOnSinglePage"
[nzShowTotal]="nzShowTotal"
[nzSize]="(nzSize=='middle'||nzSize=='small')?'small':''"
[nzPageSize]="nzPageSize"
Expand Down
10 changes: 10 additions & 0 deletions components/table/nz-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class NzTableComponent implements OnInit, AfterViewInit, OnDestroy {
private _loading = false;
private _showSizeChanger = false;
private _showQuickJumper = false;
private _hideOnSinglePage = false;
private _scroll: { x: string; y: string } = { x: null, y: null };
private _footer: string | TemplateRef<void>;
private _title: string | TemplateRef<void>;
Expand Down Expand Up @@ -163,6 +164,15 @@ export class NzTableComponent implements OnInit, AfterViewInit, OnDestroy {
return this._showSizeChanger;
}

@Input()
set nzHideOnSinglePage(value: boolean) {
this._hideOnSinglePage = toBoolean(value);
}

get nzHideOnSinglePage(): boolean {
return this._hideOnSinglePage;
}

@Input()
set nzShowQuickJumper(value: boolean) {
this._showQuickJumper = toBoolean(value);
Expand Down
10 changes: 10 additions & 0 deletions components/table/nz-table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ describe('nz-table', () => {
expect(table.nativeElement.querySelector('.ant-pagination-options-quick-jumper')).toBeDefined();
expect(table.nativeElement.querySelector('.ant-pagination-options-size-changer')).toBeDefined();
});
it('should hideOnSinglePage work', () => {
fixture.detectChanges();
expect(table.nativeElement.querySelector('.ant-pagination')).not.toBe(null);
testComponent.hideOnSinglePage = true;
testComponent.dataSet = [ {} ];
fixture.detectChanges();
expect(table.nativeElement.querySelector('.ant-pagination')).toBe(null);
});
it('#18n', () => {
testComponent.dataSet = [];
fixture.detectChanges();
Expand Down Expand Up @@ -315,6 +323,7 @@ describe('nz-table', () => {
[nzLoading]="loading"
[nzShowSizeChanger]="showSizeChanger"
[nzShowQuickJumper]="showQuickJumper"
[nzHideOnSinglePage]="hideOnSinglePage"
[nzWidthConfig]="widthConfig"
[nzShowPagination]="pagination"
[nzFrontPagination]="pagination"
Expand Down Expand Up @@ -356,6 +365,7 @@ export class NzTestTableBasicComponent implements OnInit {
noResult = '';
showSizeChanger = false;
showQuickJumper = false;
hideOnSinglePage = false;
bordered = false;
loading = false;
pagination = true;
Expand Down

0 comments on commit afe3080

Please sign in to comment.