feat(frontend,api): Add checkbox and select
This commit is contained in:
@@ -881,7 +881,7 @@ components:
|
|||||||
FormElementType:
|
FormElementType:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- DROPDOWN
|
- SELECT
|
||||||
- CHECKBOX
|
- CHECKBOX
|
||||||
- RADIOBUTTON
|
- RADIOBUTTON
|
||||||
- TEXTFIELD
|
- TEXTFIELD
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ const emit = defineEmits<{
|
|||||||
function getResolvedComponent(formElement: FormElementDto) {
|
function getResolvedComponent(formElement: FormElementDto) {
|
||||||
switch (formElement.type) {
|
switch (formElement.type) {
|
||||||
case 'CHECKBOX':
|
case 'CHECKBOX':
|
||||||
case 'DROPDOWN':
|
return resolveComponent('TheCheckbox')
|
||||||
|
case 'SELECT':
|
||||||
|
return resolveComponent('TheSelect')
|
||||||
case 'RADIOBUTTON':
|
case 'RADIOBUTTON':
|
||||||
return resolveComponent('TheRadioGroup')
|
return resolveComponent('TheRadioGroup')
|
||||||
case 'SWITCH':
|
case 'SWITCH':
|
||||||
|
|||||||
28
legalconsenthub/components/formelements/TheCheckbox.vue
Normal file
28
legalconsenthub/components/formelements/TheCheckbox.vue
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<template>
|
||||||
|
<UCheckbox v-model="modelValue" :label="label" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { FormOptionDto } from '~/.api-client'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
formOptions: FormOptionDto[]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:formOptions', value: FormOptionDto[]): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const modelValue = computed({
|
||||||
|
get: () => props.formOptions?.[0].value === 'true',
|
||||||
|
set: (val) => {
|
||||||
|
if (props.formOptions?.[0]) {
|
||||||
|
const updatedModelValue = [...props.formOptions]
|
||||||
|
updatedModelValue[0] = { ...updatedModelValue[0], value: val.toString() }
|
||||||
|
emit('update:formOptions', updatedModelValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const label = computed(() => props.formOptions?.[0].label ?? '')
|
||||||
|
</script>
|
||||||
32
legalconsenthub/components/formelements/TheSelect.vue
Normal file
32
legalconsenthub/components/formelements/TheSelect.vue
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<template>
|
||||||
|
<USelect v-model="modelValue" placeholder="Select status" :items="items" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { FormOptionDto } from '~/.api-client'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
label?: string
|
||||||
|
formOptions: FormOptionDto[]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:formOptions', value: FormOptionDto[]): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
// Our "label" is the "value" of the select
|
||||||
|
const items = computed(() => props.formOptions.map((option) => ({ label: option.label, value: option.label })))
|
||||||
|
|
||||||
|
const modelValue = computed({
|
||||||
|
get: () => props.formOptions.find((option) => option.value === 'true')?.label,
|
||||||
|
set: (val) => {
|
||||||
|
if (val) {
|
||||||
|
const updatedModelValue = [...props.formOptions]
|
||||||
|
updatedModelValue.forEach((option) => {
|
||||||
|
option.value = option.label === val ? 'true' : 'false'
|
||||||
|
})
|
||||||
|
emit('update:formOptions', updatedModelValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -41,6 +41,7 @@ export const complianceMap = new Map<ProcessingPurpose, Map<EmployeeDataCategory
|
|||||||
|
|
||||||
export const complianceCheckableElementTypes: FormElementType[] = [
|
export const complianceCheckableElementTypes: FormElementType[] = [
|
||||||
FormElementType.Switch,
|
FormElementType.Switch,
|
||||||
|
FormElementType.Select,
|
||||||
FormElementType.Checkbox,
|
FormElementType.Checkbox,
|
||||||
FormElementType.Radiobutton
|
FormElementType.Radiobutton
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user