mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-29 03:46:25 -06:00
Update table config link when updating table
This commit is contained in:
parent
475dd7247b
commit
2f425fda34
@ -1,5 +1,6 @@
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
import django_tables2 as tables
|
import django_tables2 as tables
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -191,6 +192,14 @@ class BaseTable(tables.Table):
|
|||||||
'ordering': self.order_by,
|
'ordering': self.order_by,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def config_params(self):
|
||||||
|
return urlencode({
|
||||||
|
'object_type': ObjectType.objects.get_for_model(self.Meta.model).pk,
|
||||||
|
'table': self.name,
|
||||||
|
**self.configuration,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class NetBoxTable(BaseTable):
|
class NetBoxTable(BaseTable):
|
||||||
"""
|
"""
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
{# Include the updated object count for display elsewhere on the page #}
|
{# Include the updated object count for display elsewhere on the page #}
|
||||||
<div hx-swap-oob="innerHTML:.total-object-count">{{ table.rows|length }}</div>
|
<div hx-swap-oob="innerHTML:.total-object-count">{{ table.rows|length }}</div>
|
||||||
|
|
||||||
|
{# Include the updated "save" link for the table configuration #}
|
||||||
|
<a class="dropdown-item" hx-swap-oob="outerHTML:#table_save_link" href="{% url 'extras:tableconfig_add' %}?{{ table.config_params }}&return_url={{ request.path }}" id="table_save_link">Save</a>
|
||||||
|
|
||||||
{# Update the bulk action buttons with new query parameters #}
|
{# Update the bulk action buttons with new query parameters #}
|
||||||
{% if actions %}
|
{% if actions %}
|
||||||
<div class="bulk-action-buttons" hx-swap-oob="outerHTML:.bulk-action-buttons">
|
<div class="bulk-action-buttons" hx-swap-oob="outerHTML:.bulk-action-buttons">
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
<span class="visually-hidden">Toggle Dropdown</span>
|
<span class="visually-hidden">Toggle Dropdown</span>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<a class="dropdown-item" href="{% url 'extras:tableconfig_add' %}?object_type={{ table.Meta.model|content_type_id }}&table={{ table.name }}&columns={{ table.configuration.columns }}&ordering={{ table.configuration.ordering }}">Save</a>
|
<a class="dropdown-item" href="{% url 'extras:tableconfig_add' %}?{{ table.config_params }}&return_url={{ request.path }}" id="table_save_link">Save</a>
|
||||||
{% if table_configs %}
|
{% if table_configs %}
|
||||||
<hr class="dropdown-divider">
|
<hr class="dropdown-divider">
|
||||||
{% for config in table_configs %}
|
{% for config in table_configs %}
|
||||||
|
Loading…
Reference in New Issue
Block a user