htmx single page application + work

This commit is contained in:
JMARyA 2024-12-05 17:03:42 +01:00
parent 7a70163e76
commit 73e019de9a
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
10 changed files with 150 additions and 58 deletions

View file

@ -1,13 +1,7 @@
<html>
<head>
<title>Neues Berichtsheft</title>
{% include 'head.html' %}
</head>
<body class="bg-gray-50 text-gray-800 font-sans min-h-screen flex flex-col items-center">
{% include 'header.html' with title="Neues Berichtsheft" %}
<main class="flex-grow w-full max-w-4xl mx-auto p-6 bg-white shadow-lg rounded-lg mt-6">
{{ title|safe }}
<div class="mb-6">
<p class="text-lg font-medium">{{ user.display_name }}</p>
<p class="text-gray-600">
@ -20,8 +14,7 @@
<form method="post" class="space-y-4">
{% load set_content %}
{% load access %}
{% load access set_content %}
{% for field in form %}
<div class="mb-4">
@ -31,13 +24,13 @@
{% if field.id_for_label == "id_department" %}
{{ field|set_content:draft.department}}
{{ field|set_content:draft.department }}
{%else%}
{% else %}
{% with content=draft.content|access:field.id_for_label %}
{{ field|set_content:content }}
{% endwith %}
{%endif%}
{% endif %}
{% if field.errors %}
<p class="text-red-500 text-sm">{{ field.errors|join:", " }}</p>
{% endif %}
@ -45,6 +38,7 @@
{% endfor %}
{% csrf_token %}
<button
type="submit"
class="w-full bg-red-600 text-white py-2 px-4 rounded-lg shadow hover:bg-red-700 focus:ring focus:ring-red-400">
@ -61,7 +55,7 @@ function updateDraft() {
var field = document.getElementById("{{ field.id_for_label }}");
formData["{{ field.id_for_label }}"] = field.value;
{% endfor%}
{% endfor %}
fetch("/draft", {
method: 'POST',
@ -127,5 +121,3 @@ setupListeners();
</script>
</main>
</body>
</html>