feat(frontend): Add ComplianceStatus and first validation

This commit is contained in:
2025-03-01 08:45:12 +01:00
parent 12ba5da7be
commit c07e03d593
7 changed files with 172 additions and 7 deletions

View File

@@ -1,15 +1,23 @@
<template>
<div v-for="formElement in formElements" :key="formElement.id">
<component :is="getResolvedComponent(formElement)" />
<div v-for="(formElement, index) in props.modelValue" :key="formElement.id">
<component
:is="getResolvedComponent(formElement)"
:form-options="formElement.options"
@update:form-options="updateFormOptions($event)"
/>
</div>
</template>
<script setup lang="ts">
import type { FormElementDto } from '~/.api-client'
import type { FormElementDto, FormOptionDto } from '~/.api-client'
import { resolveComponent } from 'vue'
defineProps<{
formElements: FormElementDto[]
const props = defineProps<{
modelValue: FormElementDto[]
}>()
const emit = defineEmits<{
(e: 'update:modelValue', value: FormElementDto[]): void
}>()
// TODO: Lazy loading?
@@ -19,10 +27,17 @@ function getResolvedComponent(formElement: FormElementDto) {
case 'DROPDOWN':
case 'RADIOBUTTON':
case 'SWITCH':
return resolveComponent('TheSwitch')
case 'TEXTFIELD':
return resolveComponent('TheInput')
default:
return resolveComponent('Unimplemented')
}
}
function updateFormOptions(formOptions: FormOptionDto[]) {
const updatedModelValue = [...props.modelValue]
updatedModelValue[0] = { ...updatedModelValue[0], options: formOptions }
emit('update:modelValue', updatedModelValue)
}
</script>