diff --git a/app/src/components/fields/dynamicFieldsSection/utils.js b/app/src/components/fields/dynamicFieldsSection/utils.js index 63bb4f54c8..3b31327d26 100644 --- a/app/src/components/fields/dynamicFieldsSection/utils.js +++ b/app/src/components/fields/dynamicFieldsSection/utils.js @@ -24,9 +24,16 @@ import { AUTOCOMPLETE_TYPE, MULTIPLE_AUTOCOMPLETE_TYPE, CREATABLE_MULTIPLE_AUTOCOMPLETE_TYPE, + MULTILINE_TEXT_TYPE, } from './constants'; import { FIELDS_MAP } from './dynamicFieldMap'; +const AUTOCOMPLETE_TYPES = [ + AUTOCOMPLETE_TYPE, + MULTIPLE_AUTOCOMPLETE_TYPE, + CREATABLE_MULTIPLE_AUTOCOMPLETE_TYPE, +]; + const normalizeDefinedValue = (item) => !item[VALUE_ID_KEY] ? { ...item, [VALUE_ID_KEY]: item[VALUE_NAME_KEY] } : item; @@ -67,22 +74,16 @@ export const mapFieldsToValues = (fields, predefinedFieldValue, predefinedFieldK export const getFieldComponent = (field) => { let fieldType = TEXT_TYPE; - if (field.fieldType === ARRAY_TYPE && field.definedValues && field.definedValues.length) { + if (field.fieldType === MULTILINE_TEXT_TYPE) { + fieldType = MULTILINE_TEXT_TYPE; + } else if (field.fieldType === ARRAY_TYPE && field.definedValues && field.definedValues.length) { fieldType = ARRAY_TYPE; } else if (field.fieldType === DATE_TYPE || field.fieldType.toLowerCase() === 'datetime') { fieldType = DATE_TYPE; } else if (field.definedValues && field.definedValues.length && field.fieldType !== ARRAY_TYPE) { fieldType = DROPDOWN_TYPE; - } else if (field.commandName) { - if (field.fieldType === AUTOCOMPLETE_TYPE) { - fieldType = AUTOCOMPLETE_TYPE; - } - if (field.fieldType === MULTIPLE_AUTOCOMPLETE_TYPE) { - fieldType = MULTIPLE_AUTOCOMPLETE_TYPE; - } - if (field.fieldType === CREATABLE_MULTIPLE_AUTOCOMPLETE_TYPE) { - fieldType = CREATABLE_MULTIPLE_AUTOCOMPLETE_TYPE; - } + } else if (field.commandName && AUTOCOMPLETE_TYPES.includes(field.fieldType)) { + fieldType = field.fieldType; } return FIELDS_MAP[fieldType];