add drag&drop to kanban
This commit is contained in:
@@ -54,8 +54,31 @@ function KanbanBoardView(
|
||||
selectedObject: React.State<MessageObject | undefined>,
|
||||
isShowingObjectModal: React.State<boolean>
|
||||
) {
|
||||
function dragOver(event: DragEvent) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
function drop(event: DragEvent) {
|
||||
event.preventDefault();
|
||||
var id = event.dataTransfer?.getData("text");
|
||||
if (!id) return;
|
||||
|
||||
const messageObject = chat.objects.value.get(id);
|
||||
if (!messageObject) return;
|
||||
|
||||
const latest = chat.getMostRecentContent(messageObject);
|
||||
latest.categoryName = kanbanBoard.title;
|
||||
|
||||
chat.addObjectAndSend(messageObject);
|
||||
}
|
||||
|
||||
return (
|
||||
<div class="flex-column flex-no" style="min-width: 280px">
|
||||
<div
|
||||
class="flex-column flex-no"
|
||||
style="min-width: 280px"
|
||||
on:dragover={dragOver}
|
||||
on:drop={drop}
|
||||
>
|
||||
<b class="flex-row width-100">{kanbanBoard.title}</b>
|
||||
<hr></hr>
|
||||
<div class="flex-column gap padding-bottom">
|
||||
|
||||
@@ -21,6 +21,10 @@ export function ObjectEntryView(
|
||||
isShowingObjectModal.value = true;
|
||||
}
|
||||
|
||||
function dragStart(event: DragEvent) {
|
||||
event.dataTransfer?.setData("text", messageObject.id);
|
||||
}
|
||||
|
||||
const fields = {
|
||||
[icons.noteContent]: "---",
|
||||
[icons.priority]: "---",
|
||||
@@ -49,7 +53,12 @@ export function ObjectEntryView(
|
||||
});
|
||||
|
||||
return (
|
||||
<button class="tile justify-start" on:click={select}>
|
||||
<button
|
||||
class="tile justify-start"
|
||||
on:click={select}
|
||||
draggable="true"
|
||||
on:dragstart={dragStart}
|
||||
>
|
||||
<div>
|
||||
<b>{chat.getObjectTitle(messageObject)}</b>
|
||||
<hr></hr>
|
||||
|
||||
Reference in New Issue
Block a user