Skip to content
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

feat: remove and create tags from tag database panel #569

Merged
merged 13 commits into from
Dec 20, 2024

Conversation

DandyDev01
Copy link
Contributor

@DandyDev01 DandyDev01 commented Oct 31, 2024

Added a button in the tag database panel for creating new tags
added ability to delete tags from the tag database panel

image

@DandyDev01 DandyDev01 marked this pull request as ready for review October 31, 2024 02:32
@CyanVoxel CyanVoxel linked an issue Nov 3, 2024 that may be closed by this pull request
3 tasks
@CyanVoxel CyanVoxel added Type: Enhancement New feature or request Type: UI/UX User interface and/or user experience TagStudio: Tags Relating to the TagStudio tag system Status: Review Needed A review of this is needed labels Nov 3, 2024
@CyanVoxel CyanVoxel added this to the Alpha v9.5 (Post-SQL) milestone Nov 3, 2024
@CyanVoxel CyanVoxel added the Priority: Medium An issue that shouldn't be be saved for last label Nov 7, 2024
Copy link
Collaborator

@VasigaranAndAngel VasigaranAndAngel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid lambda as possible.
#131 (comment)

tag_widget.on_edit.connect(lambda checked=False, t=tag: self.edit_tag(t))
tag_widget.on_remove.connect(lambda t=tag: self.remove_tag(t))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use functools.partial instead of lambda.

Suggested change
tag_widget.on_remove.connect(lambda t=tag: self.remove_tag(t))
tag_widget.on_remove.connect(partial(self.remove_tag, tag))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe, the codebase uses lambda throughout when using slots. Is there a real world benefit to using a partial here (or throughout)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, partial feels comfortable for me because that makes the intent more explicit and ties directly to the idea of binding tag to self.remove_tag. however i would say it's a matter of style so i'm okay if @DandyDev01 decides to go with lambda here.

Copy link
Contributor Author

@DandyDev01 DandyDev01 Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I will just stick with the lambda, because it seems that using a partial will not guarantee a memory leak won't occur and @seakrueger didn't run into any leaks while testing #131 (comment). Also, I haven't seen partials used too much elsewhere in the code base, so for consistency and readability (most people already know lambda and might have to lookup partials) lambda make more sense for now.

Co-authored-by: VasigaranAndAngel <[email protected]>
@CyanVoxel CyanVoxel added Status: Mergeable The code is ready to be merged and removed Status: Review Needed A review of this is needed labels Nov 16, 2024
@seakrueger
Copy link
Collaborator

Two quick things, sorry. Thanks for the pull!

  1. Currently, you can remove the built-in tags via the tag panel. Doing so, causes the program to error when clicking the respective icon on a thumbnail.
  2. A pretty minor detail that probably isn't a huge deal, removing a tag doesn't refresh the tag boxes on the preview panel. Removing a tag continues to show the tag until the entry is clicked off and reselected.

@DandyDev01 DandyDev01 closed this Nov 17, 2024
@DandyDev01 DandyDev01 reopened this Nov 17, 2024
@CyanVoxel CyanVoxel added Status: Review Needed A review of this is needed and removed Status: Mergeable The code is ready to be merged labels Nov 17, 2024
Copy link
Collaborator

@seakrueger seakrueger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great, thanks!

@CyanVoxel CyanVoxel added Status: Mergeable The code is ready to be merged and removed Status: Review Needed A review of this is needed labels Nov 21, 2024
@CyanVoxel CyanVoxel removed the Status: Mergeable The code is ready to be merged label Nov 29, 2024
@CyanVoxel
Copy link
Member

Can you rebase this to main now that parent tags have been added (#596)? I wouldn't want to pull this until we can verify that it's compatible

@CyanVoxel CyanVoxel added the Status: Changes Requested Changes are quested to this label Nov 29, 2024
@CyanVoxel
Copy link
Member

Looks very good! Seems to work mostly well with the new subtag and alias implementation, however I did notice that any subtag and alias connections that reference deleted tags will stick around in the db afterwards. Should just be a straightforward addition of making sure those affected rows get purged as well. I've also got a log warning that happens that's related to this:

F:\GitHub\TagStudio/tagstudio\src\core\library\alchemy\library.py:691: SAWarning: Object of type <TagAlias> not in session, delete operation along 'Tag.aliases' will not proceed
  session.commit()
F:\GitHub\TagStudio/tagstudio\src\core\library\alchemy\library.py:691: SAWarning: Object of type <Tag> not in session, delete operation along 'Tag.subtags' won't proceed
  session.commit()

Also, I know this is a late ask so I understand if you'd rather pass on doing this, but I think a confirmation message box when deleting tags would be a much needed addition. If you'd rather not spend any more time on that, I understand and can implement one myself afterwards (or push to this PR if you're comfortable with that!)

@DandyDev01
Copy link
Contributor Author

Also, I know this is a late ask so I understand if you'd rather pass on doing this, but I think a confirmation message box when deleting tags would be a much needed addition. If you'd rather not spend any more time on that, I understand and can implement one myself afterwards (or push to this PR if you're comfortable with that!)

All good! I can add a confirmation message box.

@DandyDev01 DandyDev01 changed the title [feat] remove and create tags from tag database panel feat: remove and create tags from tag database panel Dec 13, 2024
Copy link
Member

@CyanVoxel CyanVoxel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for all of your work on this!

@CyanVoxel CyanVoxel removed the Status: Changes Requested Changes are quested to this label Dec 20, 2024
@CyanVoxel CyanVoxel merged commit fdfd649 into TagStudioDev:main Dec 20, 2024
5 checks passed
CyanVoxel added a commit that referenced this pull request Dec 31, 2024
This import was accidentally removed in #569. This commit restores the import.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium An issue that shouldn't be be saved for last TagStudio: Tags Relating to the TagStudio tag system Type: Enhancement New feature or request Type: UI/UX User interface and/or user experience
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Ability to add new tags from within tag management.
4 participants