Commit 20db5680 by Peter Holmberg Committed by GitHub

Fix: Value mappings match against string values (#25929)

* Use standard input for value mappings value

* add test and case for matching string values

* re add number on rangemap

* remove FieldTypeNumber required
parent 275c3750
......@@ -78,4 +78,15 @@ describe('Format value with value mappings', () => {
expect(getMappedValue(valueMappings, value).text).toEqual('1-20');
});
it('should map value text to mapping', () => {
const valueMappings: ValueMapping[] = [
{ id: 0, operator: '', text: '1-20', type: MappingType.RangeToText, from: '1', to: '20' },
{ id: 1, operator: '', text: 'ELVA', type: MappingType.ValueToText, value: 'elva' },
];
const value = 'elva';
expect(getMappedValue(valueMappings, value).text).toEqual('ELVA');
});
});
......@@ -19,7 +19,9 @@ const addValueToTextMappingText = (
const valueToTextMappingAsNumber = parseFloat(valueToTextMapping.value as string);
if (isNaN(valueAsNumber) || isNaN(valueToTextMappingAsNumber)) {
return allValueMappings;
if (value === valueToTextMapping.value) {
return allValueMappings.concat(valueToTextMapping);
}
}
if (valueAsNumber !== valueToTextMappingAsNumber) {
......
......@@ -83,7 +83,6 @@ export const MappingRow: React.FC<Props> = ({ valueMapping, updateValueMapping,
<>
<Field label="Value">
<Input
type="number"
defaultValue={(valueMapping as ValueMap).value}
onBlur={e => onMappingValueChange(e.currentTarget.value)}
onKeyDown={onKeyDown(onMappingValueChange)}
......
......@@ -161,7 +161,7 @@ export const getStandardFieldConfigs = () => {
process: valueMappingsOverrideProcessor,
settings: {},
defaultValue: [],
shouldApply: field => field.type === FieldType.number,
shouldApply: () => true,
category: ['Value mappings'],
getItemsCount: (value?) => (value ? value.length : 0),
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment