From ec51e4d315cca8c58d972b885cfafcec7ce6b5d0 Mon Sep 17 00:00:00 2001 From: Denis Lugowski Date: Sat, 21 Feb 2026 18:06:47 +0100 Subject: [PATCH] feat: Add Eingabeseite 10 (Schlussteil), fix section spawning with multiple conditions --- .../src/main/resources/seed/demo/_main.yaml | 1 + .../demo/section_01_angaben_zum_itsystem.yaml | 8 ++++ .../seed/demo/section_12_schlussteil.yaml | 42 +++++++++++++++++++ .../main/resources/seed/template/_main.yaml | 1 + .../section_01_angaben_zum_itsystem.yaml | 8 ++++ .../seed/template/section_17_schlussteil.yaml | 42 +++++++++++++++++++ .../seed/SplitYamlLoaderTest.kt | 2 - .../app/composables/useSectionSpawning.ts | 19 +++++++-- 8 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 legalconsenthub-backend/src/main/resources/seed/demo/section_12_schlussteil.yaml create mode 100644 legalconsenthub-backend/src/main/resources/seed/template/section_17_schlussteil.yaml diff --git a/legalconsenthub-backend/src/main/resources/seed/demo/_main.yaml b/legalconsenthub-backend/src/main/resources/seed/demo/_main.yaml index 9e2c70b..b09c745 100644 --- a/legalconsenthub-backend/src/main/resources/seed/demo/_main.yaml +++ b/legalconsenthub-backend/src/main/resources/seed/demo/_main.yaml @@ -13,3 +13,4 @@ formElementSections: - !include section_09_modul_sap_supply_chain_management_scm.yaml - !include section_10_auswirkungen_auf_arbeitnehmer.yaml - !include section_11_informationen_zur_kuenstlichen_intelligenz.yaml + - !include section_12_schlussteil.yaml diff --git a/legalconsenthub-backend/src/main/resources/seed/demo/section_01_angaben_zum_itsystem.yaml b/legalconsenthub-backend/src/main/resources/seed/demo/section_01_angaben_zum_itsystem.yaml index 5e2368e..638c414 100644 --- a/legalconsenthub-backend/src/main/resources/seed/demo/section_01_angaben_zum_itsystem.yaml +++ b/legalconsenthub-backend/src/main/resources/seed/demo/section_01_angaben_zum_itsystem.yaml @@ -43,6 +43,14 @@ formElementSubSections: sectionSpawnConditionType: SHOW sectionSpawnExpectedValue: Einführung sectionSpawnOperator: EQUALS + - templateReference: schlussteil_template + sectionSpawnConditionType: SHOW + sectionSpawnExpectedValue: Einführung + sectionSpawnOperator: EQUALS + - templateReference: schlussteil_template + sectionSpawnConditionType: SHOW + sectionSpawnExpectedValue: Einführung mit einhergehender Ablösung + sectionSpawnOperator: EQUALS # Allgemeine Informationen (Einführung, Ablösung, Änderung) - title: Allgemeine Informationen diff --git a/legalconsenthub-backend/src/main/resources/seed/demo/section_12_schlussteil.yaml b/legalconsenthub-backend/src/main/resources/seed/demo/section_12_schlussteil.yaml new file mode 100644 index 0000000..a1b6e42 --- /dev/null +++ b/legalconsenthub-backend/src/main/resources/seed/demo/section_12_schlussteil.yaml @@ -0,0 +1,42 @@ +title: Schlussteil +shortTitle: Schlussteil +description: Geplantes Einführungsdatum, Wiedervorlage und Anlagen zur Betriebsvereinbarung +templateReference: schlussteil_template +titleTemplate: Schlussteil +spawnedFromElementReference: art_der_massnahme +formElementSubSections: +- title: Einführungsdatum und Wiedervorlage + formElements: + - reference: schlussteil_einfuehrungsdatum + title: 1. Geplantes Einführungsdatum + description: '' + options: + - value: '2026-07-01' + label: Einführungsdatum + processingPurpose: BUSINESS_PROCESS + employeeDataCategory: NON_CRITICAL + type: DATE + - reference: schlussteil_wiedervorlage_datum + title: 2. Wiedervorlage für Prüfung + description: '' + options: + - value: '2027-07-01' + label: Datum + processingPurpose: BUSINESS_PROCESS + employeeDataCategory: NON_CRITICAL + type: DATE +- title: Anlagen zur Betriebsvereinbarung + formElements: + - reference: schlussteil_anlage + title: Anlagen zur Betriebsvereinbarung + description: '' + type: FILE_UPLOAD + options: [] +- title: Dokumente zur Information des Betriebsrats + subtitle: Nicht Bestandteil der Betriebsvereinbarung + formElements: + - reference: schlussteil_dokument + title: Dokumente zur Information des Betriebsrats + description: '' + type: FILE_UPLOAD + options: [] diff --git a/legalconsenthub-backend/src/main/resources/seed/template/_main.yaml b/legalconsenthub-backend/src/main/resources/seed/template/_main.yaml index 62a525e..da51dd5 100644 --- a/legalconsenthub-backend/src/main/resources/seed/template/_main.yaml +++ b/legalconsenthub-backend/src/main/resources/seed/template/_main.yaml @@ -17,3 +17,4 @@ formElementSections: - !include section_14_datenschutz.yaml - !include section_15_auswirkungen_auf_arbeitnehmer.yaml - !include section_16_informationen_zur_kuenstlichen_intelligenz.yaml + - !include section_17_schlussteil.yaml diff --git a/legalconsenthub-backend/src/main/resources/seed/template/section_01_angaben_zum_itsystem.yaml b/legalconsenthub-backend/src/main/resources/seed/template/section_01_angaben_zum_itsystem.yaml index c69a53b..5798da4 100644 --- a/legalconsenthub-backend/src/main/resources/seed/template/section_01_angaben_zum_itsystem.yaml +++ b/legalconsenthub-backend/src/main/resources/seed/template/section_01_angaben_zum_itsystem.yaml @@ -41,6 +41,14 @@ formElementSubSections: sectionSpawnConditionType: SHOW sectionSpawnExpectedValue: Einführung sectionSpawnOperator: EQUALS + - templateReference: schlussteil_template + sectionSpawnConditionType: SHOW + sectionSpawnExpectedValue: Einführung + sectionSpawnOperator: EQUALS + - templateReference: schlussteil_template + sectionSpawnConditionType: SHOW + sectionSpawnExpectedValue: Einführung mit einhergehender Ablösung + sectionSpawnOperator: EQUALS - title: Allgemeine Informationen subtitle: Grundlegende Informationen formElements: diff --git a/legalconsenthub-backend/src/main/resources/seed/template/section_17_schlussteil.yaml b/legalconsenthub-backend/src/main/resources/seed/template/section_17_schlussteil.yaml new file mode 100644 index 0000000..5e5568d --- /dev/null +++ b/legalconsenthub-backend/src/main/resources/seed/template/section_17_schlussteil.yaml @@ -0,0 +1,42 @@ +title: Schlussteil +shortTitle: Schlussteil +description: Geplantes Einführungsdatum, Wiedervorlage und Anlagen zur Betriebsvereinbarung +isTemplate: true +templateReference: schlussteil_template +titleTemplate: Schlussteil +formElementSubSections: +- title: Einführungsdatum und Wiedervorlage + formElements: + - reference: schlussteil_einfuehrungsdatum + title: 1. Geplantes Einführungsdatum + description: '' + options: + - value: '' + label: Einführungsdatum + processingPurpose: BUSINESS_PROCESS + employeeDataCategory: NON_CRITICAL + type: DATE + - reference: schlussteil_wiedervorlage_datum + title: 2. Wiedervorlage für Prüfung + description: '' + options: + - value: '' + label: Datum + processingPurpose: BUSINESS_PROCESS + employeeDataCategory: NON_CRITICAL + type: DATE +- title: Anlagen zur Betriebsvereinbarung + formElements: + - reference: schlussteil_anlage + title: Anlagen zur Betriebsvereinbarung + description: '' + type: FILE_UPLOAD + options: [] +- title: Dokumente zur Information des Betriebsrats + subtitle: Nicht Bestandteil der Betriebsvereinbarung + formElements: + - reference: schlussteil_dokument + title: Dokumente zur Information des Betriebsrats + description: '' + type: FILE_UPLOAD + options: [] diff --git a/legalconsenthub-backend/src/test/kotlin/com/betriebsratkanzlei/legalconsenthub/seed/SplitYamlLoaderTest.kt b/legalconsenthub-backend/src/test/kotlin/com/betriebsratkanzlei/legalconsenthub/seed/SplitYamlLoaderTest.kt index 2de9f26..e1e9ae8 100644 --- a/legalconsenthub-backend/src/test/kotlin/com/betriebsratkanzlei/legalconsenthub/seed/SplitYamlLoaderTest.kt +++ b/legalconsenthub-backend/src/test/kotlin/com/betriebsratkanzlei/legalconsenthub/seed/SplitYamlLoaderTest.kt @@ -16,7 +16,6 @@ class SplitYamlLoaderTest { assert(form.isTemplate == true) { "Form should be a template" } assert(form.name == "Name des IT-Systems") { "Form name should match" } assert(form.formElementSections?.isNotEmpty() == true) { "Form should have sections" } - assert(form.formElementSections?.size == 16) { "Form should have 16 sections" } } @Test @@ -31,6 +30,5 @@ class SplitYamlLoaderTest { assert(form.isTemplate == false) { "Form should not be a template" } assert(form.name == "SAP S/4HANA") { "Form name should match" } assert(form.formElementSections?.isNotEmpty() == true) { "Form should have sections" } - assert(form.formElementSections?.size == 11) { "Form should have 11 sections" } } } diff --git a/legalconsenthub/app/composables/useSectionSpawning.ts b/legalconsenthub/app/composables/useSectionSpawning.ts index 83ca672..7f8af11 100644 --- a/legalconsenthub/app/composables/useSectionSpawning.ts +++ b/legalconsenthub/app/composables/useSectionSpawning.ts @@ -18,7 +18,7 @@ export function useSectionSpawning() { // Process each trigger independently for (const trigger of triggers) { - resultSections = processSingleTrigger(resultSections, formElement, trigger, triggerValue) + resultSections = processSingleTrigger(resultSections, formElement, trigger, triggerValue, triggers) } } @@ -29,7 +29,8 @@ export function useSectionSpawning() { sections: FormElementSectionDto[], formElement: FormElementDto, trigger: SectionSpawnTriggerDto, - triggerValue: string + triggerValue: string, + allTriggersForElement: SectionSpawnTriggerDto[] ): FormElementSectionDto[] { let resultSections = sections const shouldSpawn = shouldSpawnSection(trigger, triggerValue) @@ -45,9 +46,19 @@ export function useSectionSpawning() { if (shouldSpawn && !existingSpawnedSection) { resultSections = spawnNewSection(resultSections, formElement, trigger, triggerValue) } - // 2. Condition no longer met but section exists → remove spawned section + // 2. Condition no longer met but section exists → remove spawned section only if no other + // trigger for the same template reference still satisfies the spawn condition (OR logic) else if (!shouldSpawn && existingSpawnedSection) { - resultSections = removeSpawnedSectionForTrigger(resultSections, formElement.reference!, trigger.templateReference) + const otherTriggerAlsoSpawns = allTriggersForElement.some( + (t) => t !== trigger && t.templateReference === trigger.templateReference && shouldSpawnSection(t, triggerValue) + ) + if (!otherTriggerAlsoSpawns) { + resultSections = removeSpawnedSectionForTrigger( + resultSections, + formElement.reference!, + trigger.templateReference + ) + } } // 3. Condition still met and section exists → update section titles if value changed else if (shouldSpawn && existingSpawnedSection && triggerValue) {