Explorar el Código

Merge pull request #21588 from netbox-community/19867-preserve-per_page-param

Fixes #19867: Retain the `per_page` URL parameter after editing an object
bctiemann hace 23 horas
padre
commit
e6db3f75ea
Se han modificado 2 ficheros con 6 adiciones y 1 borrados
  1. 1 1
      netbox/templates/generic/object_list.html
  2. 5 0
      netbox/templates/htmx/table.html

+ 1 - 1
netbox/templates/generic/object_list.html

@@ -92,7 +92,7 @@ Context:
 
         <div class="form form-horizontal">
           {% csrf_token %}
-          <input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
+          <input type="hidden" id="object-list-return-url" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
 
           {# Warn of any missing prerequisite objects #}
           {% if prerequisite_model %}

+ 5 - 0
netbox/templates/htmx/table.html

@@ -32,4 +32,9 @@
       {% action_buttons actions model multi=True %}
     </div>
   {% endif %}
+
+  {# Update the return_url to reflect any changed query parameters (e.g. per_page) #}
+  {% if not table.embedded %}
+    <input type="hidden" id="object-list-return-url" name="return_url" value="{{ request.get_full_path }}" hx-swap-oob="outerHTML:#object-list-return-url" />
+  {% endif %}
 {% endif %}