Skip to content

Commit

Permalink
fix(module: tree): add origin param to NzTreeNode (NG-ZORRO#1221)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason authored and vthinkxie committed Apr 4, 2018
1 parent 6453aa8 commit 223b507
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
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

0 comments on commit 223b507

Please sign in to comment.