Skip to content

Commit

Permalink
feat(components/tree): add an input named beforeDrop
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-erim committed Jul 17, 2020
1 parent 380586a commit e8ec281
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<nz-tree
[nzBeforeDrop]="beforeDrop"
[nzDraggable]="draggable"
[nzCheckStrictly]="checkStrictly"
[nzCheckable]="checkable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ViewEncapsulation,
} from '@angular/core';
import { NzFormatEmitEvent } from 'ng-zorro-antd/tree';
import { of } from 'rxjs';

@Component({
selector: 'abp-tree',
Expand All @@ -23,7 +24,7 @@ export class TreeComponent {
@Output() readonly checkedKeysChange = new EventEmitter();
@Output() readonly expandedKeysChange = new EventEmitter<string[]>();
@Output() readonly selectedNodeChange = new EventEmitter();
@Output() readonly drop = new EventEmitter<NzFormatEmitEvent>();
@Output() readonly dropOver = new EventEmitter<NzFormatEmitEvent>();
@Input() draggable: boolean;
@Input() checkable: boolean;
@Input() checkStrictly: boolean;
Expand All @@ -32,6 +33,7 @@ export class TreeComponent {
@Input() expandedKeys: string[] = [];
@Input() selectedNode: any;
@Input() isNodeSelected = node => this.selectedNode?.id === node.key;
@Input() beforeDrop = () => of(false);

onSelectedNodeChange(node) {
this.selectedNode = node.origin.entity;
Expand All @@ -52,6 +54,6 @@ export class TreeComponent {
event.event.stopPropagation();
event.event.preventDefault();

this.drop.emit(event);
this.dropOver.emit(event);
}
}

0 comments on commit e8ec281

Please sign in to comment.