From 05e436fc9c76aae4dd5364913768e59285d0d439 Mon Sep 17 00:00:00 2001 From: Alexander Watzinger Date: Fri, 6 Dec 2024 14:30:52 +0100 Subject: [PATCH 1/3] Tooltips for source tabs (#2390) --- openatlas/display/display.py | 13 +++++++++---- openatlas/display/tab.py | 6 ++++-- openatlas/templates/tabs.html | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/openatlas/display/display.py b/openatlas/display/display.py index dd0753dad..53d14e3a6 100644 --- a/openatlas/display/display.py +++ b/openatlas/display/display.py @@ -297,10 +297,15 @@ def add_data(self) -> None: def add_tabs(self) -> None: super().add_tabs() entity = self.entity - for name in [ - 'actor', 'artifact', 'event', 'place', 'text', 'reference', - 'file']: - self.tabs[name] = Tab(name, entity=entity) + for name, tooltip in { + 'actor': _('mentioned in the source'), + 'artifact': _('mentioned in the source'), + 'event': _('mentioned in the source'), + 'place': _('mentioned in the source'), + 'text': _('mentioned in the source'), + 'reference': '', + 'file': ''}.items(): + self.tabs[name] = Tab(name, entity=entity, tooltip=tooltip) for text in entity.get_linked_entities('P73', types=True): self.tabs['text'].table.rows.append([ link(text), diff --git a/openatlas/display/tab.py b/openatlas/display/tab.py index ce5ffa55f..2b533841a 100644 --- a/openatlas/display/tab.py +++ b/openatlas/display/tab.py @@ -9,7 +9,7 @@ from openatlas.display.table import Table from openatlas.display.util import ( button, check_iiif_activation, check_iiif_file_exist) -from openatlas.display.util2 import is_authorized, manual +from openatlas.display.util2 import is_authorized, manual, uc_first if TYPE_CHECKING: # pragma: no cover from openatlas.models.entity import Entity @@ -44,7 +44,8 @@ def __init__( table: Optional[Table] = None, buttons: Optional[list[str]] = None, entity: Optional[Entity] = None, - form: Optional[FlaskForm] = None) -> None: + form: Optional[FlaskForm] = None, + tooltip: Optional[str] = None) -> None: self.name = name self.content = content @@ -53,6 +54,7 @@ def __init__( self.table = table or Table() self.set_table_headers(name, entity) self.buttons: list[str] = buttons or [manual(f'entity/{name}')] + self.tooltip = uc_first(tooltip) if tooltip else '' if is_authorized('contributor'): self.set_buttons(name, entity) diff --git a/openatlas/templates/tabs.html b/openatlas/templates/tabs.html index af5b449dd..337f01e3f 100644 --- a/openatlas/templates/tabs.html +++ b/openatlas/templates/tabs.html @@ -7,7 +7,9 @@