From 8b0b56cb7b59a6250a21ba504e1818cc1528fc2e Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Sun, 2 Feb 2025 21:48:12 +0100 Subject: [PATCH] added new parent page + minor css/js improvements --- TimeDispatcher/urls.py | 1 + dispatcher/static/base.css | 14 +++- dispatcher/static/{edit.css => form.css} | 2 +- dispatcher/static/list.css | 20 ++++- dispatcher/static/{parents.js => list.js} | 4 + dispatcher/static/logo.svg | 99 +++++++++++++++++++++++ dispatcher/static/parents.css | 2 +- dispatcher/views.py | 13 +++ templates/add.html | 16 ++++ templates/base.html | 2 + templates/edit.html | 2 +- templates/import.html | 23 ++++-- templates/list.html | 30 ++++--- templates/parents.html | 6 +- 14 files changed, 205 insertions(+), 29 deletions(-) rename dispatcher/static/{edit.css => form.css} (95%) rename dispatcher/static/{parents.js => list.js} (69%) create mode 100644 dispatcher/static/logo.svg create mode 100644 templates/add.html diff --git a/TimeDispatcher/urls.py b/TimeDispatcher/urls.py index ec053e3..859bfad 100644 --- a/TimeDispatcher/urls.py +++ b/TimeDispatcher/urls.py @@ -29,6 +29,7 @@ urlpatterns = [ path("parents/", views.ParentsView.as_view(), name="parents"), path("table///", views.get_table_data, name="table_data"), path("table/", views.table_view, name="table"), + path("parents/new/", views.new_parent_view, name="new_parent"), path("parents//", views.parent_view, name="parent"), path("projects//", views.project_view, name="project"), path("projects//set_parent", views.set_parent, name="set_parent"), diff --git a/dispatcher/static/base.css b/dispatcher/static/base.css index a2df91e..9ff71dd 100644 --- a/dispatcher/static/base.css +++ b/dispatcher/static/base.css @@ -7,6 +7,8 @@ --light2: #e5e5e5; --light3: #cccccc; --light4: #c5c5c5; + --accent: #69c935; + --accent2: #61ba31; } * { @@ -43,6 +45,16 @@ nav a { transition: background-color 0.2s; } +nav a.logo { + padding-top: 0; + padding-bottom: 0; +} +nav a.logo img { + object-fit: contain; + height: 2em; + width: 2em; +} + nav a.active { box-shadow: 0 -2px var(--light1) inset; } @@ -95,5 +107,5 @@ button, select { } a { - color: #69c935 + color: var(--accent); } \ No newline at end of file diff --git a/dispatcher/static/edit.css b/dispatcher/static/form.css similarity index 95% rename from dispatcher/static/edit.css rename to dispatcher/static/form.css index 900767e..a5e5080 100644 --- a/dispatcher/static/edit.css +++ b/dispatcher/static/form.css @@ -42,7 +42,7 @@ form input[type="checkbox"] { form input[type="checkbox"]:checked::after { content: ""; - background-color: #69c935; + background-color: var(--accent); width: 80%; height: 80%; border-radius: 10%; diff --git a/dispatcher/static/list.css b/dispatcher/static/list.css index c9ae09d..c2ab8fc 100644 --- a/dispatcher/static/list.css +++ b/dispatcher/static/list.css @@ -1,8 +1,24 @@ -.list { - display: flex; +.list-wrapper { width: 100%; max-width: 40em; align-self: center; + display: flex; + flex-direction: column; + gap: 1em; +} + +.list-header { + display: flex; + justify-content: flex-end; + gap: 1em; +} + +.list-header button { + padding: 0.4em 1.2em; +} + +.list { + display: flex; gap: 0.8em; flex-direction: column; } diff --git a/dispatcher/static/parents.js b/dispatcher/static/list.js similarity index 69% rename from dispatcher/static/parents.js rename to dispatcher/static/list.js index 652239a..b138911 100644 --- a/dispatcher/static/parents.js +++ b/dispatcher/static/list.js @@ -1,4 +1,8 @@ window.addEventListener("load", () => { + document.querySelector("button.new").addEventListener("click", () => { + window.location.href = "new/" + }) + document.querySelectorAll(".list li").forEach(row => { let id = row.dataset.id row.querySelector("button.edit").addEventListener("click", () => { diff --git a/dispatcher/static/logo.svg b/dispatcher/static/logo.svg new file mode 100644 index 0000000..0b1c36e --- /dev/null +++ b/dispatcher/static/logo.svg @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/dispatcher/static/parents.css b/dispatcher/static/parents.css index 8e91c8e..14f456d 100644 --- a/dispatcher/static/parents.css +++ b/dispatcher/static/parents.css @@ -1,3 +1,3 @@ .productive { - box-shadow: 0.2em 0 0 #69c935 inset; + box-shadow: 0.2em 0 0 var(--accent) inset; } \ No newline at end of file diff --git a/dispatcher/views.py b/dispatcher/views.py index d2bf874..e72d536 100644 --- a/dispatcher/views.py +++ b/dispatcher/views.py @@ -23,6 +23,7 @@ def dashboard_view(request): def projects_view(request): context = { + "class_name": "parent", "projects": Project.objects.all(), "parents": Parent.objects.all() } @@ -38,9 +39,21 @@ def parent_view(request, id): form = ParentForm(request.POST or None, request.FILES or None, instance=parent) if form.is_valid(): form.save() + return redirect("parents") context["form"] = ParentForm(instance=parent) return render(request, "edit.html", context) +def new_parent_view(request): + context = { + "class": "parent" + } + form = ParentForm(request.POST or None, request.FILES or None) + if form.is_valid(): + form.save() + return redirect("parents") + context["form"] = form + return render(request, "add.html", context) + def project_view(request, id): project = get_object_or_404(Project, id=id) context = { diff --git a/templates/add.html b/templates/add.html new file mode 100644 index 0000000..c0c2440 --- /dev/null +++ b/templates/add.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} +{% load static %} +{% block title %}New {{ class }}{% endblock %} +{% block head %} + +{% endblock %} +{% block main %} +
+

New {{ class }}

+
+ {% csrf_token %} + {{ form }} + +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 792b945..4ed7f19 100644 --- a/templates/base.html +++ b/templates/base.html @@ -4,6 +4,7 @@ {% block title %}Title{% endblock %} + {% block head %}{% endblock %} @@ -11,6 +12,7 @@