Skip to content

Commit

Permalink
convert setDrag to ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Feb 22, 2024
1 parent 2792a6a commit 8da9be6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion client/src/components/History/Content/ContentItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ import { updateContentFields } from "components/History/model/queries";
import StatelessTags from "components/TagsMultiselect/StatelessTags";
import { useEntryPointStore } from "stores/entryPointStore";
import { clearDrag } from "@/utils/setDrag.js";
import { clearDrag } from "@/utils/setDrag.ts";
import CollectionDescription from "./Collection/CollectionDescription";
import { JobStateSummary } from "./Collection/JobStateSummary";
Expand Down
1 change: 0 additions & 1 deletion client/src/stores/eventStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const useEventStore = defineStore("eventStore", () => {

return {
multipleDragData,
dragData,
clearDragData,
getDragData,
setDragData,
Expand Down
23 changes: 0 additions & 23 deletions client/src/utils/setDrag.js

This file was deleted.

27 changes: 27 additions & 0 deletions client/src/utils/setDrag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Helper to configure datatransfer for drag & drop operations
*/
import { useEventStore } from "@/stores/eventStore";

export function setDrag(evt: DragEvent, data = null, multiple = false) {
const eventStore = useEventStore();
if (data) {
evt.dataTransfer?.setData("text", JSON.stringify([data]));
// data submitted through datatransfer is only available upon drop,
// in order to access the drop data immediately this event store is used.
eventStore.setDragData(data, multiple);
}
if (evt.dataTransfer) {
evt.dataTransfer.dropEffect = "move";
evt.dataTransfer.effectAllowed = "move";
const elem = document.getElementById("drag-ghost");
if (elem) {
evt.dataTransfer.setDragImage(elem, 0, 0);
}
}
}

export function clearDrag() {
const eventStore = useEventStore();
eventStore.clearDragData();
}

0 comments on commit 8da9be6

Please sign in to comment.