Skip to content

Commit

Permalink
EPMRPP-88348 || multiline field mapping fix (#3734)
Browse files Browse the repository at this point in the history
* EPMRPP-88348 || multiline field mapping fix

* EPMRPP-88348 || code review fixes - 1
  • Loading branch information
Vadim73i authored Jan 23, 2024
1 parent 846ae76 commit 7d1dd80
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions app/src/components/fields/dynamicFieldsSection/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 7d1dd80

Please sign in to comment.