Initial commit
CI / test (push) Canceled after 0s

This commit is contained in:
2026-09-12 22:22:17 +02:00
commit 904d14b64c
314 changed files with 31884 additions and 0 deletions
@@ -0,0 +1,89 @@
{{define "title"}}{{if .PlantID}}Pflanze bearbeiten{{else}}Pflanze erfassen{{end}}{{end}}
{{define "main"}}
{{$canSave := canGarden .Garden "plants:create"}}{{if .PlantID}}{{$canSave = canGardenResource .Garden .CurrentUser .PlantCreatedBy "plants:update:own" "plants:update:other"}}{{end}}
<div class='{{if .PlantID}}settings-layout{{end}}'>
{{if .PlantID}}<aside class='settings-sidebar panel'><nav aria-label='Bearbeitungsbereiche'><a href='#plant-general'>Allgemein</a><a href='#plant-tasks'>Aufgaben</a></nav></aside>{{end}}
<div class='settings-content'><section class='panel plant-detail' id='plant-general'>
<h2>{{if .PlantID}}Pflanze bearbeiten{{else}}Pflanze erfassen{{end}}</h2>
{{$form := .Form}}
<form action='{{if .PlantID}}{{webPath "plant.edit" .Garden.ID .PlantID}}{{else}}{{webPath "plant.new" .Garden.ID}}{{end}}' method='POST'>
<input type='hidden' name='csrf_token' value='{{.CSRFToken}}'>
<label for='name'>Name</label>
<input id='name' name='name' value='{{$form.Name}}' required data-plant-name>
{{with index $form.Errors "name"}}<p class='field-error'>{{.}}</p>{{end}}
{{template "image_editor" (dict "ImageData" $form.ImageData "ImageID" $form.ImageID "Images" .Images "GardenID" .Garden.ID)}}
<label for='species_id'>Art oder Sorte</label>
<select id='species_id' name='species_id' data-plant-species hx-get='{{if .PlantID}}{{pathWithQuery (webPath "plant.template-tasks" .Garden.ID) "plant_id" .PlantID}}{{else}}{{webPath "plant.template-tasks" .Garden.ID}}{{end}}' hx-trigger='change' hx-target='#plant-template-tasks' hx-swap='outerHTML' hx-include='this'>
<option value='0' {{if eqInt $form.SpeciesID 0}}selected{{end}}>Ohne Artzuordnung</option>
{{range .Species}}<option value='{{.ID}}' data-plant-name-value='{{.CommonName}}{{with .Cultivar}} · {{.}}{{end}}' data-sun='{{stringValue .SunExposure}}' data-soil='{{stringValue .SoilCondition}}' data-reaction='{{stringValue .SoilReaction}}' {{if eqInt $form.SpeciesID .ID}}selected{{end}}>{{.CommonName}}{{with .Cultivar}} · {{.}}{{end}}</option>{{end}}
</select>
{{with index $form.Errors "species_id"}}<p class='field-error'>{{.}}</p>{{end}}
<fieldset class='assignment-fieldset'>
<legend>Orte und Anzahl</legend>
{{if not .PlantID}}{{$locationURL := pathWithQuery (webPath "location.new" .Garden.ID) "return_to" (webPath "plant.new" .Garden.ID)}}<a class='create-location-link' href='{{$locationURL}}' hx-get='{{$locationURL}}' hx-target='#location-dialog-host' hx-swap='innerHTML'>Ort direkt anlegen</a>{{end}}
<div class='assignment-list' data-assignment-list>
{{range $index, $assignment := $form.Assignments}}
<div class='assignment-row' data-assignment-row>
<input type='hidden' name='assignment_id' value='{{$assignment.AssignmentID}}'>
<div>
<label for='{{if eqInt $index 0}}location_id{{else}}location_id_{{$index}}{{end}}'>Ort</label>
<select id='{{if eqInt $index 0}}location_id{{else}}location_id_{{$index}}{{end}}' name='location_id' class='assignment-location'>
<option value='0' {{if eqInt $assignment.LocationID 0}}selected{{end}}>Noch keinem Ort zuordnen</option>
{{range $.Locations}}<option value='{{.ID}}' {{if eqInt $assignment.LocationID .ID}}selected{{end}}>{{.Name}}</option>{{end}}
</select>
</div>
<div class='quantity-field'>
<label for='quantity_{{$index}}'>Anzahl</label>
<input id='quantity_{{$index}}' name='quantity' type='number' min='1' value='{{$assignment.Quantity}}'>
{{with index $form.Errors (printf "quantity_%d" $index)}}<p class='field-error'>{{.}}</p>{{end}}
</div>
<button type='button' class='assignment-remove secondary' data-remove-assignment aria-label='Ort entfernen' title='Ort entfernen'>×</button>
</div>
{{end}}
</div>
<button type='button' class='icon-button assignment-add' data-add-assignment aria-label='Weiteren Ort hinzufügen' title='Weiteren Ort hinzufügen'></button>
</fieldset>
<template id='assignment-row-template'>
<div class='assignment-row' data-assignment-row>
<input type='hidden' name='assignment_id' value='0'>
<div><label>Ort</label><select name='location_id'><option value='0' selected>Noch keinem Ort zuordnen</option>{{range .Locations}}<option value='{{.ID}}'>{{.Name}}</option>{{end}}</select></div>
<div class='quantity-field'><label>Anzahl</label><input name='quantity' type='number' min='1' value='1'></div>
<button type='button' class='assignment-remove secondary' data-remove-assignment aria-label='Ort entfernen' title='Ort entfernen'>×</button>
</div>
</template>
<div hidden data-location-compatibilities>{{range .Locations}}<span data-location-id='{{.ID}}' data-sun='{{stringValue .SunExposure}}' data-soil='{{stringValue .SoilCondition}}' data-reaction='{{stringValue .SoilReaction}}'></span>{{end}}</div><div class='compatibility-warning' data-compatibility-warning role='status' hidden></div>
<label for='acquired_at'>Erworben oder gepflanzt am</label>
<input id='acquired_at' name='acquired_at' type='date' value='{{$form.AcquiredAt}}'>
{{with index $form.Errors "acquired_at"}}<p class='field-error'>{{.}}</p>{{end}}
<label for='status'>Status</label>
<select id='status' name='status'>
{{range plantStatuses}}<option value='{{.Value}}' {{if eqString $form.Status .Value}}selected{{end}}>{{.Label}}</option>{{end}}
</select>
{{template "tag_editor" .}}
<label for='notes'>Notizen</label>
<textarea id='notes' name='notes' rows='5'>{{$form.Notes}}</textarea>
{{with index $form.Errors "notes"}}<p class='field-error'>{{.}}</p>{{end}}
<fieldset class='plant-task-fieldset' id='plant-tasks'>
<legend>Aufgaben</legend>
{{template "plant_template_tasks" .}}
<div id='plant-manual-tasks' class='plant-task-list'>
{{range $form.Tasks}}{{template "plant_task_row_fragment" (plantTaskData $.Garden .)}}{{end}}
</div>
<button type='button' class='icon-button plant-task-add' hx-get='{{pathWithQuery (webPath "plant.task-row" .Garden.ID) "new" true "plant_id" .PlantID}}' hx-include='#name, #location_id' hx-target='#plant-task-dialog-host' hx-swap='innerHTML' aria-label='Weitere Aufgabe hinzufügen' title='Weitere Aufgabe hinzufügen'></button>
</fieldset>
<div class='actions'>{{if $canSave}}<button type='submit'>Speichern</button>{{end}}<a href='{{webPath "plants" .Garden.ID}}'>{{if $canSave}}Abbrechen{{else}}Zurück{{end}}</a></div>
</form>
<div id='location-dialog-host'></div>
<div id='plant-task-dialog-host'></div>
{{if and .PlantID (canGardenResource .Garden .CurrentUser .PlantCreatedBy "plants:delete:own" "plants:delete:other")}}<form class='delete-form' method='POST' action='{{webPath "plant.delete" .Garden.ID .PlantID}}'><input type='hidden' name='csrf_token' value='{{.CSRFToken}}'><button type='submit' class='danger'>Pflanze löschen</button></form>{{end}}
</section>
</div></div>
{{end}}