1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Enable the use of fieldsets on bulk edit forms

This commit is contained in:
jeremystretch
2022-02-04 09:59:53 -05:00
parent ac1c0b0715
commit 60e87cd496
9 changed files with 273 additions and 13 deletions

View File

@@ -3,7 +3,7 @@
{% load form_helpers %}
{% load render_table from django_tables2 %}
{% block title %}Editing {{ table.rows|length }} {{ obj_type_plural|bettertitle }}{% endblock %}
{% block title %}Editing {{ table.rows|length }} {{ model|meta:"verbose_name_plural" }}{% endblock %}
{% block tabs %}
<ul class="nav nav-tabs px-3">
@@ -41,13 +41,71 @@
<div class="col col-md-12 col-lg-10 offset-lg-1">
<div class="card">
<div class="card-body">
{% for field in form.visible_fields %}
{% if field.name in form.nullable_fields %}
{% render_field field bulk_nullable=True %}
{% else %}
{% render_field field %}
{% if form.fieldsets %}
{# Render grouped fields according to declared fieldsets #}
{% for group, fields in form.fieldsets %}
<div class="field-group mb-5">
<div class="row mb-2">
<h5 class="offset-sm-3">
{% if group %}{{ group }}{% else %}{{ model|meta:"verbose_name" }}{% endif %}
</h5>
</div>
{% for name in fields %}
{% with field=form|getfield:name %}
{% if field.name in form.nullable_fields %}
{% render_field field bulk_nullable=True %}
{% else %}
{% render_field field %}
{% endif %}
{% endwith %}
{% endfor %}
</div>
{% endfor %}
{# Render tag add/remove fields #}
{% if form.add_tags and form.remove_tags %}
<div class="field-group mb-5">
<div class="row mb-2">
<h5 class="offset-sm-3">Tags</h5>
</div>
{% render_field form.add_tags %}
{% render_field form.remove_tags %}
</div>
{% endif %}
{% endfor %}
{# Render custom fields #}
{% if form.custom_fields %}
<div class="field-group mb-5">
<div class="row mb-2">
<h5 class="offset-sm-3">Custom Fields</h5>
</div>
{% render_custom_fields form %}
</div>
{% endif %}
{# Render comments #}
{% if form.comments %}
<div class="field-group mb-5">
<div class="row mb-2">
<h5 class="offset-sm-3">Comments</h5>
</div>
{% render_field form.comments bulk_nullable=True %}
</div>
{% endif %}
{% else %}
{# Render all fields #}
{% for field in form.visible_fields %}
{% if field.name in form.nullable_fields %}
{% render_field field bulk_nullable=True %}
{% else %}
{% render_field field %}
{% endif %}
{% endfor %}
{% endif %}
</div>
</div>