Skip to content

Commit

Permalink
Fixed number attribute (#972)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored and nmanovic committed Dec 17, 2019
1 parent 2ec4b32 commit 5331c13
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions cvat-ui/src/components/labels-editor/label-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,30 @@ class LabelForm extends React.PureComponent<Props, {}> {
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();
Expand Down

0 comments on commit 5331c13

Please sign in to comment.