fix(#15): Fix several UI bugs

This commit is contained in:
2025-11-20 17:46:41 +01:00
parent 176c3630b9
commit 1bf34f350c
7 changed files with 70 additions and 58 deletions

View File

@@ -1,7 +1,7 @@
<template>
<template v-for="(formElement, index) in props.modelValue" :key="formElement.id">
<div class="flex py-3 lg:py-4">
<div class="group flex-auto">
<div class="group flex py-3 lg:py-4">
<div class="flex-auto">
<p v-if="formElement.title" class="font-semibold">{{ formElement.title }}</p>
<p v-if="formElement.description" class="text-dimmed pb-3">{{ formElement.description }}</p>
<component
@@ -17,8 +17,17 @@
:comments="comments?.[formElement.id]"
/>
</div>
<div>
<UDropdownMenu :items="getDropdownItems(formElement.id, index)" :content="{ align: 'end' }">
<div
:class="[
'transition-opacity duration-200',
openDropdownId === formElement.id ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'
]"
>
<UDropdownMenu
:items="getDropdownItems(formElement.id, index)"
:content="{ align: 'end' }"
@update:open="(isOpen) => handleDropdownToggle(formElement.id, isOpen)"
>
<UButton icon="i-lucide-ellipsis-vertical" color="neutral" variant="ghost" />
</UDropdownMenu>
</div>
@@ -55,7 +64,13 @@ if (props.applicationFormId) {
await loadComments(props.applicationFormId)
}
const route = useRoute()
const activeFormElement = ref('')
const openDropdownId = ref<string | null>(null)
function handleDropdownToggle(formElementId: string, isOpen: boolean) {
openDropdownId.value = isOpen ? formElementId : null
}
function getResolvedComponent(formElement: FormElementDto) {
switch (formElement.type) {
@@ -77,20 +92,23 @@ function getResolvedComponent(formElement: FormElementDto) {
}
function getDropdownItems(formElementId: string, formElementPosition: number): DropdownMenuItem[] {
return [
[
{
label: 'Comments',
icon: 'i-lucide-message-square-more',
onClick: () => toggleComments(formElementId)
},
{
label: 'Add input field below',
icon: 'i-lucide-list-plus',
onClick: () => emit('add:input-form', formElementPosition)
}
]
]
const items = []
if (route.path !== '/create') {
items.push({
label: 'Comments',
icon: 'i-lucide-message-square-more',
onClick: () => toggleComments(formElementId)
})
}
items.push({
label: 'Add input field below',
icon: 'i-lucide-list-plus',
onClick: () => emit('add:input-form', formElementPosition)
})
return [items]
}
function updateFormOptions(formOptions: FormOptionDto[], formElementIndex: number) {