improve boathouse functionality, fixes #261 #281

Merged
philipp merged 1 commits from staging into main 2024-03-20 13:59:32 +01:00
2 changed files with 30 additions and 14 deletions
Showing only changes of commit 68a1153885 - Show all commits

View File

@ -146,7 +146,7 @@ CREATE TABLE IF NOT EXISTS "boathouse" (
"boat_id" INTEGER NOT NULL REFERENCES boat(id), "boat_id" INTEGER NOT NULL REFERENCES boat(id),
"aisle" TEXT NOT NULL CHECK (aisle in ('water', 'middle', 'mountain')), "aisle" TEXT NOT NULL CHECK (aisle in ('water', 'middle', 'mountain')),
"side" TEXT NOT NULL CHECK(side IN ('mountain', 'water')), "side" TEXT NOT NULL CHECK(side IN ('mountain', 'water')),
"level" INTEGER NOT NULL CHECK(level BETWEEN 0 AND 3), "level" INTEGER NOT NULL CHECK(level BETWEEN 0 AND 11),
CONSTRAINT unq UNIQUE (aisle, side, level) -- only 1 boat allowed to rest at each space CONSTRAINT unq UNIQUE (aisle, side, level) -- only 1 boat allowed to rest at each space
); );

View File

@ -10,6 +10,7 @@
{{ place[level].1.name }} <a class="btn btn-primary absolute end-0" {{ place[level].1.name }} <a class="btn btn-primary absolute end-0"
href="/board/boathouse/{{ place[level].0 }}/delete">X</a> href="/board/boathouse/{{ place[level].0 }}/delete">X</a>
{% elif boats | length > 0 %} {% elif boats | length > 0 %}
{% if "admin" in loggedin_user.roles %}
<details> <details>
<summary>Kein Boot</summary> <summary>Kein Boot</summary>
<form action="/board/boathouse" method="post" class="grid gap-3"> <form action="/board/boathouse" method="post" class="grid gap-3">
@ -25,6 +26,9 @@
{% else %} {% else %}
Kein Boot Kein Boot
{% endif %} {% endif %}
{% else %}
Kein Boot
{% endif %}
</li> </li>
{% endmacro show_place %} {% endmacro show_place %}
{% macro show_side(aisle_name, side_name) %} {% macro show_side(aisle_name, side_name) %}
@ -35,7 +39,9 @@
{{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 2) }} {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 2) }}
{{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 3) }} {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 3) }}
{{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 4) }} {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 4) }}
{% if aisle_name != 'water' or side_name != 'water' %}
{{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 5) }} {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 5) }}
{% endif %}
{% set show_additional = false %} {% set show_additional = false %}
{% if aisle_name == "mountain" %} {% if aisle_name == "mountain" %}
{% set show_additional = true %} {% set show_additional = true %}
@ -57,6 +63,16 @@
{% macro show_aisle(name, last=false) %} {% macro show_aisle(name, last=false) %}
<div id="{{ name }}-aisle" <div id="{{ name }}-aisle"
class="grid grid-cols-2 gap-4 {% if not last %}md:border-r{% endif %}"> class="grid grid-cols-2 gap-4 {% if not last %}md:border-r{% endif %}">
<h1 class="col-span-2 text-center">
{% if name == "water" %}
🌊
{% elif name == "middle" %}
{% else %}
⛰️
{% endif %}
- Gang
</h1>
{{ self::show_side(aisle_name = name, side_name = "mountain") }} {{ self::show_side(aisle_name = name, side_name = "mountain") }}
{{ self::show_side(aisle_name = name, side_name = "water") }} {{ self::show_side(aisle_name = name, side_name = "water") }}
</div> </div>