diff --git a/frontend/src/components/common/FormGroup.vue b/frontend/src/components/common/FormGroup.vue index 29a8f87b..f57d7479 100644 --- a/frontend/src/components/common/FormGroup.vue +++ b/frontend/src/components/common/FormGroup.vue @@ -5,7 +5,7 @@ --> - + diff --git a/frontend/src/components/question/FormElement.vue b/frontend/src/components/question/FormElement.vue index 4b6961d0..2a2a97a6 100644 --- a/frontend/src/components/question/FormElement.vue +++ b/frontend/src/components/question/FormElement.vue @@ -12,14 +12,14 @@ import { computed } from 'vue' import type { ComponentInstance } from 'vue' -import type { FormElement } from '@/types' +import type { ElementPath, FormElement } from '@/types' import { mapElementKindToComponent } from './elements' const props = defineProps<{ disabled: boolean element: FormElement - pathPrefix: string[] + pathPrefix: ElementPath }>() const elementComponent = computed(() => mapElementKindToComponent(props.element.kind)) diff --git a/frontend/src/components/question/OptionsSection.vue b/frontend/src/components/question/OptionsSection.vue index eb951d3e..a76dc645 100644 --- a/frontend/src/components/question/OptionsSection.vue +++ b/frontend/src/components/question/OptionsSection.vue @@ -5,14 +5,14 @@ --> - {{ header }} - + + {{ header }} + + + + + + diff --git a/frontend/src/components/question/ValidationFeedback.vue b/frontend/src/components/question/ValidationFeedback.vue new file mode 100644 index 00000000..10d75e91 --- /dev/null +++ b/frontend/src/components/question/ValidationFeedback.vue @@ -0,0 +1,15 @@ + + + + {{ validation.text }} + + + diff --git a/frontend/src/components/question/elements/CheckboxElement.vue b/frontend/src/components/question/elements/CheckboxElement.vue index a24ceba9..0317facf 100644 --- a/frontend/src/components/question/elements/CheckboxElement.vue +++ b/frontend/src/components/question/elements/CheckboxElement.vue @@ -5,43 +5,47 @@ --> - + {{ element.right_label }} + {{ helpText }} diff --git a/frontend/src/components/question/elements/GeneratedIdElement.vue b/frontend/src/components/question/elements/GeneratedIdElement.vue index 3b881a71..7e21826e 100644 --- a/frontend/src/components/question/elements/GeneratedIdElement.vue +++ b/frontend/src/components/question/elements/GeneratedIdElement.vue @@ -5,17 +5,19 @@ --> - + diff --git a/frontend/src/components/question/elements/GroupElement.vue b/frontend/src/components/question/elements/GroupElement.vue index 6d76bb67..cad85f0d 100644 --- a/frontend/src/components/question/elements/GroupElement.vue +++ b/frontend/src/components/question/elements/GroupElement.vue @@ -5,33 +5,34 @@ --> - - + + + + - {{ helpText }} diff --git a/frontend/src/components/question/elements/HiddenElement.vue b/frontend/src/components/question/elements/HiddenElement.vue index 5137d4e7..9759889e 100644 --- a/frontend/src/components/question/elements/HiddenElement.vue +++ b/frontend/src/components/question/elements/HiddenElement.vue @@ -5,22 +5,23 @@ --> - + diff --git a/frontend/src/components/question/elements/RadioGroupElement.vue b/frontend/src/components/question/elements/RadioGroupElement.vue index 5760993b..44b9d122 100644 --- a/frontend/src/components/question/elements/RadioGroupElement.vue +++ b/frontend/src/components/question/elements/RadioGroupElement.vue @@ -5,16 +5,17 @@ --> - + + {{ helpText }} @@ -24,25 +25,29 @@ import { computed } from 'vue' import { useAriaDescribedBy, - useCommon, useConditions, useHelp, + useId, useIsDisabled, useModel, + usePath, + useValidation, } from '@/composables/question/elements' -import type { RadioGroupElement } from '@/types' +import type { ElementPath, RadioGroupElement } from '@/types' const { disabled, element, pathPrefix } = defineProps<{ disabled: boolean element: RadioGroupElement - pathPrefix: string[] + pathPrefix: ElementPath }>() -const { id, name } = useCommon(pathPrefix, element) +const path = usePath(pathPrefix, element) +const id = useId(path) const model = useModel(pathPrefix, element) const { isDisabledByCond, isHiddenByCond } = useConditions(pathPrefix, element) const { helpId, helpText } = useHelp(pathPrefix, element) const isDisabled = useIsDisabled(computed(() => disabled || isDisabledByCond.value)) const ariaDescribedBy = useAriaDescribedBy([helpId.value]) const options = computed(() => element.options.map(({ value, label }) => ({ value, text: label }))) +const validation = useValidation(path) diff --git a/frontend/src/components/question/elements/RepetitionElement.vue b/frontend/src/components/question/elements/RepetitionElement.vue index cdc688d0..22250b4b 100644 --- a/frontend/src/components/question/elements/RepetitionElement.vue +++ b/frontend/src/components/question/elements/RepetitionElement.vue @@ -5,56 +5,47 @@ --> - - - + + + + + + + - {{ element.button_label ?? 'Add repetition' }} - Remove + {{ + element.button_label ?? 'Add repetition' + }} - - + + + diff --git a/frontend/src/components/question/elements/SelectElement.vue b/frontend/src/components/question/elements/SelectElement.vue index 8707e0df..c2504d9b 100644 --- a/frontend/src/components/question/elements/SelectElement.vue +++ b/frontend/src/components/question/elements/SelectElement.vue @@ -5,18 +5,19 @@ --> - + + {{ helpText }} @@ -26,29 +27,33 @@ import { computed } from 'vue' import { useAriaDescribedBy, - useCommon, useConditions, useHelp, + useId, useIsDisabled, useModel, + usePath, + useValidation, } from '@/composables/question/elements' -import type { SelectElement } from '@/types' +import type { ElementPath, SelectElement } from '@/types' const { disabled, element, pathPrefix } = defineProps<{ disabled: boolean element: SelectElement - pathPrefix: string[] + pathPrefix: ElementPath }>() const MAX_SIZE = 8 const size = computed(() => (element.multiple ? Math.min(element.options.length, MAX_SIZE) : undefined)) -const { id, name } = useCommon(pathPrefix, element) +const path = usePath(pathPrefix, element) +const id = useId(path) const model = useModel(pathPrefix, element) const { isDisabledByCond, isHiddenByCond } = useConditions(pathPrefix, element) const { helpId, helpText } = useHelp(pathPrefix, element) const isDisabled = useIsDisabled(computed(() => disabled || isDisabledByCond.value)) const ariaDescribedBy = useAriaDescribedBy([helpId.value]) +const validation = useValidation(path) const options = computed(() => element.options.map((opts) => ({ diff --git a/frontend/src/components/question/elements/StaticTextElement.vue b/frontend/src/components/question/elements/StaticTextElement.vue index 838c0197..55b4caa4 100644 --- a/frontend/src/components/question/elements/StaticTextElement.vue +++ b/frontend/src/components/question/elements/StaticTextElement.vue @@ -13,11 +13,11 @@