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): support nzSimple option #1699

Merged
merged 1 commit into from
Jun 22, 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
26 changes: 18 additions & 8 deletions components/table/demo/dynamic-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,30 @@ import { Component, OnInit } from '@angular/core';
</nz-form-item>
<nz-form-item>
<nz-form-label>
<label>Size</label>
<label>No Result</label>
</nz-form-label>
<nz-form-control>
<nz-radio-group [(ngModel)]="size" name="size">
<label nz-radio-button nzValue="default">Default</label>
<label nz-radio-button nzValue="middle">Middle</label>
<label nz-radio-button nzValue="small">Small</label>
</nz-radio-group>
<nz-switch [(ngModel)]="noResult" (ngModelChange)="noResultChange($event)" name="noResult"></nz-switch>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label>
<label>No Result</label>
<label>Simple Pagination</label>
</nz-form-label>
<nz-form-control>
<nz-switch [(ngModel)]="noResult" (ngModelChange)="noResultChange($event)" name="noResult"></nz-switch>
<nz-switch [(ngModel)]="simple" name="simple"></nz-switch>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label>
<label>Size</label>
</nz-form-label>
<nz-form-control>
<nz-radio-group [(ngModel)]="size" name="size">
<label nz-radio-button nzValue="default">Default</label>
<label nz-radio-button nzValue="middle">Middle</label>
<label nz-radio-button nzValue="small">Small</label>
</nz-radio-group>
</nz-form-control>
</nz-form-item>
</form>
Expand All @@ -105,6 +113,7 @@ import { Component, OnInit } from '@angular/core';
[nzScroll]="fixHeader?{ y: '240px' }:null"
[nzData]="dataSet"
[nzBordered]="bordered"
[nzSimple]="simple"
[nzLoading]="loading"
[nzFrontPagination]="pagination"
[nzShowPagination]="pagination"
Expand Down Expand Up @@ -170,6 +179,7 @@ export class NzDemoTableDynamicSettingsComponent implements OnInit {
allChecked = false;
indeterminate = false;
displayData = [];
simple = false;
noResult = false;

currentPageDataChange($event: Array<{ name: string; age: number; address: string; checked: boolean; expand: boolean; description: string; }>): void {
Expand Down
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 @@ -79,6 +79,7 @@ The data passed to `[nzData]` will be export with [Template Context](https://ang
| `[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 |
| `[nzSimple]` | whether to use simple mode | boolean | - |
| `(nzPageIndexChange)` | pageIndex change callback | `EventEmitter<number>` | - |
| `(nzPageSizeChange)` | pageSize change callback | `EventEmitter<number>` | - |
| `(nzCurrentPageDataChange)` | current pageData change callback | `EventEmitter<any[]>` | - |
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 @@ -80,6 +80,7 @@ Table 组件同时具备了易用性和高度可定制性
| `[nzShowSizeChanger]` | 是否可以改变 `nzPageSize` | boolean | false |
| `[nzShowTotal]` | 用于显示数据总量和当前数据范围 | `TemplateRef<{ $implicit: number, range: [ number, number ] }>` | - |
| `[nzHideOnSinglePage]` | 只有一页时是否隐藏分页器 | boolean | false |
| `[nzSimple]` | 当添加该属性时,显示为简单分页 | boolean | - |
| `(nzPageIndexChange)` | 当前页码改版时的回调函数 | `EventEmitter<number>` | - |
| `(nzPageSizeChange)` | 页数改变时的回调函数 | `EventEmitter<number>` | - |
| `(nzCurrentPageDataChange)` | 当前页面展示数据改变的回调函数 | `EventEmitter<any[]>` | - |
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 @@ -97,6 +97,7 @@
[nzPageSize]="nzPageSize"
(nzPageSizeChange)="emitPageSize($event)"
[nzTotal]="nzTotal"
[nzSimple]="nzSimple"
[nzPageIndex]="nzPageIndex"
(nzPageIndexChange)="emitPageIndex($event)">
</nz-pagination>
Expand Down
9 changes: 9 additions & 0 deletions components/table/nz-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class NzTableComponent implements OnInit, AfterViewInit, OnDestroy {
private _pageSize = 10;
private _widthConfig: string[] = [];
private _frontPagination = true;
private _simple = false;
/* tslint:disable-next-line:no-any */
locale: any = {};
nzTheadComponent: NzTheadComponent;
Expand Down Expand Up @@ -82,6 +83,14 @@ export class NzTableComponent implements OnInit, AfterViewInit, OnDestroy {
@Input() nzLoadingDelay = 0;
@Input() nzTotal: number;

@Input()
set nzSimple(value: boolean) {
this._simple = toBoolean(value);
}

get nzSimple(): boolean {
return this._simple;
}
@Input()
set nzFrontPagination(value: boolean) {
this._frontPagination = toBoolean(value);
Expand Down
9 changes: 9 additions & 0 deletions components/table/nz-table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ describe('nz-table', () => {
fixture.detectChanges();
expect(console.warn).toHaveBeenCalledTimes(1);
});
it('should pagination simple work', () => {
fixture.detectChanges();
expect(table.nativeElement.querySelector('.ant-pagination-simple')).toBeNull();
testComponent.simple = true;
fixture.detectChanges();
expect(table.nativeElement.querySelector('.ant-pagination-simple')).toBeDefined();
});
it('should pagination work', () => {
fixture.detectChanges();
expect(table.nativeElement.querySelector('.ant-pagination')).toBeDefined();
Expand Down Expand Up @@ -322,6 +329,7 @@ describe('nz-table', () => {
[nzBordered]="bordered"
[nzLoading]="loading"
[nzShowSizeChanger]="showSizeChanger"
[nzSimple]="simple"
[nzShowQuickJumper]="showQuickJumper"
[nzHideOnSinglePage]="hideOnSinglePage"
[nzWidthConfig]="widthConfig"
Expand Down Expand Up @@ -373,6 +381,7 @@ export class NzTestTableBasicComponent implements OnInit {
title = true;
footer = true;
fixHeader = false;
simple = false;
size = 'small';
widthConfig = [];

Expand Down