Compare commits

...

2 Commits

Author SHA1 Message Date
fda2673f5a Merge pull request 'improve boathouse functionality, fixes #261' (#281) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m12s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 3m57s
Reviewed-on: #281
2024-03-20 13:59:30 +01:00
68a1153885 improve boathouse functionality, fixes #261
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m22s
CI/CD Pipeline / deploy-staging (push) Successful in 4m4s
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-03-20 13:58:42 +01:00
2 changed files with 30 additions and 14 deletions

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,18 +10,22 @@
{{ 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 %}
<details> {% if "admin" in loggedin_user.roles %}
<summary>Kein Boot</summary> <details>
<form action="/board/boathouse" method="post" class="grid gap-3"> <summary>Kein Boot</summary>
{{ macros::select(label="Boot", data=boats, name="boat_id", id="boat_id", display=["name", " (","amount_seats", " x)"], wrapper_class="col-span-4") }} <form action="/board/boathouse" method="post" class="grid gap-3">
<input type="hidden" name="aisle" value="{{ aisle_name }}" /> {{ macros::select(label="Boot", data=boats, name="boat_id", id="boat_id", display=["name", " (","amount_seats", " x)"], wrapper_class="col-span-4") }}
<input type="hidden" name="side" value="{{ side_name }}" /> <input type="hidden" name="aisle" value="{{ aisle_name }}" />
<input type="hidden" name="level" value="{{ level }}" /> <input type="hidden" name="side" value="{{ side_name }}" />
<input type="submit" <input type="hidden" name="level" value="{{ level }}" />
class="btn btn-primary w-full col-span-4" <input type="submit"
value="Boot eintragen" /> class="btn btn-primary w-full col-span-4"
</form> value="Boot eintragen" />
</details> </form>
</details>
{% else %}
Kein Boot
{% endif %}
{% else %} {% else %}
Kein Boot Kein Boot
{% endif %} {% endif %}
@ -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) }}
{{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 5) }} {% if aisle_name != 'water' or side_name != 'water' %}
{{ 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>