Skip to content

Commit

Permalink
refactor(tree): support more functions & property
Browse files Browse the repository at this point in the history
refactor(tree): support more functions & property

fix(tree): fix demo

fix dir-tree

fix doc

fix doc

fix(tree): support deprecated property

fix(tree): fix interface

fix(tree): fix param

fix(tree): fix param

fix(tree): fix spec

fix(tree): fix spec

fix(tree): fix origin

fix(tree): support get all nodes

fix(tree): fix demo
  • Loading branch information
simplejason committed Sep 20, 2018
1 parent 21f0703 commit b2482ac
Show file tree
Hide file tree
Showing 42 changed files with 2,132 additions and 2,475 deletions.
4 changes: 2 additions & 2 deletions components/ng-zorro-antd.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { NzCarouselModule } from './carousel/nz-carousel.module';
import { NzCascaderModule } from './cascader/nz-cascader.module';
import { NzCheckboxModule } from './checkbox/nz-checkbox.module';
import { NzCollapseModule } from './collapse/nz-collapse.module';
import { NzWaveModule } from './core/wave/nz-wave.module';
import { NzDatePickerModule } from './date-picker/date-picker.module';
import { NzDividerModule } from './divider/nz-divider.module';
import { NzDrawerModule } from './drawer/nz-drawer.module';
Expand All @@ -30,6 +31,7 @@ import { NzMenuModule } from './menu/nz-menu.module';
import { NzMessageModule } from './message/nz-message.module';
import { NzModalModule } from './modal/nz-modal.module';
import { NzNotificationModule } from './notification/nz-notification.module';
import { NzTreeSelectModule } from './tree-select/nz-tree-select.module';
import { NzPaginationModule } from './pagination/nz-pagination.module';
import { NzPopconfirmModule } from './popconfirm/nz-popconfirm.module';
import { NzPopoverModule } from './popover/nz-popover.module';
Expand All @@ -49,10 +51,8 @@ import { NzTimePickerModule } from './time-picker/nz-time-picker.module';
import { NzTimelineModule } from './timeline/nz-timeline.module';
import { NzToolTipModule } from './tooltip/nz-tooltip.module';
import { NzTransferModule } from './transfer/nz-transfer.module';
import { NzTreeSelectModule } from './tree-select/nz-tree-select.module';
import { NzTreeModule } from './tree/nz-tree.module';
import { NzUploadModule } from './upload/nz-upload.module';
import { NzWaveModule } from './core/wave/nz-wave.module';

export * from './affix';
export * from './alert';
Expand Down
130 changes: 29 additions & 101 deletions components/tree-select/demo/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,39 @@ import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd';
selector: 'nz-demo-tree-select-async',
template: `
<nz-tree-select style="width: 250px"
nzPlaceHolder="Please select"
[nzDefaultExpandedKeys]="expandKeys"
[nzDropdownMatchSelectWidth]="true"
[nzDropdownStyle]="{ 'max-height': '300px' }"
[(ngModel)]="value"
[nzNodes]="nodes"
[nzAsyncData]="true"
(nzExpandChange)="onExpandChange($event)">
nzPlaceHolder="Please select"
[nzDefaultExpandedKeys]="expandKeys"
[nzDropdownMatchSelectWidth]="true"
[nzDropdownStyle]="{ 'max-height': '300px' }"
[(ngModel)]="value"
[nzNodes]="nodes"
[nzAsyncData]="true"
(nzExpandChange)="onExpandChange($event)">
</nz-tree-select>
`
})

export class NzDemoTreeSelectAsyncComponent implements OnInit {
expandKeys = [ '1001', '10001' ];
expandKeys = [ '0-0' ];
value: string;
nodes = [
new NzTreeNode({
title: 'root1',
key: '1001',
children: [
{
title: 'child1',
key: '10001',
children: [
{
title: 'child1.1',
key: '100011',
children: []
},
{
title: 'child1.2',
key: '100012',
children: [
{
title: 'grandchild1.2.1',
key: '1000121',
isLeaf: true,
disabled: true
},
{
title: 'grandchild1.2.2',
key: '1000122',
isLeaf: true
}
]
}
]
}
]
}),
new NzTreeNode({
title: 'root2',
key: '1002',
children: [
{
title: 'child2.1',
key: '10021',
children: [],
disabled: true
},
{
title: 'child2.2',
key: '10022',
children: [
{
title: 'grandchild2.2.1',
key: '100221',
isLeaf: true
}
]
}
]
})
];
nodes = [ {
title : 'Node1',
value : '0-0',
key : '0-0',
children: [ {
title: 'Child Node1',
value: '0-0-1',
key : '0-0-1'
}, {
title: 'Child Node2',
value: '0-0-2',
key : '0-0-2'
} ]
}, {
title: 'Node2',
value: '0-1',
key : '0-1'
} ];

onExpandChange(e: NzFormatEmitEvent): void {
if (e.node.getChildren().length === 0 && e.node.isExpanded) {
Expand All @@ -91,39 +50,8 @@ export class NzDemoTreeSelectAsyncComponent implements OnInit {
loadNode(): Promise<any[]> {
return new Promise(resolve => {
setTimeout(() => resolve([
new NzTreeNode({
title: 'root2',
key: '10030-' + (new Date()).getTime(),
children: [
{
title: 'child2.1',
key: '10021',
children: [],
checked: true,
disabled: true
},
{
title: 'child2.2',
key: '10022',
children: [
{
title: 'grandchild2.2.1',
key: '100221',
isLeaf: true
}
]
}
]
}),
{
title: 'childAdd-1',
key: '10031-' + (new Date()).getTime()
},
{
title: 'childAdd-2',
key: '10032-' + (new Date()).getTime(),
isLeaf: true
}]),
{ title: 'Child Node', key: `${(new Date()).getTime()}-0` },
{ title: 'Child Node', key: `${(new Date()).getTime()}-1` } ]),
1000);
});
}
Expand Down
75 changes: 17 additions & 58 deletions components/tree-select/demo/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,76 +16,35 @@ import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd';
})

export class NzDemoTreeSelectBasicComponent implements OnInit {
expandKeys = [ '1001', '10001' ];
expandKeys = [ '100', '1001' ];
value: string;
nodes = [
new NzTreeNode({
title: 'root1',
key: '1001',
nodes = [ {
title : 'parent 1',
key : '100',
children: [ {
title : 'parent 1-0',
key : '1001',
children: [
{
title: 'child1',
key: '10001',
children: [
{
title: 'child1.1',
key: '100011',
children: []
},
{
title: 'child1.2',
key: '100012',
children: [
{
title: 'grandchild1.2.1',
key: '1000121',
isLeaf: true,
disabled: true
},
{
title: 'grandchild1.2.2',
key: '1000122',
isLeaf: true
}
]
}
]
}
{ title: 'leaf 1-0-0', key: '10010', isLeaf: true },
{ title: 'leaf 1-0-1', key: '10011', isLeaf: true }
]
}),
new NzTreeNode({
title: 'root2',
key: '1002',
}, {
title : 'parent 1-1',
key : '1002',
children: [
{
title: 'child2.1',
key: '10021',
children: [],
disableCheckbox: true
},
{
title: 'child2.2',
key: '10022',
children: [
{
title: 'grandchild2.2.1',
key: '100221',
isLeaf: true
}
]
}
{ title: 'leaf 1-1-0', key: '10020', isLeaf: true }
]
})
];
} ]
} ];

onChange($event: NzTreeNode): void {
onChange($event: string): void {
console.log($event);
}

ngOnInit(): void {
// mock async
setTimeout(() => {
this.value = '10001';
this.value = '1001';
}, 1000);
}
}
94 changes: 33 additions & 61 deletions components/tree-select/demo/checkable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,68 +17,40 @@ import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd';

export class NzDemoTreeSelectCheckableComponent implements OnInit {

value: string[] = [ '10001', '10022' ];
nodes = [
new NzTreeNode({
title : 'root1',
key : '1001',
children: [
{
title : 'child1',
key : '10001',
children: [
{
title : 'child1.1',
key : '100011',
children: []
},
{
title : 'child1.2',
key : '100012',
children: [
{
title : 'grandchild1.2.1',
key : '1000121',
isLeaf : true,
disabled: true
},
{
title : 'grandchild1.2.2',
key : '1000122',
isLeaf: true
}
]
}
]
}
]
}),
new NzTreeNode({
title : 'root2',
key : '1002',
children: [
{
title : 'child2.1',
key : '10021',
children : [],
disableCheckbox: true
},
{
title : 'child2.2',
key : '10022',
children: [
{
title : 'grandchild2.2.1',
key : '100221',
isLeaf: true
}
]
}
]
})
];
value: string[] = [ '0-0-0' ];
nodes = [ {
title : 'Node1',
value : '0-0',
key : '0-0',
children: [ {
title : 'Child Node1',
value : '0-0-0',
key : '0-0-0',
isLeaf: true
} ]
}, {
title : 'Node2',
value : '0-1',
key : '0-1',
children: [ {
title : 'Child Node3',
value : '0-1-0',
key : '0-1-0',
isLeaf: true
}, {
title : 'Child Node4',
value : '0-1-1',
key : '0-1-1',
isLeaf: true
}, {
title : 'Child Node5',
value : '0-1-2',
key : '0-1-2',
isLeaf: true
} ]
} ];

onChange($event: NzTreeNode): void {
onChange($event: string[]): void {
console.log($event);
}

Expand Down
Loading

0 comments on commit b2482ac

Please sign in to comment.