implement drag&drop for kanban

This commit is contained in:
marlon-erler
2024-07-25 16:20:43 +02:00
parent 0ed71600c6
commit 01ef0ac09c
8 changed files with 228 additions and 143 deletions
+1 -3
View File
@@ -1,7 +1,5 @@
import * as React from "bloatless-react";
export default class CoreViewModel {
draggedFile: React.State<File | undefined> = new React.State<
File | undefined
>(undefined);
draggedObject: React.State<any> = new React.State<any>(undefined);
}
+6
View File
@@ -94,6 +94,12 @@ export default class BoardViewModel {
this.updateIndex();
};
handleDrop = (category?: string, status?: string): void => {
const draggedObject: any = this.coreViewModel.draggedObject.value;
if (draggedObject instanceof TaskViewModel == false) return;
draggedObject.setCategoryAndStatus(category, status);
};
// storage
storeLastUsedView = (): void => {
const path: string[] = this.getLastUsedBoardPath();
+14 -1
View File
@@ -1,6 +1,8 @@
import * as React from "bloatless-react";
import BoardsAndTasksModel, { TaskFileContent } from "../../Model/Files/boardsAndTasksModel";
import BoardsAndTasksModel, {
TaskFileContent,
} from "../../Model/Files/boardsAndTasksModel";
import { localeCompare, padZero } from "../../Model/Utility/utility";
import BoardViewModel from "./boardViewModel";
@@ -53,6 +55,17 @@ export default class TaskViewModel {
selectedVersionId: React.State<string> = new React.State("");
versionIds: React.ListState<string> = new React.ListState();
// methods
dragStart = (): void => {
this.coreViewModel.draggedObject.value = this;
};
setCategoryAndStatus = (category?: string, status?: string) => {
if (category != undefined) this.category.value = category;
if (status != undefined) this.status.value = status;
this.save();
}
// view
open = (): void => {
this.boardViewModel.selectTask(this);