fix(frontend): Wrong index when updating FormElement

This commit is contained in:
2025-03-01 10:30:21 +01:00
parent 9538181865
commit 54bb370bfb

View File

@@ -1,9 +1,9 @@
<template> <template>
<div v-for="formElement in props.modelValue" :key="formElement.id"> <div v-for="(formElement, index) in props.modelValue" :key="formElement.id">
<component <component
:is="getResolvedComponent(formElement)" :is="getResolvedComponent(formElement)"
:form-options="formElement.options" :form-options="formElement.options"
@update:form-options="updateFormOptions($event)" @update:form-options="updateFormOptions($event, index)"
/> />
</div> </div>
</template> </template>
@@ -35,9 +35,9 @@ function getResolvedComponent(formElement: FormElementDto) {
} }
} }
function updateFormOptions(formOptions: FormOptionDto[]) { function updateFormOptions(formOptions: FormOptionDto[], formElementIndex: number) {
const updatedModelValue = [...props.modelValue] const updatedModelValue = [...props.modelValue]
updatedModelValue[0] = { ...updatedModelValue[0], options: formOptions } updatedModelValue[formElementIndex] = { ...updatedModelValue[formElementIndex], options: formOptions }
emit('update:modelValue', updatedModelValue) emit('update:modelValue', updatedModelValue)
} }
</script> </script>