-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GSoC2024] Implemented drag and drop feature #7624
[GSoC2024] Implemented drag and drop feature #7624
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally im not sure if this solution is good in UX terms. Design with arrows is a bit outdated and not so comfortable to use (if I want to place 10th attribute to the first place I need to make 10 clicks 😟).
Lets return to original proposal, as the author of 7370 mentiones, it sould be implemented as drag-n-drop. I belive we need to use dots icon that is shown only on hover.
It should be something similar to:
In CVAT, we use react-grid-layout to help us implement draggable and responsible layouts on analytics page and canvas-layout. I would suggest to implement this feature using specific rows-only draggable layout.
Also, please, add a link to the issue you're trying to resolve in PR description. And dont forget to add a changelog entry.
Ok, I will make the changes |
Hey I think react-grid-layout doesn't works on Forms. |
What do you mean by doesnt work on Forms? Could you describe the soultion you are trying to implement so we can discuss it? |
I was trying to implement the same but after wrapping with < ReactGridLayout >, this.renderAttributes was not returning anything. Most probably because fieldInstances was empty when calling from < ReactGridLayout >. |
I think we dont need to pass |
Hey, I have almost completed it but I am facing a problem. The thing is when we change the layout, I update the attributes list and this layout updates based on this new attributes list. These were the changes that I have made: url. |
Hi @KrishavRajSingh , As I can see you are trying to update form after layout changes and then it re-renders. I think we can fix this problem by managing layout somewhere outside of the form. There should be some state for the layout. By default it should be empty, then on first render of the form we set it up. If user makes some changes, we set the state of the layout object. When the form is submitted ( |
Hi @KrishavRajSingh, |
I am looking into this. |
Thanks for this, I was finally able to implement this drag&drop. Drag.Drop_CVAT.mp4 |
@@ -49,7 +49,7 @@ | |||
from cvat.apps.engine.frame_provider import FrameProvider | |||
from cvat.apps.engine.media_extractors import get_mime | |||
from cvat.apps.engine.models import ( | |||
ClientFile, Job, JobType, Label, SegmentType, Task, Project, Issue, Data, | |||
ClientFile, Job, JobType, Label, AttributeSpec, SegmentType, Task, Project, Issue, Data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused import.
Also please check failing linters and tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- cvat-ui/src/components/labels-editor/label-form.tsx (7 hunks)
- cvat-ui/src/components/labels-editor/styles.scss (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- cvat-ui/src/components/labels-editor/styles.scss
Additional Context Used
Biome (20)
cvat-ui/src/components/labels-editor/label-form.tsx (20)
75-75: Unexpected any. Specify a different type.
157-157: Unexpected any. Specify a different type.
163-163: Unexpected any. Specify a different type.
163-163: Unexpected any. Specify a different type.
166-166: Unexpected any. Specify a different type.
166-166: Unexpected any. Specify a different type.
182-182: Unexpected any. Specify a different type.
196-196: Unexpected any. Specify a different type.
196-196: Unexpected any. Specify a different type.
241-241: Unexpected any. Specify a different type.
241-241: Unexpected any. Specify a different type.
246-246: Unexpected any. Specify a different type.
323-323: Unexpected any. Specify a different type.
345-345: Unexpected any. Specify a different type.
345-345: Unexpected any. Specify a different type.
349-349: Unexpected any. Specify a different type.
398-398: Unexpected any. Specify a different type.
408-408: Unexpected any. Specify a different type.
408-408: Unexpected any. Specify a different type.
426-426: Unexpected any. Specify a different type.
Additional comments not posted (4)
cvat-ui/src/components/labels-editor/label-form.tsx (4)
Line range hint
20-31
: Import and setup ofreact-grid-layout
for drag-and-drop functionality.This setup is crucial for the drag-and-drop feature and has been correctly implemented. The
WidthProvider
HOC is used to manage the grid's width, which is a common practice withreact-grid-layout
.
465-501
: Implementation of the drag-and-drop UI for attributes.The UI components for drag-and-drop are well-structured and follow the design requirements. The use of
HolderOutlined
for the drag handle is consistent with the initial feedback from the review comments.
704-730
: Integration ofReactGridLayout
for managing attribute layout.The integration of
ReactGridLayout
to manage the layout of attributes dynamically is a good use of the library. TheonLayoutChange
handler updates the form's layout state correctly, ensuring that the attribute order is preserved.
70-79
: Handling of attribute reordering logic in the form submission.The logic to reorder attributes based on the layout from the form is well-implemented. However, consider using a more specific type than
any
for theobj
parameter in the loop to enhance type safety.
I have fixed almost everything, but I am not able to run the tests locally. Please help me with that. |
@KrishavRajSingh |
Hey, I am getting thia issue while generating cvat-sdk for tests. |
|
Hi @KrishavRajSingh, sorry for the long response, we will try to look on the issue. |
Hey @klakhov , you may review this now. Sorry for taking this long. |
Also I was informed that I need to make a similar drag and drop for Annotation labels, so should I make this here or should I make a separate PR? |
Please, look at the updates |
@klakhov you may review this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @KrishavRajSingh,
As I see now you are trying to adjust height of elements based on having/not-having error using some unspecified constants as 8
,6
, 25
etc. I dont think this approach is correct. Consider this: I've incorrectly filled up a attibute name with two errors and now adjustments are not working:
In other case, what if we will try to add the LabelForm
component on other page where the width of the container would be different. It will break the adjustments too.
We need to calculate height automatically based on current form component height(with errors) and base row height. We can use some constants but maybe for ratios, not for the height itself. There is a thread about this in RGL repo. Can we try to get the actual width of the components and resize its grid height based on it?
Also, the same comment as before, we need to make the drag element padding smaller, its too large now.
|
||
.cvat-save-cancel-btn { | ||
padding-top: 0.1rem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same comment as before, please dont use rem, use $grid-unit-size
|
||
.anticon-holder > svg { | ||
height: 3 / 2 * $grid-unit-size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
height: 3 / 2 * $grid-unit-size; | |
height: $grid-unit-size * 1.5; |
This PR has no activity for more than a month, I will close it for now. If you wish to finish the contribution feel free to re-open 😄 |
Sorry for this, am pretty busy for a while. |
Added the feature of dragging attributes
Motivation and context
resolves #7370
Checklist
develop
branch(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit
New Features
Style