Просмотр исходного кода

Replicate 'max length' field in PrefixFilterForm for consistency

Jeremy Stretch 5 лет назад
Родитель
Сommit
0f397fa410
2 измененных файлов с 32 добавлено и 26 удалено
  1. 3 0
      netbox/ipam/forms.py
  2. 29 26
      netbox/templates/inc/search_panel.html

+ 3 - 0
netbox/ipam/forms.py

@@ -437,6 +437,9 @@ class PrefixFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldFilterForm)
         'q', 'within_include', 'family', 'mask_length', 'vrf_id', 'status', 'region', 'site', 'role', 'tenant_group',
         'q', 'within_include', 'family', 'mask_length', 'vrf_id', 'status', 'region', 'site', 'role', 'tenant_group',
         'tenant', 'is_pool', 'expand',
         'tenant', 'is_pool', 'expand',
     ]
     ]
+    mask_length__lte = forms.IntegerField(
+        widget=forms.HiddenInput()
+    )
     q = forms.CharField(
     q = forms.CharField(
         required=False,
         required=False,
         label='Search'
         label='Search'

+ 29 - 26
netbox/templates/inc/search_panel.html

@@ -7,33 +7,36 @@
     </div>
     </div>
     <div class="panel-body">
     <div class="panel-body">
         <form action="." method="get" class="form">
         <form action="." method="get" class="form">
-                {% for field in filter_form %}
-                    <div class="form-group">
-                        {% if field.name == "q" %}
-                            <div class="input-group">
-                                <input type="text" name="q" class="form-control" placeholder="Search" {% if request.GET.q %}value="{{ request.GET.q }}" {% endif %}/>
-                                <span class="input-group-btn">
-                                    <button type="submit" class="btn btn-primary">
-                                        <span class="fa fa-search" aria-hidden="true"></span>
-                                    </button>
-                                </span>
-                            </div>
-                        {% elif field|widget_type == 'checkboxinput' %}
-                            <label for="{{ field.id_for_label }}">{{ field }} {{ field.label }}</label>
-                        {% else %}
-                            {{ field.label_tag }}
-                            {{ field }}
-                        {% endif %}
-                    </div>
-                {% endfor %}
-                <div class="text-right noprint">
-                    <button type="submit" class="btn btn-primary">
-                        <span class="fa fa-search" aria-hidden="true"></span> Apply
-                    </button>
-                    <a href="." class="btn btn-default">
-                        <span class="fa fa-remove" aria-hidden="true"></span> Clear
-                    </a>
+            {% for field in filter_form.hidden_fields %}
+                {{ field }}
+            {% endfor %}
+            {% for field in filter_form.visible_fields %}
+                <div class="form-group">
+                    {% if field.name == "q" %}
+                        <div class="input-group">
+                            <input type="text" name="q" class="form-control" placeholder="Search" {% if request.GET.q %}value="{{ request.GET.q }}" {% endif %}/>
+                            <span class="input-group-btn">
+                                <button type="submit" class="btn btn-primary">
+                                    <span class="fa fa-search" aria-hidden="true"></span>
+                                </button>
+                            </span>
+                        </div>
+                    {% elif field|widget_type == 'checkboxinput' %}
+                        <label for="{{ field.id_for_label }}">{{ field }} {{ field.label }}</label>
+                    {% else %}
+                        {{ field.label_tag }}
+                        {{ field }}
+                    {% endif %}
                 </div>
                 </div>
+            {% endfor %}
+            <div class="text-right noprint">
+                <button type="submit" class="btn btn-primary">
+                    <span class="fa fa-search" aria-hidden="true"></span> Apply
+                </button>
+                <a href="." class="btn btn-default">
+                    <span class="fa fa-remove" aria-hidden="true"></span> Clear
+                </a>
+            </div>
         </form>
         </form>
     </div>
     </div>
 </div>
 </div>