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(module:table): add nzHideOnSinglePage property #1585

Merged
merged 8 commits into from
Jun 2, 2018
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 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