From 1365a1d64dec291075d91b94d9affa1ce1040a0b Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Fri, 16 Aug 2024 11:24:56 -0500 Subject: [PATCH] show name in draggable for `DCE` --- client/src/api/index.ts | 4 ++++ client/src/utils/setDrag.ts | 11 +++++++++++ 2 files changed, 15 insertions(+) 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; + } +}