forked from surveyjs/survey-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/3217 abandon sortablejs (surveyjs#3227)
* surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217 * work for the surveyjs#3217
- Loading branch information
1 parent
b1fcc2a
commit 94715da
Showing
13 changed files
with
247 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ItemValue } from "../itemvalue"; | ||
import { DragDropChoices } from "./choices"; | ||
export class DragDropRankingChoices extends DragDropChoices { | ||
protected getShortcutText(draggedElement: ItemValue): string { | ||
const index = this.parentElement.ran; | ||
return draggedElement.text; | ||
} | ||
|
||
protected getDropTargetByDataAttributeValue( | ||
dataAttributeValue: string | ||
): ItemValue { | ||
return this.parentElement.rankingChoices[dataAttributeValue]; | ||
} | ||
|
||
protected isDropTargetValid(dropTarget: ItemValue): boolean { | ||
const choices = this.parentElement.visibleChoices; | ||
|
||
// shouldn't allow to drop on "adorners" (selectall, none, other) | ||
if (choices.indexOf(dropTarget) === -1) return false; | ||
|
||
return true; | ||
} | ||
|
||
protected afterDragOver(): void { | ||
const choices = this.parentElement.choices; | ||
const dropTargetIndex = choices.indexOf(this.dropTarget); | ||
const draggedElementIndex = choices.indexOf(this.draggedElement); | ||
|
||
choices.splice(draggedElementIndex, 1); | ||
choices.splice(dropTargetIndex, 0, this.draggedElement); | ||
this.parentElement.setValue(); | ||
} | ||
|
||
protected ghostPositionChanged(): void { | ||
this.parentElement.currentDragTarget = this.draggedElement; | ||
super.ghostPositionChanged(); | ||
} | ||
|
||
protected doDrop = (): any => { | ||
super.doDrop(); | ||
this.parentElement.setValue(); | ||
return this.parentElement; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.