-
Notifications
You must be signed in to change notification settings - Fork 380
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
fix: subtags/parent tags & aliases update the UI for building a tag #534
Conversation
actions = tag_widget.bg_button.actions() | ||
edit_action = [a for a in actions if a.text() == "Edit"][0] | ||
edit_action.triggered.emit() | ||
# actions = tag_widget.bg_button.actions() | ||
# edit_action = [a for a in actions if a.text() == "Edit"][0] | ||
# edit_action.triggered.emit() | ||
|
||
# Then | ||
panel = tag_box_widget.edit_modal.widget | ||
assert isinstance(panel, BuildTagPanel) | ||
assert panel.tag.name == tag.name | ||
assert panel.name_field.text() == tag.name | ||
# NOTE: currently tag_box_widget.edit_modal is never set because its | ||
# edit_tag method is never called | ||
# panel = tag_box_widget.edit_modal.widget | ||
# assert isinstance(panel, BuildTagPanel) | ||
# assert panel.tag.name == tag.name | ||
# assert panel.name_field.text() == tag.name |
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.
commenting out existing tests isnt really convincing that everything works as expected
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.
Sorry, completely forgot I had done that. Thanks for catching it, the test is properly implemented now.
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.
please add tests for newly added methods, thanks.
.vscode/settings.json
Outdated
{ | ||
"cSpell.words": [ | ||
"Abendshien", | ||
"qtbot", | ||
"Voxel" | ||
] | ||
} |
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.
I'd say we want to have whole .vscode
in .gitignore
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.
.vscode is now ignored
@DandyDev01 the PR is still marked as Draft, so am I supposed to review it already? |
@yedpodtrzitko Yes, its ready. Sorry I thought I took it off draft when I sent the review request. |
If adding a tag as a parent of itself corrupts the database entry, IMO a check should be added to make sure that isn't possible rather than hiding the tag in the UI. |
looks good overall, I just noticed some issue with the alias:
another issue with the same button when editing existing tag - clicking the |
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.
Also could you please squash the commits? thanks.
@CyanVoxel can you approve the CI run here? |
Thank you for this PR! I apologize for not getting around to commenting on it earlier. From my understanding, this PR is doing three things:
However I also understand that this PR is not:
The DB connection is still an appreciated addition, and is one step closer to reaching tag feature parity between 9.4 and 9.5. I'd just like to confirm that this was your intention rather than a full re-implementation of these features. If you did intend to re-implement these features so that they're functioning on par with 9.4, then please let me know. As for the alias UI changes, I have some feedback on the direction taken here. While the previous newline separated textbox wasn't completely ideal, I feel that this individually separated line approach makes things a bit more cumbersome to use. My thoughts are:
My recommendations to solve these issues while keeping the spirit of the changes that improve upon the original implementation would be:
|
@CyanVoxel In terms of your feedback, the following is my proposed implementation. Please let me know if you approve of them.
|
added shortcuts for adding and removing aliases and updated the alias ui to always show remove button and not cover alias aliases use flowlayout wrote test for buildTagPanel removeSelectedAlias parent tags now use flowlayout in build tag panel moved buttons for adding aliases and parents to be at the end of the flowLayout
how do I make a query using the tag alias? |
…ed or an alias was removed
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 new alias UI seems to work great! I have no additional comments or requests for that 👍
I noticed that you tried getting the display names working though, which has a couple of issues:
- The SQL database structure does not support a consistent parent tag order. Unfortunately switching from a set to a list will not work as a substitute for what will ultimately be needed in the end: which is a an additional db column referencing which parent tag ID should be use to disambiguate it as the display name.
- These display names don't seem to function regardless, causing an exception on my machine when trying to access the tag manager panel:
Traceback (most recent call last):
File "/Users/cyanvoxel/Files/GitHub/TagStudio/tagstudio/src/qt/ts_qt.py", line 368, in <lambda>
tag_database_action.triggered.connect(lambda: self.show_tag_database())
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cyanvoxel/Files/GitHub/TagStudio/tagstudio/src/qt/ts_qt.py", line 666, in show_tag_database
self.modal.show()
File "/Users/cyanvoxel/Files/GitHub/TagStudio/tagstudio/src/qt/modals/tag_database.py", line 119, in showEvent
self.update_tags()
File "/Users/cyanvoxel/Files/GitHub/TagStudio/tagstudio/src/qt/modals/tag_database.py", line 87, in update_tags
display_name = tag.display_name
^^^^^^^^^^^^^^^^
File "/Users/cyanvoxel/Files/GitHub/TagStudio/tagstudio/src/core/library/alchemy/models.py", line 81, in display_name
if len(self.parent_tags) == 0:
^^^^^^^^^^^^^^^^
File "/Users/cyanvoxel/Files/GitHub/TagStudio/.venv/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 566, in __get__
return self.impl.get(state, dict_) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cyanvoxel/Files/GitHub/TagStudio/.venv/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 1086, in get
value = self._fire_loader_callables(state, key, passive)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cyanvoxel/Files/GitHub/TagStudio/.venv/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 1121, in _fire_loader_callables
return self.callable_(state, passive)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cyanvoxel/Files/GitHub/TagStudio/.venv/lib/python3.12/site-packages/sqlalchemy/orm/strategies.py", line 918, in _load_for_state
raise orm_exc.DetachedInstanceError(
sqlalchemy.orm.exc.DetachedInstanceError: Parent instance <Tag at 0x171e0ea80> is not bound to a Session; lazy load operation of attribute 'parent_tags' cannot proceed (Background on this error at: https://sqlalche.me/e/20/bhk3)
I would suggest just reverting any additions regarding display names here. If you would like to eventually tackle them, I would also suggest taking that on in a separate PR (it's gonna involve some nasty work though so I don't blame you if you'd want to pass on that)
And finally, the bug I mentioned here on #596 is still present. Since this is currently a live bug on main now I would suggest trying to fix that in a new PR that can be merged in the meantime, or at least let me know if you wouldn't like to work on it so that I can open it up to others.
But other than the backend stuff, the UI and UX improvements to the alias list are great!
…d be added in a different PR
I've just removed them, as you said that is definitely something for a separate PR
I'll create a PR for those changes then |
c0e01ff
to
38b0e5d
Compare
primaryjoin="Tag.id == TagSubtag.parent_id", | ||
secondaryjoin="Tag.id == TagSubtag.child_id", |
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.
Any specific reason for this change?
@@ -618,7 +618,6 @@ def search_tags( | |||
results=len(res), | |||
) | |||
|
|||
session.expunge_all() |
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.
Any reason for this as well?
@@ -12,7 +12,6 @@ | |||
|
|||
import cv2 | |||
import numpy as np | |||
import pillow_jxl # noqa: F401 |
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.
Was removing this import accidental? This is used for JPEG XL support
session.expunge_all() on line 621 was removed, added it back.
parent_tags primaryJoin and secondaryJoin where in the wrong order. They have been switched back to the proper order.
Not sure why the MyPy check is failing here as it passes on my machines, looking into it now. |
The MyPy workflow is failing on this, though I still don't know why I can't reproduce it locally:
|
I'm suspecting that something is wrong with the workflow and isn't running on this PR properly, as these line numbers only make sense when looking at the current |
So it's not a workflow issue - MyPy just creates a new merge commit and sees that the type hint changes here are conflicting with a call to |
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.
Thank you for all your work on this! I apologize for the long turnaround time and roundabout PRs for this, but I appreciate you working with me and I love the final results here!
The following has moved to #596
subtags can be added and removed when creating or editing a Tag
- parent tags would not be listed before
- parent tags could not be removed beforecan exclude tags from the tag search panel
- it was possible to make a tag parent itself before. Now when selecting a parent tag, the tag being created or edited isexcluded from the tag search panel, so it cannot be added as a parent to itself.
- before when a tag could parent itself, that tag would be corrupted and users would be unable to edit the tag or add itas a parent to another tag (this would corrupt that tag too)- aliases can be removed and added
- aliases can be edited
- added support for display name on Tags. This is a parity feature from the json DB.This PR is meant to update the UI for aliases to use a table like the exclude file extensions.
changed how aliases are managed (UI is a table):