From 301060178c072d3c2f1c9381d50d7466f9c8452d Mon Sep 17 00:00:00 2001 From: Jan-Gerke Salomon Date: Wed, 25 Oct 2023 13:29:20 +0200 Subject: [PATCH] feat(custom attributes): add "No value" option to optionset attributes --- src/pages/dataElements/form/CustomAttributes.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/dataElements/form/CustomAttributes.tsx b/src/pages/dataElements/form/CustomAttributes.tsx index ce0b0326..fb67856a 100644 --- a/src/pages/dataElements/form/CustomAttributes.tsx +++ b/src/pages/dataElements/form/CustomAttributes.tsx @@ -1,3 +1,4 @@ +import i18n from '@dhis2/d2-i18n' import { InputFieldFF, SingleSelectFieldFF, TextAreaFieldFF } from '@dhis2/ui' import * as React from 'react' import { Field as FieldRFF } from 'react-final-form' @@ -15,13 +16,18 @@ function CustomAttribute({ attribute, index }: CustomAttributeProps) { const name = `attributeValues[${index}].value` if (attribute.optionSet?.options) { - const options = attribute.optionSet?.options.map( + const attributeOptions = attribute.optionSet?.options.map( ({ code, displayName }) => ({ value: code, label: displayName, }) ) + const options = [ + { value: '', label: i18n.t('') }, + ...(attributeOptions || []), + ] + return (