feat: Add visibilityConditions for checkboxes and radio gorups, update seeds
This commit is contained in:
@@ -753,6 +753,14 @@ formElementSubSections:
|
|||||||
label: Ja (Nutzer-/Aktivitätsbezug)
|
label: Ja (Nutzer-/Aktivitätsbezug)
|
||||||
processingPurpose: DATA_ANALYSIS
|
processingPurpose: DATA_ANALYSIS
|
||||||
employeeDataCategory: SENSITIVE
|
employeeDataCategory: SENSITIVE
|
||||||
|
visibilityConditions:
|
||||||
|
operator: AND
|
||||||
|
conditions:
|
||||||
|
- nodeType: LEAF
|
||||||
|
formElementConditionType: SHOW
|
||||||
|
sourceFormElementReference: sens_sichtbarkeit
|
||||||
|
formElementOperator: NOT_EQUALS
|
||||||
|
formElementExpectedValue: "Für Administratoren"
|
||||||
- value: 'false'
|
- value: 'false'
|
||||||
label: Audit-Logs
|
label: Audit-Logs
|
||||||
processingPurpose: DATA_ANALYSIS
|
processingPurpose: DATA_ANALYSIS
|
||||||
@@ -808,6 +816,14 @@ formElementSubSections:
|
|||||||
label: Fachlich
|
label: Fachlich
|
||||||
processingPurpose: DATA_ANALYSIS
|
processingPurpose: DATA_ANALYSIS
|
||||||
employeeDataCategory: REVIEW_REQUIRED
|
employeeDataCategory: REVIEW_REQUIRED
|
||||||
|
visibilityConditions:
|
||||||
|
operator: AND
|
||||||
|
conditions:
|
||||||
|
- nodeType: LEAF
|
||||||
|
formElementConditionType: SHOW
|
||||||
|
sourceFormElementReference: sens_sichtbarkeit
|
||||||
|
formElementOperator: NOT_EQUALS
|
||||||
|
formElementExpectedValue: "Für Administratoren"
|
||||||
type: CHECKBOX
|
type: CHECKBOX
|
||||||
visibilityConditions:
|
visibilityConditions:
|
||||||
operator: AND
|
operator: AND
|
||||||
|
|||||||
@@ -721,6 +721,14 @@ formElementSubSections:
|
|||||||
label: Ja (Nutzer-/Aktivitätsbezug)
|
label: Ja (Nutzer-/Aktivitätsbezug)
|
||||||
processingPurpose: DATA_ANALYSIS
|
processingPurpose: DATA_ANALYSIS
|
||||||
employeeDataCategory: SENSITIVE
|
employeeDataCategory: SENSITIVE
|
||||||
|
visibilityConditions:
|
||||||
|
operator: AND
|
||||||
|
conditions:
|
||||||
|
- nodeType: LEAF
|
||||||
|
formElementConditionType: SHOW
|
||||||
|
sourceFormElementReference: sens_sichtbarkeit
|
||||||
|
formElementOperator: NOT_EQUALS
|
||||||
|
formElementExpectedValue: "Für Administratoren"
|
||||||
- value: 'false'
|
- value: 'false'
|
||||||
label: Audit-Logs
|
label: Audit-Logs
|
||||||
processingPurpose: DATA_ANALYSIS
|
processingPurpose: DATA_ANALYSIS
|
||||||
@@ -776,6 +784,14 @@ formElementSubSections:
|
|||||||
label: Fachlich
|
label: Fachlich
|
||||||
processingPurpose: DATA_ANALYSIS
|
processingPurpose: DATA_ANALYSIS
|
||||||
employeeDataCategory: REVIEW_REQUIRED
|
employeeDataCategory: REVIEW_REQUIRED
|
||||||
|
visibilityConditions:
|
||||||
|
operator: AND
|
||||||
|
conditions:
|
||||||
|
- nodeType: LEAF
|
||||||
|
formElementConditionType: SHOW
|
||||||
|
sourceFormElementReference: sens_sichtbarkeit
|
||||||
|
formElementOperator: NOT_EQUALS
|
||||||
|
formElementExpectedValue: "Für Administratoren"
|
||||||
type: CHECKBOX
|
type: CHECKBOX
|
||||||
visibilityConditions:
|
visibilityConditions:
|
||||||
operator: AND
|
operator: AND
|
||||||
|
|||||||
@@ -3,20 +3,40 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { FormOptionDto } from '~~/.api-client'
|
import type { FormElementDto, FormOptionDto } from '~~/.api-client'
|
||||||
|
import { useFormElementVisibility } from '~/composables/useFormElementVisibility'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
formOptions: FormOptionDto[]
|
formOptions: FormOptionDto[]
|
||||||
|
allFormElements?: FormElementDto[]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'update:formOptions', value: FormOptionDto[]): void
|
(e: 'update:formOptions', value: FormOptionDto[]): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
// Map options to items format expected by UCheckboxGroup
|
const { isFormOptionVisible } = useFormElementVisibility()
|
||||||
const items = computed(() => props.formOptions.map((option) => ({ label: option.label, value: option.label })))
|
|
||||||
|
const visibleOptions = computed(() => {
|
||||||
|
if (!props.allFormElements) return props.formOptions
|
||||||
|
return props.formOptions.filter((opt) => isFormOptionVisible(opt.visibilityConditions, props.allFormElements!))
|
||||||
|
})
|
||||||
|
|
||||||
|
// Auto-clear hidden options that are still selected
|
||||||
|
watchEffect(() => {
|
||||||
|
if (!props.allFormElements) return
|
||||||
|
const hiddenSelected = props.formOptions.filter(
|
||||||
|
(opt) => opt.value === 'true' && !isFormOptionVisible(opt.visibilityConditions, props.allFormElements!)
|
||||||
|
)
|
||||||
|
if (hiddenSelected.length === 0) return
|
||||||
|
emit(
|
||||||
|
'update:formOptions',
|
||||||
|
props.formOptions.map((opt) => (hiddenSelected.includes(opt) ? { ...opt, value: 'false' } : opt))
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
const items = computed(() => visibleOptions.value.map((option) => ({ label: option.label, value: option.label })))
|
||||||
|
|
||||||
// Model value is an array of labels for checkboxes where value === 'true'
|
|
||||||
const modelValue = computed({
|
const modelValue = computed({
|
||||||
get: () => props.formOptions.filter((option) => option.value === 'true').map((option) => option.label),
|
get: () => props.formOptions.filter((option) => option.value === 'true').map((option) => option.label),
|
||||||
set: (selectedLabels: string[]) => {
|
set: (selectedLabels: string[]) => {
|
||||||
|
|||||||
@@ -3,19 +3,41 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { FormOptionDto } from '~~/.api-client'
|
import type { FormElementDto, FormOptionDto } from '~~/.api-client'
|
||||||
|
import { useFormElementVisibility } from '~/composables/useFormElementVisibility'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
label?: string
|
label?: string
|
||||||
formOptions: FormOptionDto[]
|
formOptions: FormOptionDto[]
|
||||||
|
allFormElements?: FormElementDto[]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'update:formOptions', value: FormOptionDto[]): void
|
(e: 'update:formOptions', value: FormOptionDto[]): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const { isFormOptionVisible } = useFormElementVisibility()
|
||||||
|
|
||||||
|
const visibleOptions = computed(() => {
|
||||||
|
if (!props.allFormElements) return props.formOptions
|
||||||
|
return props.formOptions.filter((opt) => isFormOptionVisible(opt.visibilityConditions, props.allFormElements!))
|
||||||
|
})
|
||||||
|
|
||||||
|
// Auto-clear selected option if it becomes hidden
|
||||||
|
watchEffect(() => {
|
||||||
|
if (!props.allFormElements) return
|
||||||
|
const selectedOption = props.formOptions.find((opt) => opt.value === 'true')
|
||||||
|
if (!selectedOption) return
|
||||||
|
if (!isFormOptionVisible(selectedOption.visibilityConditions, props.allFormElements!)) {
|
||||||
|
emit(
|
||||||
|
'update:formOptions',
|
||||||
|
props.formOptions.map((opt) => ({ ...opt, value: 'false' }))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Our "label" is the "value" of the radio button
|
// Our "label" is the "value" of the radio button
|
||||||
const items = computed(() => props.formOptions.map((option) => ({ label: option.label, value: option.label })))
|
const items = computed(() => visibleOptions.value.map((option) => ({ label: option.label, value: option.label })))
|
||||||
|
|
||||||
const modelValue = computed({
|
const modelValue = computed({
|
||||||
get: () => props.formOptions.find((option) => option.value === 'true')?.label,
|
get: () => props.formOptions.find((option) => option.value === 'true')?.label,
|
||||||
|
|||||||
Reference in New Issue
Block a user