From 6d427a792d015dcca86678948a7a876245e4ae0f Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Wed, 7 Sep 2022 15:26:54 +0200 Subject: [PATCH] fix(dropdown): filter multi_text in valueType --- src/forms/form-fields/drop-down.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/forms/form-fields/drop-down.js b/src/forms/form-fields/drop-down.js index cd7a23759..78adcf615 100644 --- a/src/forms/form-fields/drop-down.js +++ b/src/forms/form-fields/drop-down.js @@ -7,6 +7,12 @@ import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import MenuItem from 'material-ui/MenuItem/MenuItem'; + +// A map to filter out options across all usages of the dropdown +// Entries are ['referenceProperty' of the rendered field, optionsToFilter] +// ['valueType', ['MULTI_TEXT']], means filter out options "MULTI_TEXT" when referenceProperty is "valueType" +const OPTIONS_BLOCK_LIST = new Map([['valueType', ['MULTI_TEXT']]]) + class Dropdown extends Component { constructor(props, context) { super(props, context); @@ -35,12 +41,17 @@ class Dropdown extends Component { } getOptions(options) { - const opts = options + let opts = options .map(option => ({ value: option.value, text: option.text, })); + const blockedProperties = OPTIONS_BLOCK_LIST.get(this.props.referenceProperty) + if(blockedProperties) { + opts = opts.filter(opt => !blockedProperties.includes(opt.value)) + } + return opts .map((option) => { if (option.text && this.props.translateOptions) {