From a934626721282e5f8547017a18b2151501371d9c Mon Sep 17 00:00:00 2001 From: Arno Kaimbacher Date: Tue, 18 Mar 2025 12:51:19 +0100 Subject: [PATCH] hotfix: ensure selected collection is draggable - Update draggable attribute and class logic so that the selected collection remains draggable - Preserve proper styling while allowing user interaction with the selected collection --- .../js/Pages/Submitter/Dataset/Category.vue | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/resources/js/Pages/Submitter/Dataset/Category.vue b/resources/js/Pages/Submitter/Dataset/Category.vue index 9b3e6b1..ff45dbc 100644 --- a/resources/js/Pages/Submitter/Dataset/Category.vue +++ b/resources/js/Pages/Submitter/Dataset/Category.vue @@ -69,14 +69,21 @@

Selected Collection

-

- {{ `${selectedCollection.name} (${selectedCollection.number})` }} -

+ ]">

--> + + +
-

Narrower Collections

@@ -189,6 +196,16 @@ const broaderCollections = ref([]); // Reactive list that holds collections dropped by the user const selectedCollectionList: Ref = ref([]); + +// Wrap selectedCollection in an array for draggable (always expects an array) +const selectedCollectionArray = computed({ + get: () => (selectedCollection.value ? [selectedCollection.value] : []), + set: (value: Collection[]) => { + selectedCollection.value = value.length ? value[0] : null + } +}) + + const form = useForm({ collections: [] as number[], }); @@ -277,6 +294,12 @@ const fetchCollections = async (collectionId: number) => { const alreadyDropped = selectedCollectionList.value.find(dc => dc.id === collection.id); return alreadyDropped ? { ...collection, inUse: true } : { ...collection, inUse: false }; }); + // Check if selected collection is in the selected list + if (selectedCollection.value && selectedCollectionList.value.find(dc => dc.id === selectedCollection.value.id)) { + selectedCollection.value = { ...selectedCollection.value, inUse: true }; + } else if (selectedCollection.value) { + selectedCollection.value = { ...selectedCollection.value, inUse: false }; + } } catch (error) { console.error('Error in fetchCollections:', error); }