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: tree): add origin param to NzTreeNode #1221

Merged
merged 1 commit into from
Apr 4, 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
2 changes: 1 addition & 1 deletion components/tree/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Almost anything can be represented in a tree structure. Examples include directo
| selectable | Set whether the treeNode can be selected | boolean | true |
| disabled | Disables the treeNode | boolean | false |
| disableCheckbox | Disables the checkbox of the treeNode | boolean | false |

| origin | treeNode's raw data(user provided) | - | - |

### NzFormatEmitEvent props

Expand Down
1 change: 1 addition & 0 deletions components/tree/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ subtitle: 树形控件
| selectable | 设置节点是否可被选中 | boolean | true |
| disabled | 设置是否禁用节点(不可进行任何操作) | boolean | false |
| disableCheckbox | 设置节点禁用 Checkbox | boolean | false |
| origin | 原始数据(用户提供) | - | - |

### NzFormatEmitEvent props

Expand Down
3 changes: 3 additions & 0 deletions components/tree/nz-tree-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export class NzTreeNode {
level: number = 0;
children: NzTreeNode[];
isLeaf: boolean;
// tslint:disable-next-line:no-any
origin: any;
// Parent Node
parentNode: NzTreeNode;
isChecked: boolean;
Expand All @@ -23,6 +25,7 @@ export class NzTreeNode {
this.title = option.title || '---';
this.key = option.key || null;
this.isLeaf = option.isLeaf || false;
this.origin = option;

this.children = [];
this.parentNode = parent;
Expand Down
2 changes: 1 addition & 1 deletion components/tree/nz-tree.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export class NzTreeService {
}

getOffset(ele: Element): NzFormatPosition {
if (!ele || !ele.getClientRects().length) {
if (!ele.getClientRects().length) {
return { top: 0, left: 0 };
}
const rect = ele.getBoundingClientRect();
Expand Down
4 changes: 4 additions & 0 deletions components/tree/nz-tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ describe('tree component test', () => {

it('test service - initNodeActive', () => {
const selectedNode = treeService.rootNodes[ 0 ];
selectedNode.isDisabled = true;
treeService.initNodeActive(selectedNode, false);
expect(treeService.getSelectedNodeList().length).toEqual(0);
selectedNode.isDisabled = false;
treeService.initNodeActive(selectedNode, false);
expect(treeService.getSelectedNodeList().length).toEqual(1);
expect(treeService.getSelectedNodeList()[ 0 ].title).toEqual('root1');
Expand Down