mirror of
https://github.com/netbox-community/netbox.git
synced 2026-02-06 07:16:25 -06:00
Remove HTMX navigation
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
{% load i18n %}
|
||||
{% load navigation %}
|
||||
|
||||
<ul class="navbar-nav pt-lg-2" {% htmx_boost %}>
|
||||
<ul class="navbar-nav pt-lg-2">
|
||||
<li class="nav-item d-block d-lg-none">
|
||||
<form action="{% url 'search' %}" method="get" autocomplete="off" novalidate>
|
||||
<div class="input-group mb-1 mt-2">
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from django import template
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from extras.choices import CustomFieldTypeChoices
|
||||
from utilities.querydict import dict_to_querydict
|
||||
@@ -121,9 +120,7 @@ def htmx_table(context, viewname, return_url=None, **kwargs):
|
||||
@register.simple_tag(takes_context=True)
|
||||
def formaction(context):
|
||||
"""
|
||||
Replace the 'formaction' attribute on an HTML element with the appropriate HTMX attributes
|
||||
if HTMX navigation is enabled (per the user's preferences).
|
||||
A hook for overriding the 'formaction' attribute on an HTML element, for example to replace
|
||||
with 'hx-push-url="true" hx-post' for HTMX navigation.
|
||||
"""
|
||||
if context.get('htmx_navigation', False):
|
||||
return mark_safe('hx-push-url="true" hx-post')
|
||||
return 'formaction'
|
||||
|
||||
@@ -226,7 +226,6 @@ def bulk_edit_button(context, model, action='bulk_edit', query_params=None):
|
||||
return {
|
||||
'label': _('Edit Selected'),
|
||||
'url': url,
|
||||
'htmx_navigation': context.get('htmx_navigation'),
|
||||
}
|
||||
|
||||
|
||||
@@ -243,5 +242,4 @@ def bulk_delete_button(context, model, action='bulk_delete', query_params=None):
|
||||
return {
|
||||
'label': _('Delete Selected'),
|
||||
'url': url,
|
||||
'htmx_navigation': context.get('htmx_navigation'),
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
from django import template
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from netbox.navigation.menu import MENUS
|
||||
|
||||
__all__ = (
|
||||
'nav',
|
||||
'htmx_boost',
|
||||
)
|
||||
|
||||
|
||||
@@ -43,30 +41,4 @@ def nav(context):
|
||||
|
||||
return {
|
||||
'nav_items': nav_items,
|
||||
'htmx_navigation': context['htmx_navigation']
|
||||
}
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def htmx_boost(context, target='#page-content', select='#page-content'):
|
||||
"""
|
||||
Renders the HTML attributes needed to effect HTMX boosting within an element if
|
||||
HTMX navigation is enabled for the request. The target and select parameters are
|
||||
rendered as `hx-target` and `hx-select`, respectively. For example:
|
||||
|
||||
<div id="page-content" {% htmx_boost %}>
|
||||
|
||||
If HTMX navigation is not enabled, the tag renders no content.
|
||||
"""
|
||||
if not context.get('htmx_navigation', False):
|
||||
return ''
|
||||
hx_params = {
|
||||
'hx-boost': 'true',
|
||||
'hx-target': target,
|
||||
'hx-select': select,
|
||||
'hx-swap': 'outerHTML show:window:top',
|
||||
}
|
||||
htmx_params = ' '.join([
|
||||
f'{k}="{v}"' for k, v in hx_params.items()
|
||||
])
|
||||
return mark_safe(htmx_params)
|
||||
|
||||
Reference in New Issue
Block a user