Refactor base templates to ensure consistent display of header content

This commit is contained in:
Jeremy Stretch 2024-01-11 15:31:23 -05:00
parent 8eed94ccd9
commit d8a665db39
26 changed files with 130 additions and 112 deletions

View File

@ -3353,6 +3353,7 @@ class VirtualChassisEditView(ObjectPermissionRequiredMixin, GetReturnURLMixin, V
formset = VCMemberFormSet(queryset=members_queryset)
return render(request, 'dcim/virtualchassis_edit.html', {
'object': virtual_chassis,
'vc_form': vc_form,
'formset': formset,
'return_url': self.get_return_url(request, virtual_chassis),

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load i18n %}
{% block tabs %}

View File

@ -116,15 +116,15 @@ Blocks:
<div class="page-wrapper">
{# Page header #}
<div class="page-header m-0">
{% block header %}
{# Banners #}
{# Top banner #}
{% if config.BANNER_TOP %}
<div class="text-center mx-3 mb-2">
{{ config.BANNER_TOP|safe }}
</div>
{% include 'inc/banner.html' with content=config.BANNER_TOP %}
{% endif %}
{# /Top banner #}
{# Alerts #}
{% if settings.DEBUG and not settings.DEVELOPER %}
{% include 'inc/alerts/warning.html' with title="Debug mode is enabled" message="Performance may be limited. Debugging should never be enabled on a production system." %}
{% endif %}
@ -132,57 +132,31 @@ Blocks:
{% if config.MAINTENANCE_MODE and config.BANNER_MAINTENANCE %}
{% include 'inc/alerts/warning.html' with title="Maintenance Mode" message=config.BANNER_MAINTENANCE|escape %}
{% endif %}
{# /Banners #}
{# /Alerts #}
{% block header %}
<div class="container-xl mt-2 d-print-none">
<div class="row align-items-center">
{# Title #}
<div class="col">
<h2 class="page-title mb-1">{% block title %}{% endblock title %}</h2>
{% block subtitle %}{% endblock %}
</div>
{# Controls #}
<div class="col-auto d-print-none">
{% block controls %}{% endblock controls %}
</div>
</div>
</div>
{# Tabs #}
<div class="page-tabs mt-3">
{% block tabs %}{% endblock %}
</div>
{% endblock header %}
</div>
{% endblock header %}
{# /Page header #}
{# Page body #}
{% block page %}
<div class="page-body">
<div class="page-body my-1">
<div class="container-xl tab-content py-3">
{# Page content #}
{% block content %}{% endblock %}
{# /Page content #}
{# Bottom banner #}
{% if config.BANNER_BOTTOM %}
<div class="text-center mx-3 mt-2">
{{ config.BANNER_BOTTOM|safe }}
</div>
{% endif %}
{# /Bottom banner #}
</div>
</div>
{% endblock page %}
{# /Page body #}
{# Bottom banner #}
{% if config.BANNER_BOTTOM %}
{% include 'inc/banner.html' with content=config.BANNER_BOTTOM %}
{% endif %}
{# /Bottom banner #}
{# Page footer #}
<footer class="footer footer-transparent d-print-none py-2">
<div class="container-xl d-flex justify-content-between align-items-center">

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/object.html' %}
{% load helpers %}
{% load buttons %}
{% load perms %}
@ -13,20 +13,6 @@
</div>
{% endblock %}
{% block header %}
<div class="row noprint">
<div class="col col-md-12">
<nav class="breadcrumb-container px-3" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'core:configrevision_list' %}">{% trans "Config revisions" %}</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:configrevision' pk=object.pk %}">{{ object }}</a></li>
</ol>
</nav>
</div>
</div>
{{ block.super }}
{% endblock header %}
{% block controls %}
<div class="controls">
<div class="control-group">
@ -76,8 +62,8 @@
<div class="submit-row" style="margin-top: 20px">
<div class="controls">
<div class="control-group">
<button type="submit" name="restore" class="btn btn-primary">{% trans "Restore" %}</button>
<a href="{% url 'core:configrevision_list' %}" id="cancel" name="cancel" class="btn btn-outline-secondary">{% trans "Cancel" %}</a>
<button type="submit" name="restore" class="btn btn-primary">{% trans "Restore" %}</button>
</div>
</div>
</div>

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/object_edit.html' %}
{% load helpers %}
{% load form_helpers %}
{% load i18n %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load buttons %}
{% load helpers %}
{% load perms %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load buttons %}
{% load helpers %}
{% load i18n %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load helpers %}
{% load buttons %}
{% load perms %}

View File

@ -0,0 +1,32 @@
{% extends 'base/layout.html' %}
{% block header %}
<div class="page-header m-0">
{{ block.super }}
{% block page-header %}
<div class="container-xl mt-2 d-print-none">
<div class="row align-items-center">
{# Title #}
<div class="col">
<h2 class="page-title mb-1">{% block title %}{% endblock title %}</h2>
{% block subtitle %}{% endblock %}
</div>
{# Controls #}
<div class="col-auto d-print-none">
{% block controls %}{% endblock controls %}
</div>
</div>
</div>
{% endblock %}
{# Tabs #}
<div class="page-tabs mt-3">
{% block tabs %}{% endblock %}
</div>
</div>
{% endblock header %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load helpers %}
{% load form_helpers %}
{% load render_table from django_tables2 %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load helpers %}
{% load render_table from django_tables2 %}
{% load i18n %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load helpers %}
{% load form_helpers %}
{% load render_table from django_tables2 %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load helpers %}
{% load form_helpers %}
{% load i18n %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load helpers %}
{% load render_table from django_tables2 %}
{% load i18n %}
@ -7,38 +7,50 @@
{% trans "Remove" %} {{ table.rows|length }} {{ obj_type_plural|bettertitle }}?
{% endblock %}
{% block content %}
<div class="alert alert-danger bg-danger-subtle" role="alert">
<div class="d-flex">
<div>
<i class="mdi mdi-alert-octagon p-2"></i>
</div>
<div>
<h4 class="alert-title">{% trans "Confirm Bulk Removal" %}</h4>
{% blocktrans trimmed with count=table.rows|length %}
The following operation will remove {{ count }} {{ obj_type_plural }} from {{ parent_obj }}. Please
carefully review the {{ obj_type_plural }} to be removed and confirm below.
{% endblocktrans %}
</div>
</div>
</div>
<div class="container-xl px-0">
<div class="table-responsive">
{% render_table table 'inc/table.html' %}
</div>
<form action="." method="post" class="form">
{% csrf_token %}
{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}
<div class="text-end">
<a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a>
<button type="submit" name="_confirm" class="btn btn-danger">
{% blocktrans trimmed with count=table.rows|length %}
Delete these {{ count }} {{ obj_type_plural }}
{% endblocktrans %}
{% block tabs %}
<ul class="nav nav-tabs px-3">
<li class="nav-item" role="presentation">
<button class="nav-link active" type="button" role="tab" aria-controls="edit-form" aria-selected="true">
{% trans "Bulk Remove" %}
</button>
</li>
</ul>
{% endblock tabs %}
{% block content %}
<div class="tab-pane show active" role="tabpanel">
<div class="alert alert-danger bg-danger-subtle" role="alert">
<div class="d-flex">
<div>
<i class="mdi mdi-alert-octagon p-2"></i>
</div>
<div>
<h4 class="alert-title">{% trans "Confirm Bulk Removal" %}</h4>
{% blocktrans trimmed with count=table.rows|length %}
The following operation will remove {{ count }} {{ obj_type_plural }} from {{ parent_obj }}. Please
carefully review the {{ obj_type_plural }} to be removed and confirm below.
{% endblocktrans %}
</div>
</div>
</div>
</form>
</div>
<div class="container-xl px-0">
<div class="table-responsive">
{% render_table table 'inc/table.html' %}
</div>
<form action="." method="post" class="form">
{% csrf_token %}
{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}
<div class="text-end">
<a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a>
<button type="submit" name="_confirm" class="btn btn-danger">
{% blocktrans trimmed with count=table.rows|length %}
Remove these {{ count }} {{ obj_type_plural }}
{% endblocktrans %}
</button>
</div>
</form>
</div>
</div>
{% endblock content %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load helpers %}
{% load form_helpers %}
{% load i18n %}
@ -7,6 +7,16 @@
{% trans "Renaming" %} {{ selected_objects|length }} {{ obj_type_plural|bettertitle }}
{% endblock %}
{% block tabs %}
<ul class="nav nav-tabs px-3">
<li class="nav-item" role="presentation">
<button class="nav-link active" type="button" role="tab" aria-controls="edit-form" aria-selected="true">
{% trans "Bulk Rename" %}
</button>
</li>
</ul>
{% endblock tabs %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-7">

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load form_helpers %}
{% load i18n %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load buttons %}
{% load custom_links %}
{% load helpers %}
@ -18,7 +18,7 @@ Context:
object: The object instance being viewed
{% endcomment %}
{% block header %}
{% block page-header %}
<div class="d-flex justify-content-between align-items-center mx-3 my-2">
{# Breadcrumbs #}
@ -40,7 +40,7 @@ Context:
</div>
{{ block.super }}
{% endblock header %}
{% endblock page-header %}
{% block title %}{{ object }}{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load helpers %}
{% load form_helpers %}
{% load i18n %}
@ -15,8 +15,6 @@ Context:
{% trans "Delete" %} {{ object|meta:"verbose_name" }}?
{% endblock %}
{% block header %}{% endblock %}
{% block content %}
<div class="modal" tabindex="-1" style="display: block; position: static">
<div class="modal-dialog">

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load i18n %}
{% comment %}

View File

@ -1,4 +1,4 @@
{% extends 'base/layout.html' %}
{% extends 'generic/_base.html' %}
{% load buttons %}
{% load helpers %}
{% load plugins %}

View File

@ -4,6 +4,7 @@
{% load i18n %}
{% block header %}
{{ block.super }}
{% if new_release %}
<div class="alert alert-info bg-info-subtle mx-3" role="alert">
<div class="d-flex">

View File

@ -1,6 +1,6 @@
{% load i18n %}
<div class="alert alert-danger bg-danger-subtle mx-3" role="alert">
<div class="alert alert-danger bg-danger-subtle mx-3 my-2" role="alert">
<div class="d-flex">
<div>
<i class="mdi mdi-alert-octagon p-2"></i>

View File

@ -1,6 +1,6 @@
{% load i18n %}
<div class="alert alert-info bg-info-subtle mx-3" role="alert">
<div class="alert alert-info bg-info-subtle mx-3 my-2" role="alert">
<div class="d-flex">
<div>
<i class="mdi mdi-information-outline p-2"></i>

View File

@ -1,6 +1,6 @@
{% load i18n %}
<div class="alert alert-success bg-success-subtle mx-3" role="alert">
<div class="alert alert-success bg-success-subtle mx-3 my-2" role="alert">
<div class="d-flex">
<div>
<i class="mdi mdi-check-bold p-2"></i>

View File

@ -1,6 +1,6 @@
{% load i18n %}
<div class="alert alert-warning bg-warning-subtle mx-3" role="alert">
<div class="alert alert-warning bg-warning-subtle mx-3 my-2" role="alert">
<div class="d-flex">
<div>
<i class="mdi mdi-alert p-2"></i>

View File

@ -0,0 +1,4 @@
{# Display top or bottom banner content #}
<div class="text-center mx-3 m-2">
{{ content|safe }}
</div>