diff --git a/cvat-ui/src/components/labels-editor/label-form.tsx b/cvat-ui/src/components/labels-editor/label-form.tsx index e2bb89b5..62633206 100644 --- a/cvat-ui/src/components/labels-editor/label-form.tsx +++ b/cvat-ui/src/components/labels-editor/label-form.tsx @@ -50,22 +50,24 @@ export default class LabelForm extends React.Component { const { label, onSubmit } = this.props; onSubmit({ - name: values.labelName, + name: values.name, id: label ? label.id : idGenerator(), - color: values.labelColor, + color: values.color, attributes: values.attributes.map((attribute: Store) => { - let attrValues: any = attribute.values; - if (attribute.input_type === AttributeType.NUMBER) { - attrValues = attrValues.split(';'); - } else { - attrValues = [attrValues]; + let attrValues: string | string[] = attribute.values; + if (!Array.isArray(attrValues)) { + if (attribute.type === AttributeType.NUMBER) { + attrValues = attrValues.split(';'); + } else { + attrValues = [attrValues]; + } } attrValues = attrValues.map((value: string) => value.trim()); return { ...attribute, values: attrValues, - input_type: attribute.type, + input_type: attribute.type.toLowerCase(), }; }), }); @@ -366,7 +368,7 @@ export default class LabelForm extends React.Component { return ( { const { label } = this.props; return ( - - - - - - + + {() => ( + + + + + + + + )} ); } @@ -486,16 +492,20 @@ export default class LabelForm extends React.Component { public componentDidMount(): void { const { label } = this.props; if (this.formRef.current) { - this.formRef.current.setFieldsValue({ - attributes: label ? - label.attributes.map( - (attribute: Attribute): Store => ({ - ...attribute, - type: attribute.input_type, - }), - ) : - [], - }); + const convertedAttributes = label ? + label.attributes.map( + (attribute: Attribute): Store => ({ + ...attribute, + type: attribute.input_type.toUpperCase(), + }), + ) : + []; + + for (const attr of convertedAttributes) { + delete attr.input_type; + } + + this.formRef.current.setFieldsValue({ attributes: convertedAttributes }); } } @@ -504,10 +514,12 @@ export default class LabelForm extends React.Component {
{this.renderLabelNameInput()} - - {this.renderChangeColorButton()} - - {this.renderNewAttributeButton()} + + {this.renderChangeColorButton()} + + + {this.renderNewAttributeButton()} +