import { Directive , NgZone , ElementRef , HostBinding , Input , Inject , OnDestroy , Optional } from '@angular/core' ; import { DragRef } from './drag-ref' ; import { DOCUMENT } from '@angular/common' ; import { ThyDragDropService } from './drag-drop.service' ; import { mixinUnsubscribe , MixinBase , Constructor , ThyUnsubscribe } from 'ngx-tethys/core' ; import { THY_DROP_CONTAINER_DIRECTIVE , IThyDropContainerDirective } from './drop-container.class' ; const _MixinBase = mixinUnsubscribe ( MixinBase ) ; @ Directive ( { selector : 'thy-drag,[thyDrag]' } ) export class ThyDragDirective < T = any > extends _MixinBase implements OnDestroy { @ Input ( 'thyDrag' ) set dragData ( data ) { this . data = data ; } @ Input ( 'thyDragData' ) data : T ; @ HostBinding ( 'attr.draggable' ) isDraggable = true ; private _disabled = false ; @ Input ( 'thyDragDisabled' ) set disabled ( isDisabled ) { this . _disabled = isDisabled ; if ( isDisabled ) { this . isDraggable = false ; } } get disabled ( ) { return this . _disabled ; } public dragRef : DragRef < T > ; constructor ( @ Inject ( DOCUMENT ) document , @ Optional ( ) @ Inject ( THY_DROP_CONTAINER_DIRECTIVE ) public container , ngZone , private elementRef , service ) { super ( ) ; this . dragRef = new DragRef < T > ( elementRef , this , container , service , document , ngZone ) ; } ngOnDestroy ( ) { super . ngOnDestroy ( ) ; this . dragRef . dispose ( ) ; } }