Skip to content

Related Objects card rendering, omit empty #17309

@ross-cello

Description

@ross-cello

NetBox version

v3.7.8

Feature type

Change to existing functionality

Proposed functionality

Proposing a change in behaviour (toggleable or otherwise) that omits rendering Related Objects where said object relations don't exist.

I have naively achieved this (superficially?) with modification to /netbox/templates/inc/panels/related_objects.html
Bearing in mind that this was an educated guess at best and not necessarily considering efficient implementation, wider compatibility or design intent.

Note this code is from v3.7.8. However the behaviour looks to be unchanged on 4.0 and 4.1beta when looking at the demo instances and code.
Have also chased some of discussions/issues/pulls related to these changes in behaviour to gain insights.
e.g. #14510

From v3.7.8 netbox/templates/inc/panels/related_objects.html

{% load helpers %}
... <brevity omit>
    {% for qs, filter_param in related_models %}
      {% if qs %} <-------------------- insertion
      {% with viewname=qs.model|viewname:"list" %}
        <a href="{% url viewname %}?{{ filter_param }}={{ object.pk }}" class="list-group-item list-group-item-action d-flex justify-content-between">
          {{ qs.model|meta:"verbose_name_plural"|bettertitle }}
          {% with count=qs.count %}
...<brevity omit>
          {% endwith %}
        </a>
      {% endwith %}
      {% endif %} <-------------------- insertion
    {% endfor %}
...<brevity omit>

EDIT: removed some snippet code I had snuck in from #16825 while testing.

Outcome on viewing an arbitrary Tenant:
netbox_related_objects

If I have a case and am barking up the right tree, then can attempt contribution.

Use case

Reduction of scroll fatigue in page views. We only recently shifted from v3.6.9 -> v3.7.8 and had a lot of feedback internally about the change in behaviour. Our user base aren't necessarily highly technical.

Database changes

Highly unlikely.

External dependencies

Highly unlikely.

Metadata

Metadata

Assignees

Labels

complexity: lowRequires minimal effort to implementnetboxstatus: acceptedThis issue has been accepted for implementationtype: featureIntroduction of new functionality to the application

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions