fix drag&drop on iOS

This commit is contained in:
marlon-erler
2024-07-25 18:16:29 +02:00
parent 830aac08f3
commit 1fc3e9062b
4 changed files with 28 additions and 10 deletions
+15 -7
View File
@@ -1514,6 +1514,14 @@
}; };
}; };
// src/View/utility.ts
function allowDrop(event) {
event.preventDefault();
}
function allowDrag(event) {
event.dataTransfer?.setData("text", "");
}
// src/ViewModel/Pages/taskViewModel.ts // src/ViewModel/Pages/taskViewModel.ts
var TaskViewModel = class { var TaskViewModel = class {
// init // init
@@ -1560,7 +1568,8 @@
selectedVersionId = new State(""); selectedVersionId = new State("");
versionIds = new ListState(); versionIds = new ListState();
// methods // methods
dragStart = () => { dragStart = (event) => {
allowDrag(event);
this.coreViewModel.draggedObject.value = this; this.coreViewModel.draggedObject.value = this;
}; };
setCategoryAndStatus = (category, status) => { setCategoryAndStatus = (category, status) => {
@@ -1620,7 +1629,10 @@
this.versionIds.add(...sortedVersionIds); this.versionIds.add(...sortedVersionIds);
}; };
switchVersion = (versionId) => { switchVersion = (versionId) => {
const taskFileContent = this.boardsAndTasksModel.getSpecificTaskFileContent(this.task.fileId, versionId); const taskFileContent = this.boardsAndTasksModel.getSpecificTaskFileContent(
this.task.fileId,
versionId
);
if (taskFileContent == null) return; if (taskFileContent == null) return;
this.task = taskFileContent; this.task = taskFileContent;
this.loadTaskData(); this.loadTaskData();
@@ -2646,6 +2658,7 @@
{ {
draggable: "true", draggable: "true",
class: "tile flex-no", class: "tile flex-no",
style: "user-select: none; -webkit-user-select: none",
"on:click": taskViewModel.open, "on:click": taskViewModel.open,
"on:dragstart": taskViewModel.dragStart "on:dragstart": taskViewModel.dragStart
}, },
@@ -2675,11 +2688,6 @@
return TaskEntry(taskViewModel); return TaskEntry(taskViewModel);
}; };
// src/View/utility.ts
function allowDrop(event) {
event.preventDefault();
}
// src/View/ChatPages/boardKanbanPage.tsx // src/View/ChatPages/boardKanbanPage.tsx
function BoardKanbanPage(boardViewModel) { function BoardKanbanPage(boardViewModel) {
const categoryNameConverter = (categoryName) => { const categoryNameConverter = (categoryName) => {
+1
View File
@@ -16,6 +16,7 @@ export function TaskEntry(taskViewModel: TaskViewModel) {
<button <button
draggable="true" draggable="true"
class="tile flex-no" class="tile flex-no"
style="user-select: none; -webkit-user-select: none"
on:click={taskViewModel.open} on:click={taskViewModel.open}
on:dragstart={taskViewModel.dragStart} on:dragstart={taskViewModel.dragStart}
> >
+4
View File
@@ -1,3 +1,7 @@
export function allowDrop(event: DragEvent) { export function allowDrop(event: DragEvent) {
event.preventDefault(); event.preventDefault();
} }
export function allowDrag(event: DragEvent) {
event.dataTransfer?.setData("text", "")
}
+8 -3
View File
@@ -7,6 +7,7 @@ import { localeCompare, padZero } from "../../Model/Utility/utility";
import BoardViewModel from "./boardViewModel"; import BoardViewModel from "./boardViewModel";
import CoreViewModel from "../Global/coreViewModel"; import CoreViewModel from "../Global/coreViewModel";
import { allowDrag } from "../../View/utility";
export default class TaskViewModel { export default class TaskViewModel {
boardsAndTasksModel: BoardsAndTasksModel; boardsAndTasksModel: BoardsAndTasksModel;
@@ -58,7 +59,8 @@ export default class TaskViewModel {
versionIds: React.ListState<string> = new React.ListState(); versionIds: React.ListState<string> = new React.ListState();
// methods // methods
dragStart = (): void => { dragStart = (event: DragEvent): void => {
allowDrag(event);
this.coreViewModel.draggedObject.value = this; this.coreViewModel.draggedObject.value = this;
}; };
@@ -71,7 +73,7 @@ export default class TaskViewModel {
setBoardId = (boardId: string): void => { setBoardId = (boardId: string): void => {
this.boardId.value = boardId; this.boardId.value = boardId;
this.save(); this.save();
} };
// view // view
open = (): void => { open = (): void => {
@@ -132,7 +134,10 @@ export default class TaskViewModel {
switchVersion = (versionId: string): void => { switchVersion = (versionId: string): void => {
const taskFileContent: TaskFileContent | null = const taskFileContent: TaskFileContent | null =
this.boardsAndTasksModel.getSpecificTaskFileContent(this.task.fileId, versionId); this.boardsAndTasksModel.getSpecificTaskFileContent(
this.task.fileId,
versionId
);
if (taskFileContent == null) return; if (taskFileContent == null) return;
this.task = taskFileContent; this.task = taskFileContent;