diff --git a/client/src/api/index.ts b/client/src/api/index.ts index be992a9a504f..db8f67c3d53d 100644 --- a/client/src/api/index.ts +++ b/client/src/api/index.ts @@ -232,6 +232,10 @@ export function isHistoryItem(item: object): item is HistoryItemSummary { return item && "history_content_type" in item; } +export function isCollectionItem(item: object): item is DCESummary { + return item && "element_type" in item; +} + type QuotaUsageResponse = components["schemas"]["UserQuotaUsage"]; /** Represents a registered user.**/ diff --git a/client/src/utils/setDrag.ts b/client/src/utils/setDrag.ts index 35f10672d857..ef4c4e87df49 100644 --- a/client/src/utils/setDrag.ts +++ b/client/src/utils/setDrag.ts @@ -1,8 +1,11 @@ /** * Helper to configure datatransfer for drag & drop operations */ +import { type DCESummary, isCollectionItem } from "@/api"; import { type EventData, useEventStore } from "@/stores/eventStore"; +type NamedDCESummary = DCESummary & { name: string }; + export function setDrag(evt: DragEvent, data?: EventData, multiple = false) { const eventStore = useEventStore(); if (data) { @@ -36,10 +39,18 @@ export function setItemDragstart( if (selectedItems && itemIsSelected && selectionSize > 1) { const selectedItemsObj: Record = {}; for (const [key, value] of selectedItems) { + setCollectionElementName(value as any); selectedItemsObj[key] = value; } setDrag(event, selectedItemsObj, true); } else { + setCollectionElementName(item as any); setDrag(event, item as any); } } + +function setCollectionElementName(obj: T) { + if (isCollectionItem(obj as object)) { + obj["name"] = obj.element_identifier; + } +}