diff --git a/legalconsenthub-backend/src/main/kotlin/com/betriebsratkanzlei/legalconsenthub/application_form/ApplicationFormController.kt b/legalconsenthub-backend/src/main/kotlin/com/betriebsratkanzlei/legalconsenthub/application_form/ApplicationFormController.kt index 2ad8495..ad36bad 100644 --- a/legalconsenthub-backend/src/main/kotlin/com/betriebsratkanzlei/legalconsenthub/application_form/ApplicationFormController.kt +++ b/legalconsenthub-backend/src/main/kotlin/com/betriebsratkanzlei/legalconsenthub/application_form/ApplicationFormController.kt @@ -23,11 +23,6 @@ class ApplicationFormController( ) } - override fun deleteApplicationForm(id: UUID): ResponseEntity { - applicationFormService.deleteApplicationFormByID(id) - return ResponseEntity.noContent().build() - } - override fun getAllApplicationForms(): ResponseEntity { return ResponseEntity.ok( pagedApplicationFormMapper.toPagedApplicationFormDto( @@ -43,4 +38,20 @@ class ApplicationFormController( ) ) } + + override fun updateApplicationForm( + id: UUID, + applicationFormDto: ApplicationFormDto + ): ResponseEntity { + return ResponseEntity.ok( + applicationFormMapper.toApplicationFormDto( + applicationFormService.updateApplicationForm(applicationFormDto) + ) + ) + } + + override fun deleteApplicationForm(id: UUID): ResponseEntity { + applicationFormService.deleteApplicationFormByID(id) + return ResponseEntity.noContent().build() + } } diff --git a/legalconsenthub/components/formelements/FormElementLayer.vue b/legalconsenthub/components/formelements/FormElementLayer.vue new file mode 100644 index 0000000..00056a6 --- /dev/null +++ b/legalconsenthub/components/formelements/FormElementLayer.vue @@ -0,0 +1,52 @@ + + + diff --git a/legalconsenthub/components/formelements/TheSwitch.vue b/legalconsenthub/components/formelements/TheSwitch.vue index 256fe56..19f3bee 100644 --- a/legalconsenthub/components/formelements/TheSwitch.vue +++ b/legalconsenthub/components/formelements/TheSwitch.vue @@ -6,7 +6,6 @@ import type { FormOptionDto } from '~/.api-client' const props = defineProps<{ - label?: string formOptions: FormOptionDto[] }>() @@ -24,4 +23,6 @@ const modelValue = computed({ } } }) + +const label = computed(() => props.formOptions?.[0].label ?? '') diff --git a/legalconsenthub/composables/useApplicationForm.ts b/legalconsenthub/composables/useApplicationForm.ts index 4426bc3..dc615a9 100644 --- a/legalconsenthub/composables/useApplicationForm.ts +++ b/legalconsenthub/composables/useApplicationForm.ts @@ -53,9 +53,13 @@ export function useApplicationForm() { } async function updateApplicationForm( - id: string, - applicationFormDto: ApplicationFormDto + id?: string, + applicationFormDto?: ApplicationFormDto ): Promise { + if (!id || !applicationFormDto) { + return Promise.reject(new Error('ID or application form DTO missing')) + } + try { currentApplicationForm.value = await applicationFormApi.updateApplicationForm(id, applicationFormDto) return currentApplicationForm.value diff --git a/legalconsenthub/pages/create.vue b/legalconsenthub/pages/create.vue index a81159d..22a8feb 100644 --- a/legalconsenthub/pages/create.vue +++ b/legalconsenthub/pages/create.vue @@ -37,7 +37,7 @@ import { ComplianceStatus, type PagedApplicationFormDto } from '~/.api-client' import { useApplicationFormValidator } from '~/composables/useApplicationFormValidator' import type { FormElementId } from '~/types/FormElement' -const { getAllApplicationForms } = useApplicationForm() +const { getAllApplicationForms, updateApplicationForm } = useApplicationForm() const { validateFormElements, getHighestComplianceStatus } = useApplicationFormValidator() const { data } = await useAsyncData(async () => { @@ -64,7 +64,7 @@ watch( { deep: true } ) -function onSubmit() { - console.log('Submitted') +async function onSubmit() { + await updateApplicationForm(data?.value?.content[0].id, data?.value?.content[0]) }