feat: Add Eingabeseite 6 (Datenschutz)

This commit is contained in:
2026-01-22 16:37:39 +01:00
parent 56d8c223d8
commit e549058c85
4 changed files with 1254 additions and 11 deletions

View File

@@ -57,6 +57,13 @@ export function useFormElementVisibility() {
return false
}
// Special handling for CHECKBOX with multiple options
if (sourceElement.type === FormElementType.Checkbox && sourceElement.options.length > 1) {
const operator = condition.formElementOperator || VCOperator.Equals
const conditionMet = evaluateCheckboxCondition(sourceElement, condition.formElementExpectedValue, operator)
return condition.formElementConditionType === VCType.Show ? conditionMet : !conditionMet
}
const sourceValue = getFormElementValue(sourceElement)
const operator = condition.formElementOperator || VCOperator.Equals
const conditionMet = evaluateCondition(sourceValue, condition.formElementExpectedValue, operator)
@@ -75,6 +82,37 @@ export function useFormElementVisibility() {
return selectedOption?.label || ''
}
/**
* Evaluates visibility condition for CHECKBOX with multiple options.
* Checks if ANY of the selected checkboxes matches the expected value.
*/
function evaluateCheckboxCondition(
element: FormElementDto,
expectedValue: string,
operator: VisibilityConditionOperator
): boolean {
const selectedLabels = element.options
.filter((option) => option.value === 'true')
.map((option) => option.label)
switch (operator) {
case VCOperator.Equals:
// Check if any selected checkbox label matches the expected value
return selectedLabels.some((label) => label.toLowerCase() === expectedValue.toLowerCase())
case VCOperator.NotEquals:
// Check if no selected checkbox label matches the expected value
return !selectedLabels.some((label) => label.toLowerCase() === expectedValue.toLowerCase())
case VCOperator.IsEmpty:
// Check if no checkboxes are selected
return selectedLabels.length === 0
case VCOperator.IsNotEmpty:
// Check if at least one checkbox is selected
return selectedLabels.length > 0
default:
return false
}
}
function evaluateCondition(
actualValue: string,
expectedValue: string,