|
|
|
@ -5,14 +5,14 @@ |
|
|
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|
|
|
*/ |
|
|
|
|
|
|
|
import { Directive, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges } from '@angular/core'; |
|
|
|
import { Directive, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; |
|
|
|
|
|
|
|
import * as Sortable from 'sortablejs'; |
|
|
|
|
|
|
|
@Directive({ |
|
|
|
selector: '[sqxSortModel]' |
|
|
|
}) |
|
|
|
export class SortedDirective implements OnDestroy, OnInit, OnChanges { |
|
|
|
export class SortedDirective implements OnDestroy, OnInit { |
|
|
|
private sortable: Sortable.Ref; |
|
|
|
|
|
|
|
@Input() |
|
|
|
@ -29,13 +29,6 @@ export class SortedDirective implements OnDestroy, OnInit, OnChanges { |
|
|
|
) { |
|
|
|
} |
|
|
|
|
|
|
|
public ngOnChanges(changes: SimpleChanges) { |
|
|
|
const sortModel = changes['sortModel'].currentValue; |
|
|
|
if (sortModel) { |
|
|
|
console.log(JSON.stringify(sortModel.map((x: any) => x.fileName))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
if (this.sortable) { |
|
|
|
this.sortable.destroy(); |
|
|
|
@ -48,7 +41,6 @@ export class SortedDirective implements OnDestroy, OnInit, OnChanges { |
|
|
|
animation: 150, |
|
|
|
|
|
|
|
onSort: (event: { oldIndex: number, newIndex: number }) => { |
|
|
|
console.log('FOO'); |
|
|
|
if (this.sortModel && event.newIndex !== event.oldIndex) { |
|
|
|
const newModel = [...this.sortModel]; |
|
|
|
|
|
|
|
|