1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00
Files
netbox-community-netbox/netbox/netbox/tables/template_code.py
Jeremy Stretch 3d20276f55 Closes #14134: Display additional object attributes in global search results (#14154)
* WIP

* Add display_attrs for all indexers

* Linkify object attributes

* Clean up prefetch logic

* Use tooltips for display attributes

* Simplify template code

* Introduce get_indexer() utility function

* Add  to examples in docs

* Use tooltips to display long strings
2023-11-09 16:21:09 -05:00

19 lines
555 B
Python

SEARCH_RESULT_ATTRS = """
{% for name, value in record.display_attrs.items %}
<span class="badge bg-secondary"
{% if value|length > 40 %} data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{ value }}"{% endif %}
>
{{ name|bettertitle }}:
{% with url=value.get_absolute_url %}
{% if url %}<a href="url">{% endif %}
{% if value|length > 40 %}
{{ value|truncatechars:"40" }}
{% else %}
{{ value }}
{% endif %}
{% if url %}</a>{% endif %}
{% endwith %}
</span>
{% endfor %}
"""