From 16428c2075949fd13d64cf380be38d962619cb90 Mon Sep 17 00:00:00 2001 From: Boris Sekachev <40690378+bsekachev@users.noreply.github.com> Date: Wed, 24 Jun 2020 22:37:18 +0300 Subject: [PATCH] Bug fixes: Propagation from the latest frame, number attribute validation (#1800) * Improved messages for number attribute validation, fixed propagation from the latest frame, fixed checking of a number attribute * Updated versions * Updated changelog --- CHANGELOG.md | 2 ++ cvat-core/package.json | 2 +- cvat-core/src/annotations-collection.js | 20 ++++++++++--------- cvat-core/src/annotations-objects.js | 3 +-- cvat-ui/package-lock.json | 2 +- cvat-ui/package.json | 2 +- .../components/labels-editor/label-form.tsx | 18 +++++++++++------ 7 files changed, 29 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93db8bb5f696..d28c576e47f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Wrong resolution for resizing a shape () - React warning because of not unique keys in labels viewer () - A couple of exceptions in AAM related with early object activation () +- Propagation from the latest frame () +- Number attribute value validation (didn't work well with floats) () ### Security diff --git a/cvat-core/package.json b/cvat-core/package.json index 5c62139ad00c..29bc84cdf4da 100644 --- a/cvat-core/package.json +++ b/cvat-core/package.json @@ -1,6 +1,6 @@ { "name": "cvat-core", - "version": "3.0.0", + "version": "3.0.1", "description": "Part of Computer Vision Tool which presents an interface for client-side integration", "main": "babel.config.js", "scripts": { diff --git a/cvat-core/src/annotations-collection.js b/cvat-core/src/annotations-collection.js index 654e89c5b248..1ea2f7e9be6c 100644 --- a/cvat-core/src/annotations-collection.js +++ b/cvat-core/src/annotations-collection.js @@ -817,15 +817,17 @@ .concat(imported.tracks) .concat(imported.shapes); - this.history.do(HistoryActions.CREATED_OBJECTS, () => { - importedArray.forEach((object) => { - object.removed = true; - }); - }, () => { - importedArray.forEach((object) => { - object.removed = false; - }); - }, importedArray.map((object) => object.clientID), objectStates[0].frame); + if (objectStates.length) { + this.history.do(HistoryActions.CREATED_OBJECTS, () => { + importedArray.forEach((object) => { + object.removed = true; + }); + }, () => { + importedArray.forEach((object) => { + object.removed = false; + }); + }, importedArray.map((object) => object.clientID), objectStates[0].frame); + } return importedArray.map((value) => value.clientID); } diff --git a/cvat-core/src/annotations-objects.js b/cvat-core/src/annotations-objects.js index e4b3402e7c6b..ece5dec06b45 100644 --- a/cvat-core/src/annotations-objects.js +++ b/cvat-core/src/annotations-objects.js @@ -156,8 +156,7 @@ if (type === AttributeType.NUMBER) { return +value >= +values[0] - && +value <= +values[1] - && !((+value - +values[0]) % +values[2]); + && +value <= +values[1]; } if (type === AttributeType.CHECKBOX) { diff --git a/cvat-ui/package-lock.json b/cvat-ui/package-lock.json index f521fbcedc4b..6c222da0e1dc 100644 --- a/cvat-ui/package-lock.json +++ b/cvat-ui/package-lock.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.4.0", + "version": "1.4.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 0db6a04d12e3..6aa9558b3dea 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.4.0", + "version": "1.4.1", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { diff --git a/cvat-ui/src/components/labels-editor/label-form.tsx b/cvat-ui/src/components/labels-editor/label-form.tsx index c9a60fde9382..b40e0b8a284f 100644 --- a/cvat-ui/src/components/labels-editor/label-form.tsx +++ b/cvat-ui/src/components/labels-editor/label-form.tsx @@ -239,21 +239,27 @@ class LabelForm extends React.PureComponent { .split(';') .map((number): number => Number.parseFloat(number)); if (numbers.length !== 3) { - callback('Invalid input'); + callback('Three numbers are expected'); } for (const number of numbers) { if (Number.isNaN(number)) { - callback('Invalid input'); + callback(`"${number}" is not a number`); } } - if (numbers[0] >= numbers[1]) { - callback('Invalid input'); + const [min, max, step] = numbers; + + if (min >= max) { + callback('Minimum must be less than maximum'); + } + + if (max - min < step) { + callback('Step must be less than minmax difference'); } - if (+numbers[1] - +numbers[0] < +numbers[2]) { - callback('Invalid input'); + if (step <= 0) { + callback('Step must be a positive number'); } callback();