diff options
author | Daniel Schadt <kingdread@gmx.de> | 2023-07-26 18:33:30 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2023-07-26 18:33:30 +0200 |
commit | ae4def114789898de2b3dc9b5f25e59942acf8ec (patch) | |
tree | 409212eab29c4a44078384387ddf24b8cb1517d2 | |
parent | 1ec44af15a0ca31f71a1ae5337de235d8ff060d8 (diff) | |
download | fietsboek-ae4def114789898de2b3dc9b5f25e59942acf8ec.tar.gz fietsboek-ae4def114789898de2b3dc9b5f25e59942acf8ec.tar.bz2 fietsboek-ae4def114789898de2b3dc9b5f25e59942acf8ec.zip |
show names of tagged people on hover
-rw-r--r-- | fietsboek/models/track.py | 10 | ||||
-rw-r--r-- | fietsboek/templates/home.jinja2 | 6 |
2 files changed, 15 insertions, 1 deletions
diff --git a/fietsboek/models/track.py b/fietsboek/models/track.py index 53961c3..8025f6a 100644 --- a/fietsboek/models/track.py +++ b/fietsboek/models/track.py @@ -607,6 +607,16 @@ class TrackWithMetadata: ] return Markup(f'<table>{"".join(rows)}</table>') + def html_tooltip_tagged_people(self) -> Markup: + """Returns the tagged people as HTML, ready to be shown as a tooltip. + + :return: The generated HTML. + """ + people = [self.owner] + list(self.tagged_people) + people.sort(key=lambda p: p.name) + html_list = "".join(Markup("<li>{}</li>").format(person.name) for person in people) + return Markup("<ul class="mb-0">{}</ul>").format(html_list) + # Proxied properties @property def id(self) -> Optional[int]: diff --git a/fietsboek/templates/home.jinja2 b/fietsboek/templates/home.jinja2 index 9835cfb..383e90a 100644 --- a/fietsboek/templates/home.jinja2 +++ b/fietsboek/templates/home.jinja2 @@ -45,7 +45,11 @@ {{ track.title | default(track.date, true) }} </a> <span class="float-end"> - {% if track.tagged_people %}{{ track.tagged_people | length + 1 }} <i class="bi bi-people-fill"></i> {% endif %} + {% if track.tagged_people %} + <span data-bs-toggle="tooltip" data-bs-container="body" data-bs-html="true" title="{{ track.html_tooltip_tagged_people() }}"> + {{ track.tagged_people | length + 1 }} <i class="bi bi-people-fill"></i> + </span> + {% endif %} {{ (track.length / 1000) | round(2) | format_decimal }} km </span> </span> |