import { Defaults } from "../defaults"; import { PipelineDomainAction } from "."; export class DraggableActionList { items: PipelineDomainAction[] = Defaults.Array; constructor(listItems: PipelineDomainAction[]) { this.items = listItems; } public dragItem(oldIndex: number, newIndex: number) : void { const draggedItem = this.items[oldIndex]; this.items.splice(oldIndex, 1); this.items.splice(newIndex, 0, draggedItem); this.updateSequence(); } public updateSequence() : void { this.items.forEach((item, index) => { item.sequenceNumber = index + 1; }) } }