added new parent page + minor css/js improvements

This commit is contained in:
Louis Heredero 2025-02-02 21:48:12 +01:00
parent 6ff3f05272
commit 8b0b56cb7b
Signed by: HEL
GPG Key ID: 8D83DE470F8544E7
14 changed files with 205 additions and 29 deletions

View File

@ -29,6 +29,7 @@ urlpatterns = [
path("parents/", views.ParentsView.as_view(), name="parents"),
path("table/<date:start_date>/<date:end_date>/", 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/<int:id>/", views.parent_view, name="parent"),
path("projects/<int:id>/", views.project_view, name="project"),
path("projects/<int:id>/set_parent", views.set_parent, name="set_parent"),

View File

@ -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);
}

View File

@ -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%;

View File

@ -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;
}

View File

@ -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", () => {

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64"
height="64"
viewBox="0 0 64 64"
version="1.1"
id="svg1"
sodipodi:docname="logo.svg"
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="true"
inkscape:zoom="11.559708"
inkscape:cx="31.012894"
inkscape:cy="41.047749"
inkscape:window-width="1920"
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
id="grid1"
units="px"
originx="0"
originy="0"
spacingx="1"
spacingy="1"
empcolor="#0099e5"
empopacity="0.30196078"
color="#0099e5"
opacity="0.14901961"
empspacing="8"
enabled="true"
visible="true" />
</sodipodi:namedview>
<defs
id="defs1">
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect3"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,1,1,0,2,0,1 @ F,0,1,1,0,2,0,1 @ F,0,1,1,0,2,0,1 @ F,0,1,1,0,2,0,1 @ F,0,1,1,0,2,0,1 @ F,0,0,1,0,2,0,1 @ F,0,1,1,0,2,0,1 @ F,0,1,1,0,2,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
</defs>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g4">
<path
style="fill:#69c935;fill-opacity:1;stroke-width:6;stroke-linecap:square;stroke:none"
d="m 8,10 v 4 a 2,2 45 0 0 2,2 h 7 a 2,2 45 0 1 2,2 v 36 a 2,2 45 0 0 2,2 h 4 a 2,2 135 0 0 2,-2 V 18 a 2,2 135 0 1 2,-2 h 7 a 2,2 135 0 0 2,-2 V 10 A 2,2 45 0 0 36,8 H 10 a 2,2 135 0 0 -2,2 z"
id="path1"
sodipodi:nodetypes="ccccccccc"
inkscape:path-effect="#path-effect3"
inkscape:original-d="m 8,8 v 8 h 11 v 40 h 8 V 16 H 38 V 8 Z" />
<g
id="g3"
style="stroke:#61ba31;stroke-opacity:1;fill:none">
<path
id="path2"
style="fill:none;stroke:#61ba31;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="M 44.834929,13.274537 C 51.52452,17.296808 56,24.625752 56,33 56,45.702549 45.702549,56 33,56"
sodipodi:nodetypes="csc" />
<path
style="fill:none;stroke:#61ba31;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="M 44,47 33,33 38,26"
id="path3" />
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -1,3 +1,3 @@
.productive {
box-shadow: 0.2em 0 0 #69c935 inset;
box-shadow: 0.2em 0 0 var(--accent) inset;
}

View File

@ -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 = {

16
templates/add.html Normal file
View File

@ -0,0 +1,16 @@
{% extends "base.html" %}
{% load static %}
{% block title %}New {{ class }}{% endblock %}
{% block head %}
<link rel="stylesheet" href="{% static "form.css" %}">
{% endblock %}
{% block main %}
<div class="container">
<h2>New {{ class }}</h2>
<form action="" method="POST">
{% csrf_token %}
{{ form }}
<button type="submit">Create</button>
</form>
</div>
{% endblock %}

View File

@ -4,6 +4,7 @@
<head>
<meta charset="UTF-8">
<title>{% block title %}Title{% endblock %}</title>
<link rel="shortcut icon" href="{% static "logo.svg" %}" type="image/x-svg">
<link rel="stylesheet" href="{% static "base.css" %}">
<script src="{% static "base.js" %}"></script>
{% block head %}{% endblock %}
@ -11,6 +12,7 @@
<body>
<header>
<nav>
<a class="logo" href="{% url "dashboard" %}"><img src="{% static "logo.svg" %}" alt="Time Dispatcher logo"></a>
{% for nav_link in nav_links %}
<a href="{% url nav_link.view %}" {% if request.resolver_match.view_name == nav_link.view %}class="active"{% endif %}>{{ nav_link.label }}</a>
{% endfor %}

View File

@ -2,7 +2,7 @@
{% load static %}
{% block title %}Editing {{ class }} {{ id }}{% endblock %}
{% block head %}
<link rel="stylesheet" href="{% static "edit.css" %}">
<link rel="stylesheet" href="{% static "form.css" %}">
{% endblock %}
{% block main %}
<div class="container">

View File

@ -1,6 +1,12 @@
{% extends "base.html" %}
{% load static %}
{% block title %}Import tasks{% endblock %}
{% block head %}
<link rel="stylesheet" href="{% static "form.css" %}">
{% endblock %}
{% block main %}
<div class="container">
<h1>Import tasks</h1>
<form action="" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div>
@ -9,4 +15,5 @@
</div>
<button type="submit">Import</button>
</form>
</div>
{% endblock %}

View File

@ -2,9 +2,14 @@
{% load static %}
{% block head %}
<link rel="stylesheet" href="{% static "list.css" %}">
<script src="{% static "list.js" %}"></script>
{% block extra-head %}{% endblock %}
{% endblock %}
{% block main %}
<div class="list-wrapper">
<div class="list-header">
<button class="new">New {{ class_name }}</button>
</div>
<ul class="list">
{% for element in elements %}
<li data-id="{{ element.id }}" class="{% block extra-class %}{% endblock %}">
@ -14,7 +19,8 @@
</div>
</li>
{% empty %}
<li class="empty">No {% block element_name %}{% endblock %} defined yet</li>
<li class="empty">No {{ class_name }} defined yet</li>
{% endfor %}
</ul>
</div>
{% endblock %}

View File

@ -1,15 +1,15 @@
{% extends "list.html" %}
{% load static %}
{% block title %}Parents{% endblock %}
{% block element_name %}parent{% endblock %}
{% block extra-head %}
<link rel="stylesheet" href="{% static "parents.css" %}">
<script src="{% static "parents.js" %}"></script>
{% endblock %}
{% block extra-class %}{% if element.is_productive %}productive{% endif %}{% endblock %}
{% block element %}
<div class="name">{{ element.name }}</div>
{% if element.project_num %}
<div class="project_num">({{ element.project_num }})</div>
{% endif %}
{% endblock %}
{% block actions %}
<button class="edit">Edit</button>