Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { DragNDropValueObject } from 'common/models/elements/label-interfaces';
import { DropListComponent } from 'common/components/input-elements/drop-list/drop-list.component';
import { DragOperatorService } from 'common/components/input-elements/drop-list/drag-operator.service';
export class DragOperation {
sourceElement: HTMLElement;
draggedItem: DragNDropValueObject;
sourceComponent: DropListComponent;
sourceIndex: number;
targetComponent: DropListComponent | undefined;
dragType: 'mouse' | 'touch';
sortingPlaceholderIndex: number | undefined;
isForeignPlaceholderActive: boolean = false;
placeholderElement: HTMLElement | undefined;
eligibleTargetListsIDs: string[]; // helper list for better performance
constructor(sourceElement: HTMLElement, sourceListComponent: DropListComponent, sourceIndex: number,
item: DragNDropValueObject, dragType: 'mouse' | 'touch',
allDropLists: { [id: string]: DropListComponent }) {
this.sourceElement = sourceElement;
this.draggedItem = item;
this.sourceComponent = sourceListComponent;
this.sourceIndex = sourceIndex;
this.dragType = dragType;
if (this.sourceComponent.elementModel.isSortList) this.sortingPlaceholderIndex = sourceIndex;
this.targetComponent = sourceListComponent;
this.eligibleTargetListsIDs = Object.values(allDropLists)
.filter(dropList => (DragOperatorService.isDropAllowed( // TODO performance!
this.draggedItem,
sourceListComponent,
allDropLists[dropList.elementModel.id],
allDropLists)
))
.map(droplist => droplist.elementModel.id);
}
}