Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds autosave htmx functionality to Visit update/create form #76

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion project/npda/templates/npda/visit_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<div class="bg-rcpch_light_blue py-8">
<div class="w-full max-w-3xl mx-auto px-2 py-4 m-2 shadow-md bg-white font-montserrat">
<strong>{{title}}</strong>
<form id="update-form" method="post" {% if form_method == "create" %} action="{% url 'visit-create' patient_id %}" {% else %} action="{% url 'visit-update' patient_id=patient_id pk=visit.pk %}" {% endif %}>
<form id="update-form" method="post" {% if form_method == "create" %} hx-post="{% url 'visit-create' patient_id %}" action="{% url 'visit-create' patient_id %}" {% else %} hx-post="{% url 'visit-update' patient_id=patient_id pk=visit.pk %}" action="{% url 'visit-update' patient_id=patient_id pk=visit.pk %}" {% endif %} hx-trigger="change delay:500ms" hx-target="#response"
hx-swap="none">
{% csrf_token %}
{% for field in form %}
{% if field.field.category is None %}
Expand Down Expand Up @@ -164,6 +165,7 @@
{% endif %}
</div>
</form>
<div id="response"></div>
</div>
</div>
{% endblock %}
2 changes: 2 additions & 0 deletions project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_htmx",
# "django.forms",
"rest_framework",
"drf_spectacular",
Expand All @@ -103,6 +104,7 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django_htmx.middleware.HtmxMiddleware",
# 2 factor authentication
"django_otp.middleware.OTPMiddleware",
]
Expand Down