From c10ec33781ee2efc0864dc08b8d20238312ba093 Mon Sep 17 00:00:00 2001 From: Jan-Gerke Salomon Date: Mon, 30 Oct 2023 12:27:40 +0100 Subject: [PATCH] fix(custom attributes optionsets): add no-value-option only when not required --- src/pages/dataElements/form/CustomAttributes.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pages/dataElements/form/CustomAttributes.tsx b/src/pages/dataElements/form/CustomAttributes.tsx index fb67856a..f379ffd5 100644 --- a/src/pages/dataElements/form/CustomAttributes.tsx +++ b/src/pages/dataElements/form/CustomAttributes.tsx @@ -14,25 +14,25 @@ type CustomAttributeProps = { function CustomAttribute({ attribute, index }: CustomAttributeProps) { const name = `attributeValues[${index}].value` + const required = attribute.mandatory if (attribute.optionSet?.options) { - const attributeOptions = attribute.optionSet?.options.map( + const options = attribute.optionSet?.options.map( ({ code, displayName }) => ({ value: code, label: displayName, }) ) - const options = [ - { value: '', label: i18n.t('') }, - ...(attributeOptions || []), - ] + if (required) { + options.unshift({ value: '', label: i18n.t('') }) + } return (