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

fix(module:list): fix invalid render empty style when unspecified data source #2415

Merged
merged 22 commits into from
Nov 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
16bad67
Merge pull request #1 from NG-ZORRO/master
cipchk Apr 12, 2018
87bfc95
Merge pull request #2 from NG-ZORRO/master
cipchk Apr 21, 2018
477168e
Merge pull request #3 from NG-ZORRO/master
cipchk May 10, 2018
eb538c3
Merge pull request #4 from NG-ZORRO/master
cipchk May 15, 2018
c469a1b
Merge pull request #5 from NG-ZORRO/master
cipchk May 18, 2018
dee2127
Merge pull request #6 from NG-ZORRO/master
cipchk May 28, 2018
13f290d
Merge pull request #7 from NG-ZORRO/master
cipchk Jun 2, 2018
71958d5
Merge pull request #8 from NG-ZORRO/master
cipchk Jun 7, 2018
d9e0160
Merge pull request #9 from NG-ZORRO/master
cipchk Jun 16, 2018
3195ecc
Merge pull request #10 from NG-ZORRO/master
cipchk Jun 28, 2018
a8c0895
Merge pull request #11 from NG-ZORRO/master
cipchk Jul 1, 2018
50d725c
Merge pull request #12 from NG-ZORRO/master
cipchk Jul 20, 2018
5b7d443
Merge pull request #13 from NG-ZORRO/master
cipchk Jul 24, 2018
b447837
Merge pull request #14 from NG-ZORRO/master
cipchk Aug 7, 2018
5d76294
Merge pull request #15 from NG-ZORRO/master
cipchk Aug 29, 2018
1b5705d
Merge pull request #16 from NG-ZORRO/master
cipchk Sep 16, 2018
cc4aafc
Merge pull request #17 from NG-ZORRO/master
cipchk Sep 19, 2018
de43ada
Merge pull request #18 from NG-ZORRO/master
cipchk Sep 27, 2018
0ca2bb0
Merge pull request #19 from NG-ZORRO/master
cipchk Oct 5, 2018
c5dd3f2
Merge pull request #20 from NG-ZORRO/master
cipchk Oct 23, 2018
fe5d460
Merge pull request #21 from NG-ZORRO/master
cipchk Nov 5, 2018
3695ae5
fix(module:list): fix invalid render empty style when unspecified dat…
cipchk Nov 8, 2018
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
75 changes: 44 additions & 31 deletions components/list/demo/vertical.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'nz-demo-list-vertical',
Expand All @@ -7,37 +7,50 @@ import { Component } from '@angular/core';
[nzDataSource]="data"
[nzItemLayout]="'vertical'"
[nzRenderItem]="item"
[nzPagination]="pagination">
<ng-template #item let-item>
<nz-list-item [nzContent]="item.content" [nzActions]="[starAction,likeAction,msgAction]" [nzExtra]="extra">
<ng-template #starAction><i nz-icon type="star-o" style="margin-right: 8px;"></i> 156</ng-template>
<ng-template #likeAction><i nz-icon type="like-o" style="margin-right: 8px;"></i> 156</ng-template>
<ng-template #msgAction><i nz-icon type="message" style="margin-right: 8px;"></i> 2</ng-template>
<nz-list-item-meta
[nzAvatar]="item.avatar"
[nzTitle]="nzTitle"
[nzDescription]="item.description">
<ng-template #nzTitle><a href="{{item.href}}">{{item.title}}</a></ng-template>
</nz-list-item-meta>
<ng-template #extra>
<img width="272" alt="logo" src="https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png">
</ng-template>
</nz-list-item>
</ng-template>
<ng-template #pagination>
<nz-pagination [nzPageIndex]="1" [nzTotal]="50"></nz-pagination>
</ng-template>
[nzPagination]="pagination"
[nzFooter]="footer">
<ng-template #item let-item>
<nz-list-item [nzContent]="item.content" [nzActions]="[starAction,likeAction,msgAction]" [nzExtra]="extra">
<ng-template #starAction><i nz-icon type="star-o" style="margin-right: 8px;"></i> 156</ng-template>
<ng-template #likeAction><i nz-icon type="like-o" style="margin-right: 8px;"></i> 156</ng-template>
<ng-template #msgAction><i nz-icon type="message" style="margin-right: 8px;"></i> 2</ng-template>
<nz-list-item-meta
[nzAvatar]="item.avatar"
[nzTitle]="nzTitle"
[nzDescription]="item.description">
<ng-template #nzTitle><a href="{{item.href}}">{{item.title}}</a></ng-template>
</nz-list-item-meta>
<ng-template #extra>
<img width="272" alt="logo" src="https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png">
</ng-template>
</nz-list-item>
</ng-template>
<ng-template #footer>
<div><b>ant design</b> footer part</div>
</ng-template>
<ng-template #pagination>
<nz-pagination [nzPageIndex]="1" [nzTotal]="50" (nzPageIndexChange)="loadData($event)"></nz-pagination>
</ng-template>
</nz-list>
`
})
export class NzDemoListVerticalComponent {
data = new Array(5).fill({}).map((i, index) => {
return {
href: 'http://ant.design',
title: `ant design part ${index}`,
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
description: 'Ant Design, a design language for background applications, is refined by Ant UED Team.',
content: 'We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.'
};
});
export class NzDemoListVerticalComponent implements OnInit {
// tslint:disable-next-line:no-any
data: any[] = [];

ngOnInit(): void {
this.loadData(1);
}

loadData(pi: number): void {
this.data = new Array(5).fill({}).map((i, index) => {
return {
href: 'http://ant.design',
title: `ant design part ${index} (page: ${pi})`,
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
description: 'Ant Design, a design language for background applications, is refined by Ant UED Team.',
content: 'We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.'
};
});
}
}
6 changes: 6 additions & 0 deletions components/list/list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ describe('list', () => {
fixture.detectChanges();
expect(dl.queryAll(By.css('.ant-list-empty-text')).length).toBe(1);
});

it('should be ingore empty text when unspecified data source', () => {
context.data = undefined;
fixture.detectChanges();
expect(dl.queryAll(By.css('.ant-list-empty-text')).length).toBe(0);
});
});

it('#nzGrid', () => {
Expand Down
32 changes: 17 additions & 15 deletions components/list/nz-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@
<ng-container *ngIf="_header; else _headerTpl">{{ _header }}</ng-container>
</div>
<nz-spin [nzSpinning]="nzLoading">
<div *ngIf="nzLoading && nzDataSource.length === 0" [style.min-height.px]="53"></div>
<div *ngIf="nzGrid; else itemsTpl" nz-row [nzGutter]="nzGrid.gutter">
<div nz-col [nzSpan]="nzGrid.span" [nzXs]="nzGrid.xs" [nzSm]="nzGrid.sm" [nzMd]="nzGrid.md" [nzLg]="nzGrid.lg" [nzXl]="nzGrid.xl" [nzXXl]="nzGrid.xxl"
*ngFor="let item of nzDataSource; let index = index">
<ng-template
[ngTemplateOutlet]="nzRenderItem"
[ngTemplateOutletContext]="{ $implicit: item, index: index }"></ng-template>
<ng-container *ngIf="nzDataSource">
<div *ngIf="nzLoading && nzDataSource.length === 0" [style.min-height.px]="53"></div>
<div *ngIf="nzGrid; else itemsTpl" nz-row [nzGutter]="nzGrid.gutter">
<div nz-col [nzSpan]="nzGrid.span" [nzXs]="nzGrid.xs" [nzSm]="nzGrid.sm" [nzMd]="nzGrid.md" [nzLg]="nzGrid.lg" [nzXl]="nzGrid.xl" [nzXXl]="nzGrid.xxl"
*ngFor="let item of nzDataSource; let index = index">
<ng-template
[ngTemplateOutlet]="nzRenderItem"
[ngTemplateOutletContext]="{ $implicit: item, index: index }"></ng-template>
</div>
</div>
</div>
<div *ngIf="!nzLoading && nzDataSource.length === 0" class="ant-list-empty-text">
{{locale.emptyText}}
</div>
<div *ngIf="!nzLoading && nzDataSource.length === 0" class="ant-list-empty-text">
{{locale.emptyText}}
</div>
</ng-container>
<ng-content></ng-content>
</nz-spin>
<div *ngIf="_isFooter" class="ant-list-footer">
<ng-container *ngIf="_footer; else _footerTpl">{{ _footer }}</ng-container>
</div>
<ng-template [ngTemplateOutlet]="nzLoadMore"></ng-template>
<ng-content></ng-content>
<div *ngIf="nzPagination" class="ant-list-pagination">
<ng-template [ngTemplateOutlet]="nzPagination"></ng-template>
</div>
<div *ngIf="_isFooter" class="ant-list-footer">
<ng-container *ngIf="_footer; else _footerTpl">{{ _footer }}</ng-container>
</div>
2 changes: 1 addition & 1 deletion components/list/nz-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class NzListComponent implements OnInit, OnChanges, OnDestroy {

// #region fields
// tslint:disable-next-line:no-any
@Input() nzDataSource: any[] = [];
@Input() nzDataSource: any[];

@Input() @InputBoolean() nzBordered = false;

Expand Down