mirror of https://github.com/Squidex/squidex.git
14 changed files with 107 additions and 3 deletions
@ -0,0 +1,39 @@ |
|||
|
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Sebastian Stehle. All rights reserved |
|||
*/ |
|||
|
|||
import { Directive, EventEmitter, Output } from '@angular/core'; |
|||
|
|||
import { |
|||
SortableComponent, |
|||
SortableContainer, |
|||
DragDropSortableService |
|||
} from 'ng2-dnd'; |
|||
|
|||
@Directive({ |
|||
selector: '[sorted]' |
|||
}) |
|||
export class SortedDirective { |
|||
@Output() |
|||
public sorted = new EventEmitter<Array<any>>(); |
|||
|
|||
constructor( |
|||
sortableComponent: SortableComponent, |
|||
sortableContainer: SortableContainer, |
|||
sortableDragDropService: DragDropSortableService |
|||
) { |
|||
const oldCallback = sortableComponent._onDropCallback.bind(sortableComponent); |
|||
|
|||
sortableComponent._onDropCallback = (event: Event) => { |
|||
oldCallback(event); |
|||
|
|||
if (sortableDragDropService.isDragged) { |
|||
this.sorted.emit(sortableContainer.sortableData); |
|||
} |
|||
}; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue