CC-163 Add annotation color as a tool in the layer's render tab #53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR moves the widget for color management for local annotation from the annotation tab to the rendering tab, improving UI organization and aligning widget placement with its functionality.
Additionally, this PR fixes an issue in the
removeJsonString
function to handle tool keys, resolving inconsistencies caused by differences in thetoJSON()
method acrossTool
andLegacyTool
classes.Motivation
Relocating the widget enhances usability by grouping it with related options, reducing user confusion.
User Interaction
Widget Relocation: The widget previously located in the state tab is now found in the redering tab. This change simplifies navigation for users working with segment-related settings.
To notify the user that the default color widget moved to the "rendering tab", a new icon with a question mark is displayed in the local-annotation layer, next to the buttons that allows to create new annotations, with a tooltip stating what are the buttons used for, and where is located the color control.
Implementation
Widget Relocation:
Code Changes: Updates in
layer/annotation/index.ts
moved the initialization and rendering logic of the widget to the redering tab.removeJsonString
Fix:Problem: The
toJSON()
method forTool
andLegacyTool
behaves differently. ForLayerTool
(inheriting fromTool
),toJSON()
returns ajsonId
value, causing keys inlocalToolBinder
to include quotes (e.g.,"mykey"
instead ofmykey
). This created mismatches when usingremoveJsonString()
, as it required explicitJSON.stringify()
calls.Solution: The fix first attempts to locate the key directly. If it is not found, it falls back to checking the
JSON.stringify()
version. This approach ensures compatibility with bothTool
andLegacyTool
implementations.