From abd90397a7e86301517544d6b66a69c805ec6550 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Tue, 17 Dec 2019 15:31:58 +0300 Subject: [PATCH] Fixed number attribute --- .../components/labels-editor/label-form.tsx | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/cvat-ui/src/components/labels-editor/label-form.tsx b/cvat-ui/src/components/labels-editor/label-form.tsx index 6bd5630a04d..6ad63efdfd3 100644 --- a/cvat-ui/src/components/labels-editor/label-form.tsx +++ b/cvat-ui/src/components/labels-editor/label-form.tsx @@ -52,22 +52,30 @@ class LabelForm extends React.PureComponent { onSubmit, } = this.props; - form.validateFields((error, values): void => { + form.validateFields((error, formValues): void => { if (!error) { onSubmit({ - name: values.labelName, + name: formValues.labelName, id: label ? label.id : idGenerator(), - attributes: values.keys.map((key: number, index: number): Attribute => ( - { - name: values.attrName[key], - type: values.type[key], - mutable: values.mutable[key], + attributes: formValues.keys.map((key: number, index: number): Attribute => { + let attrValues = formValues.values[key]; + if (!Array.isArray(attrValues)) { + if (formValues.type[key] === AttributeType.NUMBER) { + attrValues = attrValues.split(';'); + } else { + attrValues = [attrValues]; + } + } + + return { + name: formValues.attrName[key], + type: formValues.type[key], + mutable: formValues.mutable[key], id: label && index < label.attributes.length ? label.attributes[index].id : key, - values: Array.isArray(values.values[key]) - ? values.values[key] : [values.values[key]], - } - )), + values: attrValues, + }; + }), }); form.resetFields();