1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00
Jeremy Stretch 744be59a4d Closes #14736: Enable HTMX navigation globally (#15158)
* Enable HTMX boosting

* Refactor HTMX properties for tables

* Fix dashboard object list widget

* Disable scrolling to page content

* Fix initialization of TomSelect dropdowns after HTMX loading

* Replace formaction properties with hx-post

* Fix quick search field on object list view

* Reinitialize copy-to-clipboard buttons upon HTMX load

* Disable scrolling effect for intra-page navigation

* Introduce user preference for toggling HTMX navigation

* Enable HTMX navigation only when selected by user

* Pass htmx_navigation context

* Fix display of confirmation form when deleting an object

* Disable HTMX boosting for rack elevation SVG downloads

* Fix dyanmic form rendering

* Introduce htmx_boost template tag; enable HTMX for user menu

* Use out-of-band sap to update footer stamp

* Fix display of toasts after form submission

* Fix user preference selection

* Misc cleanup

* Rename render_partial() to htmx_partial()

* Add docstring to htmx_boost template tag

* Disable HTMX for user preferences form to force a full page refresh on changes
2024-03-28 11:51:38 -04:00

91 lines
2.9 KiB
HTML

{% extends 'generic/_base.html' %}
{% load i18n %}
{% comment %}
Blocks:
form: Content within the <form> element
buttons: Form submission buttons
Context:
object: Python instance of the object being edited
form: The edit form
return_url: The URL to which the user is redirected after submitting the form
{% endcomment %}
{% block title %}
{% if object.pk %}
{% trans "Editing" %} {{ object|meta:"verbose_name" }} {{ object }}
{% else %}
{% blocktrans trimmed with object_type=object|meta:"verbose_name" %}
Add a new {{ object_type }}
{% endblocktrans %}
{% endif %}
{% endblock title %}
{% block controls %}
<div class="btn-list">
{# Link to model documentation #}
{% if settings.DOCS_ROOT and object.docs_url %}
<a href="{{ object.docs_url }}" target="_blank" class="btn btn-outline-secondary" title="{% trans "View model documentation" %}">
<i class="mdi mdi-help-circle"></i> {% trans "Help" %}
</a>
{% endif %}
</div>
{% endblock controls %}
{% block tabs %}
<ul class="nav nav-tabs">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="edit-form-tab" data-bs-toggle="tab" data-bs-target="#edit-form" type="button" role="tab" aria-controls="edit-form" aria-selected="true">
{% if object.pk %}{% trans "Edit" %}{% else %}{% trans "Create" %}{% endif %}
</button>
</li>
</ul>
{% endblock tabs %}
{% block content %}
<div class="tab-pane show active" id="edit-form" role="tabpanel" aria-labelledby="object-list-tab">
{# Warn about missing prerequisite objects #}
{% if prerequisite_model %}
{% include 'inc/missing_prerequisites.html' %}
{% endif %}
<form action="" method="post" enctype="multipart/form-data" class="object-edit mt-5">
{% csrf_token %}
<div id="form_fields" hx-disinherit="hx-select hx-swap">
{% block form %}
{% include 'htmx/form.html' %}
{% endblock form %}
</div>
<div class="text-end my-3">
{% block buttons %}
<a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a>
{% if object.pk %}
<button type="submit" name="_update" class="btn btn-primary">
{% trans "Save" %}
</button>
{% else %}
<div class="btn-group" role="group" aria-label="{% trans "Actions" %}">
<button type="submit" name="_create" class="btn btn-primary">
{% trans "Create" %}
</button>
<button type="submit" name="_addanother" class="btn btn-outline-primary">
{% trans "Create & Add Another" %}
</button>
</div>
{% endif %}
{% endblock buttons %}
</div>
</form>
</div>
{% endblock content %}
{% block modals %}
{% include 'inc/htmx_modal.html' with size='lg' %}
{% endblock %}