Skip to content

Commit

Permalink
Update tooltip.py from Desktop plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed May 27, 2024
1 parent ee846af commit 0deb482
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lizmap_server/tooltip.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def remove_none(cls, data: dict) -> dict:
# Might be linked to QGIS 3.36 https://github.com/3liz/lizmap-web-client/issues/4307
return {k: v for k, v in data.items() if v is not None}

@classmethod
def friendly_name(cls, name: str, alias: str) -> str:
fname = alias if alias else name
fname = fname.replace("'", "’") # noqa RUF001
return fname

@staticmethod
def create_popup_node_item_from_form(
layer: QgsVectorLayer,
Expand Down Expand Up @@ -79,10 +85,8 @@ def create_popup_node_item_from_form(
field = layer.fields()[node.idx()]

# display field name or alias if filled
alias = field.alias()
name = field.name()
fname = alias if alias else name
fname = fname.replace("'", "’")
fname = Tooltip.friendly_name(name, field.alias())

# adapt the view depending on the field type
field_widget_setup = field.editorWidgetSetup()
Expand Down

0 comments on commit 0deb482

Please sign in to comment.