feat: implement simple file upload

This commit is contained in:
Jef Roosens 2025-01-16 22:19:22 +01:00
parent c10b9baa95
commit 52478379a0
Signed by: Jef Roosens
GPG key ID: 02D4C0997E74717B
11 changed files with 232 additions and 9 deletions

View file

@ -0,0 +1,16 @@
{% macro form(plant_id, target="#images > ul") %}
<form hx-post="/images" hx-target="{{ target }}" hx-swap="beforeend" enctype="multipart/form-data">
<input type="hidden" id="plant_id" name="plant_id" value="{{ plant_id }}">
<label for="date_taken">Date taken:</label>
<input type="date" id="date_taken" name="date_taken"></br>
<label for="note">Note:</label>
<textarea id="note" name="note" rows=1></textarea></br>
<label for="image">Image:</label>
<input type="file" id="image" name="image" accept="image/*" capture="environment"></br>
<input type="submit">
</form>
{% endmacro form %}

View file

@ -1,7 +1,13 @@
{% import "components/event.html" as comp_event %}
{% import "components/plant.html" as comp_plant %}
{% import "components/image.html" as comp_image %}
{{ comp_plant::info(plant=plant) }}
<h3>Events</h3>
{{ comp_event::list(events=events) }}
{{ comp_event::form(plant_id=plant.id) }}
<h3>Images</h3>
<div id="images">
<ul></ul>
</div>
{{ comp_image::form(plant_id=plant.id) }}