mirror of https://github.com/abpframework/abp.git
3 changed files with 117 additions and 2 deletions
@ -0,0 +1,27 @@ |
|||
<nz-tree |
|||
[nzCheckable]="checkable" |
|||
[nzMultiple]="checkable" |
|||
[nzCheckedKeys]="checkedKeys" |
|||
[nzData]="nodes" |
|||
[nzTreeTemplate]="treeTemplate" |
|||
[nzExpandedKeys]="expandedKeys" |
|||
(nzExpandChange)="onExpandedKeysChange($event)" |
|||
(nzCheckBoxChange)="onCheckboxChange($event)" |
|||
></nz-tree> |
|||
<ng-template #treeTemplate let-node> |
|||
<div |
|||
class="node-wrapper" |
|||
[class.selected]="isNodeSelected(node)" |
|||
[title]="node.title" |
|||
(click)="onSelectedNodeChange(node)" |
|||
> |
|||
<span>{{ node.title }}</span> |
|||
|
|||
<div *ngIf="menu" class="ellipsis" ngbDropdown placement="bottom" container="body"> |
|||
<i class="fas fa-ellipsis-h" ngbDropdownToggle [class.dropdown-toggle]="false"></i> |
|||
<div ngbDropdownMenu> |
|||
<ng-template *ngTemplateOutlet="menu; context: { $implicit: node }"></ng-template> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</ng-template> |
|||
@ -0,0 +1,50 @@ |
|||
.ant-tree { |
|||
color: inherit; |
|||
|
|||
.ant-tree-node-content-wrapper.ant-tree-node-selected { |
|||
background-color: transparent; |
|||
} |
|||
|
|||
.ant-tree-switcher { |
|||
line-height: 17px; |
|||
} |
|||
|
|||
.ant-tree-node-content-wrapper { |
|||
width: 100%; |
|||
padding: 0; |
|||
} |
|||
|
|||
.node-wrapper { |
|||
width: 100%; |
|||
position: relative; |
|||
display: inline-block; |
|||
margin: 0; |
|||
padding: 0 5px; |
|||
line-height: 24px; |
|||
text-decoration: none; |
|||
vertical-align: top; |
|||
border-radius: 2px; |
|||
cursor: pointer; |
|||
padding-left: 8px; |
|||
border: 1px solid transparent; |
|||
|
|||
&:hover { |
|||
background-color: transparent; |
|||
border: 1px solid var(--primary); |
|||
color: var(--text-color); |
|||
} |
|||
|
|||
&.selected { |
|||
background-color: transparent; |
|||
color: var(--white); |
|||
background-color: var(--primary); |
|||
} |
|||
} |
|||
|
|||
.ellipsis { |
|||
position: absolute; |
|||
right: 8px; |
|||
top: 1px; |
|||
cursor: pointer; |
|||
} |
|||
} |
|||
@ -1,9 +1,47 @@ |
|||
import { Component } from '@angular/core'; |
|||
import { |
|||
Component, |
|||
ContentChild, |
|||
EventEmitter, |
|||
Input, |
|||
Output, |
|||
TemplateRef, |
|||
ViewEncapsulation, |
|||
} from '@angular/core'; |
|||
|
|||
@Component({ |
|||
selector: 'abp-tree', |
|||
templateUrl: 'tree.component.html', |
|||
styleUrls: [ |
|||
'../../../../../../node_modules/ng-zorro-antd/tree/style/index.min.css', |
|||
'tree.component.scss', |
|||
], |
|||
encapsulation: ViewEncapsulation.None, |
|||
}) |
|||
export class TreeComponent { |
|||
constructor() {} |
|||
@ContentChild('menu') menu: TemplateRef<any>; |
|||
@Input() checkable: boolean; |
|||
@Input() checkedKeys = []; |
|||
@Output() checkedKeysChange = new EventEmitter(); |
|||
@Input() nodes = []; |
|||
@Input() expandedKeys: string[] = []; |
|||
@Output() expandedKeysChange = new EventEmitter<string[]>(); |
|||
@Input() isNodeSelected = node => this.selectedNode?.id === node.key; |
|||
@Input() selectedNode: any; |
|||
@Output() selectedNodeChange = new EventEmitter(); |
|||
|
|||
onSelectedNodeChange(node) { |
|||
this.selectedNode = node.origin.entity; |
|||
this.selectedNodeChange.emit(node.origin.entity); |
|||
} |
|||
|
|||
onCheckboxChange(event) { |
|||
console.log(event); |
|||
this.checkedKeys = event.checkedKeys; |
|||
this.checkedKeysChange.emit(event.checkedKeys); |
|||
} |
|||
|
|||
onExpandedKeysChange(event) { |
|||
this.expandedKeys = event.keys; |
|||
this.expandedKeysChange.emit(event.keys); |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue