diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a9af3c..1176d6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * Add helper buttons next to datime fields * Change recent session view to current year instead of last 30 days * Fix bug when filtering only manual sessions (https://git.kucharczyk.xyz/lukas/timetracker/issues/51) +* Add copy button on Add session page to copy times between fields +* Use the same form when editing a session as when adding a session ## 1.0.3 / 2023-02-20 17:16+01:00 diff --git a/games/static/js/add_session.js b/games/static/js/add_session.js index 87d86de..e190820 100644 --- a/games/static/js/add_session.js +++ b/games/static/js/add_session.js @@ -8,6 +8,9 @@ for (let button of document.querySelectorAll("[data-target]")) { event.preventDefault(); if (type == "now") { targetElement.value = toISOUTCString(new Date); + } else if (type == "copy") { + const oppositeName = targetElement.name == "timestamp_start" ? "timestamp_end" : "timestamp_start"; + document.querySelector(`[name='${oppositeName}']`).value = targetElement.value; } else if (type == "toggle") { if (targetElement.type == "datetime-local") targetElement.type = "text"; else targetElement.type = "datetime-local"; diff --git a/games/templates/add_session.html b/games/templates/add_session.html index 9352e0f..a052826 100644 --- a/games/templates/add_session.html +++ b/games/templates/add_session.html @@ -20,6 +20,7 @@
+
{% endif %} diff --git a/games/views.py b/games/views.py index c3b2a8d..29422a0 100644 --- a/games/views.py +++ b/games/views.py @@ -64,7 +64,7 @@ def edit_session(request, session_id=None): return redirect("list_sessions") context["title"] = "Edit Session" context["form"] = form - return render(request, "add.html", context) + return render(request, "add_session.html", context) def edit_purchase(request, purchase_id=None):