Skip to content

Commit

Permalink
work for the #5328
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov committed May 26, 2023
1 parent bd0a1d0 commit 2f459cd
Showing 1 changed file with 20 additions and 31 deletions.
51 changes: 20 additions & 31 deletions src/dragdrop/ranking-choose-choices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,46 +57,35 @@ export class DragDropRankingChooseChoices extends DragDropRankingChoices {
return;
}

// if (this.isDraggedElementOrdered) {

// // TODO
// const choices = rankingChoices;
// const dropTargetIndex = choices.indexOf(this.dropTarget);
// const draggedElementIndex = choices.indexOf(this.draggedElement);

// choices.splice(draggedElementIndex, 1);
// choices.splice(dropTargetIndex, 0, this.draggedElement);
// choices.splice(dropTargetIndex + 1, 0, this.dropTarget);
// rankingModel.setPropertyValue("rankingChoices", choices);
// //return;
// super.updateDraggedElementShortcut(dropTargetIndex + 1);

// if (draggedElementIndex !== dropTargetIndex) {
// dropTargetNode.classList.remove("sv-dragdrop-moveup");
// dropTargetNode.classList.remove("sv-dragdrop-movedown");
// rankingModel.dropTargetNodeMove = null;
// }

// if (draggedElementIndex > dropTargetIndex) {
// rankingModel.dropTargetNodeMove = "down";
// }
if (this.isDraggedElementOrdered) {
choices.splice(draggedElementIndex, 1);
}

// if (draggedElementIndex < dropTargetIndex) {
// rankingModel.dropTargetNodeMove = "up";
// }
choices.splice(dropTargetIndex, 0, this.draggedElement);
this.parentElement.setPropertyValue("rankingChoices", choices);
//return;
this.updateDraggedElementShortcut(dropTargetIndex + 1);

// return;
if (draggedElementIndex !== dropTargetIndex) {
dropTargetNode.classList.remove("sv-dragdrop-moveup");
dropTargetNode.classList.remove("sv-dragdrop-movedown");
this.parentElement.dropTargetNodeMove = null;
}

// //EO TODO
if (draggedElementIndex > dropTargetIndex) {
this.parentElement.dropTargetNodeMove = "down";
}

// }
if (draggedElementIndex < dropTargetIndex) {
this.parentElement.dropTargetNodeMove = "up";
}
}

private isDraggedElementOrdered() {
private get isDraggedElementOrdered() {
return this.parentElement.rankingChoices.indexOf(this.draggedElement) !== -1;
}

private isDraggedElementUnordered() {
private get isDraggedElementUnordered() {
return !this.isDraggedElementOrdered;
}

Expand Down

0 comments on commit 2f459cd

Please sign in to comment.