mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-12 04:00:02 +02:00
Handle panel title when object is not available
This commit is contained in:
@@ -106,9 +106,15 @@ class ObjectPanel(Panel):
|
||||
|
||||
def get_context(self, context):
|
||||
obj = resolve_attr_path(context, self.accessor)
|
||||
if self.title is not None:
|
||||
title_ = self.title
|
||||
elif obj is not None:
|
||||
title_ = title(obj._meta.verbose_name)
|
||||
else:
|
||||
title_ = None
|
||||
return {
|
||||
**super().get_context(context),
|
||||
'title': self.title or title(obj._meta.verbose_name),
|
||||
'title': title_,
|
||||
'object': obj,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
<!-- begin {{ panel_class|default:"panel" }} -->
|
||||
<div class="card">
|
||||
<h2 class="card-header">
|
||||
{{ title }}
|
||||
{% if actions %}
|
||||
<div class="card-actions">
|
||||
{% for action in actions %}
|
||||
{% render action %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</h2>
|
||||
{% if title or actions %}
|
||||
<h2 class="card-header">
|
||||
{{ title|default:"" }}
|
||||
{% if actions %}
|
||||
<div class="card-actions">
|
||||
{% for action in actions %}
|
||||
{% render action %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</h2>
|
||||
{% endif %}
|
||||
{% block panel_content %}{% endblock %}
|
||||
</div>
|
||||
<!-- end {{ panel_class|default:"panel" }} -->
|
||||
|
||||
Reference in New Issue
Block a user