Skip to content

Commit

Permalink
Merge pull request #2317 from dhis2/fix/filter-multi-text-valueType
Browse files Browse the repository at this point in the history
fix(dropdown): filter multi_text in valueType
  • Loading branch information
Birkbjo authored Sep 7, 2022
2 parents 64699ed + 6d427a7 commit b491563
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/forms/form-fields/drop-down.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b491563

Please sign in to comment.