From ba8d064b52eee5440a6ff73ba4e25dd6e758a47a Mon Sep 17 00:00:00 2001 From: Marci Date: Mon, 19 Jul 2021 13:56:03 +0200 Subject: [PATCH] Added smart attribute keeping when changing label (#3309) * Added smart attribute keeping when changing label * Removed input type check --- cvat-core/src/annotations-objects.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cvat-core/src/annotations-objects.js b/cvat-core/src/annotations-objects.js index 7ffe1bd3..2bd2d61e 100644 --- a/cvat-core/src/annotations-objects.js +++ b/cvat-core/src/annotations-objects.js @@ -248,6 +248,18 @@ this.label = label; this.attributes = {}; this.appendDefaultAttributes(label); + + // Try to keep old attributes if name matches and old value is still valid + for (const attribute of redoLabel.attributes) { + for (const oldAttribute of undoLabel.attributes) { + if ( + attribute.name === oldAttribute.name + && validateAttributeValue(undoAttributes[oldAttribute.id], attribute) + ) { + this.attributes[attribute.id] = undoAttributes[oldAttribute.id]; + } + } + } const redoAttributes = { ...this.attributes }; this.history.do(