From a16cbae5e64218840b17045d0a96ca5c5a3c92a1 Mon Sep 17 00:00:00 2001 From: Denis Lugowski Date: Sun, 9 Nov 2025 08:32:33 +0100 Subject: [PATCH] feat: Refactor form in sectionIndex and create --- .../components/FormStepperWithNavigation.vue | 106 ++++++++++++++++++ .../components/FormValidationIndicator.vue | 27 +++++ legalconsenthub/app/components/TheForm.vue | 103 ----------------- .../application-forms/[id]/[sectionIndex].vue | 75 ++++++++++++- legalconsenthub/app/pages/create.vue | 90 +++------------ 5 files changed, 224 insertions(+), 177 deletions(-) create mode 100644 legalconsenthub/app/components/FormStepperWithNavigation.vue create mode 100644 legalconsenthub/app/components/FormValidationIndicator.vue delete mode 100644 legalconsenthub/app/components/TheForm.vue diff --git a/legalconsenthub/app/components/FormStepperWithNavigation.vue b/legalconsenthub/app/components/FormStepperWithNavigation.vue new file mode 100644 index 0000000..3a022eb --- /dev/null +++ b/legalconsenthub/app/components/FormStepperWithNavigation.vue @@ -0,0 +1,106 @@ + + + + diff --git a/legalconsenthub/app/components/FormValidationIndicator.vue b/legalconsenthub/app/components/FormValidationIndicator.vue new file mode 100644 index 0000000..1db62da --- /dev/null +++ b/legalconsenthub/app/components/FormValidationIndicator.vue @@ -0,0 +1,27 @@ + + + + diff --git a/legalconsenthub/app/components/TheForm.vue b/legalconsenthub/app/components/TheForm.vue deleted file mode 100644 index bdc18ab..0000000 --- a/legalconsenthub/app/components/TheForm.vue +++ /dev/null @@ -1,103 +0,0 @@ - - - diff --git a/legalconsenthub/app/pages/application-forms/[id]/[sectionIndex].vue b/legalconsenthub/app/pages/application-forms/[id]/[sectionIndex].vue index 1b20bee..ce88ab2 100644 --- a/legalconsenthub/app/pages/application-forms/[id]/[sectionIndex].vue +++ b/legalconsenthub/app/pages/application-forms/[id]/[sectionIndex].vue @@ -19,13 +19,31 @@ diff --git a/legalconsenthub/app/pages/create.vue b/legalconsenthub/app/pages/create.vue index b79c8cc..949a5df 100644 --- a/legalconsenthub/app/pages/create.vue +++ b/legalconsenthub/app/pages/create.vue @@ -22,49 +22,17 @@

Sie haben keine Berechtigung zum Erstellen von Anträgen.

Zurück zur Übersicht -
- - {{ trafficLightStatusEmoji }} - - - - - - - - -

- {{ currentFormElementSection.title }} -

- -
- - Prev - - - - Next - -
- Save - Submit -
-
-
-
+
+ + + + + +
@@ -102,46 +70,22 @@ const applicationFormTemplate = computed( () => data?.value?.content[0] ?? undefined ) -const { stepper, activeStepperItemIndex, stepperItems, currentFormElementSection, navigateStepper } = useFormStepper( - computed(() => applicationFormTemplate.value?.formElementSections) -) - -const { addInputFormToApplicationForm } = useFormElementManagement(currentFormElementSection) - -const formElements = computed({ - get: () => currentFormElementSection?.value?.formElements ?? [], - set: (val) => { - if (val && applicationFormTemplate.value) { - if (!currentFormElementSection.value) return - currentFormElementSection.value.formElements = val - } - } -}) const validationMap = ref | undefined>() const validationStatus = ref(ComplianceStatus.NonCritical) +const allFormElements = computed(() => { + return applicationFormTemplate.value?.formElementSections?.flatMap((section) => section.formElements) ?? [] +}) + watch( - () => formElements, + () => allFormElements.value, (updatedFormElements) => { - validationMap.value = validateFormElements(updatedFormElements.value) + validationMap.value = validateFormElements(updatedFormElements) validationStatus.value = getHighestComplianceStatus() }, { deep: true } ) -const trafficLightStatusEmoji = computed(() => { - switch (validationStatus.value) { - case ComplianceStatus.Critical: - return '🔴' - case ComplianceStatus.Warning: - return '🟡' - case ComplianceStatus.NonCritical: - return '🟢' - default: - return '🟢' - } -}) - async function onSave() { const applicationForm = await prepareAndCreateApplicationForm() if (applicationForm) {