Related Objects card rendering, omit empty #10156

Closed
opened 2025-12-29 21:27:36 +01:00 by adam · 6 comments
Owner

Originally created by @ross-cello on GitHub (Aug 29, 2024).

Originally assigned to: @alehaa on GitHub.

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.

Originally created by @ross-cello on GitHub (Aug 29, 2024). Originally assigned to: @alehaa on GitHub. ### 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](https://github.com/netbox-community/netbox/blob/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](https://github.com/user-attachments/assets/16dc7c7a-edfe-4b1c-8961-4aadc5592bc2) 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.
adam added the status: acceptedtype: featurenetboxcomplexity: low labels 2025-12-29 21:27:36 +01:00
adam closed this issue 2025-12-29 21:27:36 +01:00
Author
Owner

@arthanson commented on GitHub (Aug 29, 2024):

@ross-cello can you please add where this is occurring, perhaps with screenshots to make it clear.

@arthanson commented on GitHub (Aug 29, 2024): @ross-cello can you please add where this is occurring, perhaps with screenshots to make it clear.
Author
Owner

@ross-cello commented on GitHub (Aug 29, 2024):

@ross-cello can you please add where this is occurring, perhaps with screenshots to make it clear.

Sorry good point. I had a screenshot but forgot to include it. Have edited it in above.

Basically though, I think everywhere that the Related Objects card is rendered. I have checked through Tenant, Region, Site, VRF, ASN and a few others and observed difference we desire.

@ross-cello commented on GitHub (Aug 29, 2024): > @ross-cello can you please add where this is occurring, perhaps with screenshots to make it clear. Sorry good point. I had a screenshot but forgot to include it. Have edited it in above. Basically though, I think everywhere that the Related Objects card is rendered. I have checked through Tenant, Region, Site, VRF, ASN and a few others and observed difference we desire.
Author
Owner

@sleepinggenius2 commented on GitHub (Aug 30, 2024):

If this does get implemented, I would also propose some placeholder value for the case where there are no related objects at all, as having a card with just a header and no body would look like something is broken to me. An example would be something like what is done for tags today.

@sleepinggenius2 commented on GitHub (Aug 30, 2024): If this does get implemented, I would also propose some placeholder value for the case where there are no related objects at all, as having a card with just a header and no body would look like something is broken to me. An example would be something like what is done for tags today.
Author
Owner

@alehaa commented on GitHub (Jan 1, 2025):

I volunteer for this issue.

@alehaa commented on GitHub (Jan 1, 2025): I volunteer for this issue.
Author
Owner

@alehaa commented on GitHub (Feb 1, 2025):

@jeremystretch @arthanson can you assign this to me please?

@alehaa commented on GitHub (Feb 1, 2025): @jeremystretch @arthanson can you assign this to me please?
Author
Owner

@jeremystretch commented on GitHub (Feb 3, 2025):

@alehaa assigned to you

@jeremystretch commented on GitHub (Feb 3, 2025): @alehaa assigned to you
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10156