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