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

fix: subtags/parent tags & aliases update the UI for building a tag #534

Merged
merged 26 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1b12482
updated parents and aliases to use the flowLaout in the build tag panel
DandyDev01 Oct 12, 2024
299e92b
added aliases and subtags to search results
DandyDev01 Nov 13, 2024
50ae2a8
aliases now use a table, removed unnecessary keyboard shortcuts
DandyDev01 Nov 14, 2024
1435238
reverted subtags to regular list from flowlayout
DandyDev01 Nov 14, 2024
4f4ffc8
Merge pull request #16 from DandyDev01/aliases_table
DandyDev01 Nov 14, 2024
7e8c33d
chor remove redundant lambda
DandyDev01 Nov 19, 2024
8df955a
feat: added display names for tags
DandyDev01 Nov 19, 2024
e929712
Merge pull request #17 from DandyDev01/aliases_table
DandyDev01 Nov 19, 2024
d591050
fix: aliases table enter/return and backspace work as expected, displ…
DandyDev01 Nov 29, 2024
d9186f0
Merge branch 'main' into merge
DandyDev01 Nov 30, 2024
d6ab610
fix: can not remove the bottom alias with backspace and removing the …
DandyDev01 Nov 30, 2024
3e9b5fe
format
DandyDev01 Nov 30, 2024
08ecb34
Merge pull request #19 from DandyDev01/aliases_ui
DandyDev01 Nov 30, 2024
9484d28
fix: add parent button on build tag panel
DandyDev01 Nov 30, 2024
3d3347e
fix: empty aliases where not being removed all the time
DandyDev01 Nov 30, 2024
bb39a3f
fix: alias name changes would be discarded when a new alias was creat…
DandyDev01 Nov 30, 2024
979c6f3
merge with upstream/main
DandyDev01 Dec 1, 2024
38b0e5d
fix: removed display names, as they didn't display properly and shoul…
DandyDev01 Dec 13, 2024
fac0c8d
fix: mypy
DandyDev01 Dec 13, 2024
e046681
Merge remote-tracking branch 'upstream/main'
DandyDev01 Dec 15, 2024
0f7ba0c
fix: added missing session.expunge_all
DandyDev01 Dec 22, 2024
3b0a423
fix: parent_tags relationship in Tag class
DandyDev01 Dec 22, 2024
e877eba
fix: pillow_jxl import was missing
DandyDev01 Dec 22, 2024
e317509
fix: ruff
DandyDev01 Dec 23, 2024
1be7e49
fix: type hint fixes
CyanVoxel Dec 23, 2024
715d10e
fix: fix the type hint fixes
CyanVoxel Dec 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tagstudio/src/core/library/alchemy/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,6 @@ def search_tags(
results=len(res),
)

session.expunge_all()
Copy link
Member

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?

return res

def get_all_child_tag_ids(self, tag_id: int) -> list[int]:
Expand Down
29 changes: 24 additions & 5 deletions tagstudio/src/core/library/alchemy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class Tag(Base):

aliases: Mapped[set[TagAlias]] = relationship(back_populates="tag")

parent_tags: Mapped[set["Tag"]] = relationship(
parent_tags: Mapped[list["Tag"]] = relationship(
secondary=TagSubtag.__tablename__,
primaryjoin="Tag.id == TagSubtag.child_id",
secondaryjoin="Tag.id == TagSubtag.parent_id",
primaryjoin="Tag.id == TagSubtag.parent_id",
secondaryjoin="Tag.id == TagSubtag.child_id",
Copy link
Member

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?

back_populates="subtags",
)

Expand All @@ -76,20 +76,39 @@ def alias_strings(self) -> list[str]:
def alias_ids(self) -> list[int]:
return [tag.id for tag in self.aliases]

@property
def display_name(self) -> str:
if len(self.parent_tags) == 0:
return ""

parent_tag = list(self.parent_tags)[0]

if parent_tag is None:
return ""

display_name = ""

if parent_tag.shorthand.strip() == "" or parent_tag.shorthand is None:
display_name = " (" + parent_tag.name + ")"
else:
display_name = " (" + parent_tag.shorthand + ")"

return self.name + display_name

def __init__(
self,
id: int | None = None,
name: str | None = None,
shorthand: str | None = None,
aliases: set[TagAlias] | None = None,
parent_tags: set["Tag"] | None = None,
parent_tags: list["Tag"] | None = None,
subtags: set["Tag"] | None = None,
icon: str | None = None,
color: TagColor = TagColor.DEFAULT,
):
self.name = name
self.aliases = aliases or set()
self.parent_tags = parent_tags or set()
self.parent_tags = parent_tags or list()
self.subtags = subtags or set()
self.color = color
self.icon = icon
Expand Down
Loading