Files
Gardomatic/internal/web/templates/pages/species_form.tmpl
T
kleiax 904d14b64c
CI / test (push) Canceled after 0s
Initial commit
2026-09-12 22:22:17 +02:00

73 lines
9.6 KiB
Cheetah
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{define "title"}}{{if .SpeciesID}}Art ansehen{{else}}Art anlegen{{end}}{{end}}
{{define "main"}}
{{$form := .Form}}
{{$editable := canEditSpecies .Garden .CurrentUser $form.Global .SpeciesID}}
{{$step := .WizardStep}}
{{$all := eqString $step "all"}}
{{$general := or $all (eqString $step "") (eqString $step "general")}}
<div class='{{if .SpeciesID}}settings-layout{{end}}'>
{{if .SpeciesID}}<aside class='settings-sidebar panel'><nav aria-label='Bearbeitungsbereiche'><a href='{{if $all}}#species-general{{else}}{{pathWithQuery (webPath "species.edit" .Garden.ID .SpeciesID) "step" "general"}}{{end}}' {{if and (not $all) $general}}aria-current='page'{{end}}>Allgemein</a><a href='{{if $all}}#species-care{{else}}{{pathWithQuery (webPath "species.edit" .Garden.ID .SpeciesID) "step" "care"}}{{end}}' {{if eqString $step "care"}}aria-current='page'{{end}}>Pflegeanweisungen</a><a href='{{if $all}}#species-tasks{{else}}{{pathWithQuery (webPath "species.edit" .Garden.ID .SpeciesID) "step" "tasks"}}{{end}}' {{if eqString $step "tasks"}}aria-current='page'{{end}}>Aufgabenvorlagen</a></nav></aside>{{end}}
<div class='settings-content'>
{{if $general}}
<section class='panel species-detail' id='species-general'>
<h2>{{if .SpeciesID}}{{if $editable}}{{if $form.Global}}Globale Art bearbeiten{{else}}Art bearbeiten{{end}}{{else}}Art ansehen{{end}}{{else}}Art anlegen{{end}}</h2>
{{if and .SpeciesID (not $editable)}}<p class='muted'>Diese Art ist nur lesbar.</p>{{end}}
<form method='POST'>
<input type='hidden' name='csrf_token' value='{{.CSRFToken}}'>
{{if and .SpeciesID $form.Global}}<input type='hidden' name='global' value='true'>{{end}}
{{if and (not .SpeciesID) (canGlobalSpecies .CurrentUser)}}<label class='checkbox'><input type='checkbox' name='global' value='true' {{if or $form.Global (not (canGarden .Garden "species:write"))}}checked{{end}} {{if not (canGarden .Garden "species:write")}}disabled{{end}}> Global anlegen <span class='muted'>für alle Gärten verfügbar</span></label>{{if not (canGarden .Garden "species:write")}}<input type='hidden' name='global' value='true'>{{end}}{{end}}
{{if not .SpeciesID}}<label for='template_species_id'>Vorlage</label><select id='template_species_id' name='template_species_id' data-species-template><option value='0'>Ohne Vorlage</option>{{range .Species}}<option value='{{.ID}}' {{if eqInt $form.TemplateSpeciesID .ID}}selected{{end}}>{{.CommonName}}{{with .Cultivar}} · {{.}}{{end}}</option>{{end}}</select><p class='muted'>Die Felder und Aufgabenvorlagen werden übernommen; der Name bleibt leer.</p>{{end}}
<fieldset class='plain-fieldset' {{if not $editable}}disabled{{end}}>
<label>Name</label><input name='common_name' value='{{$form.CommonName}}' required>{{with index $form.Errors "common_name"}}<p class='field-error'>{{.}}</p>{{end}}
<label>Sorte</label><input name='cultivar' value='{{$form.Cultivar}}'>
<label>Botanischer Name</label><input name='botanical_name' value='{{$form.BotanicalName}}'>
{{template "image_editor" (dict "ImageData" $form.ImageData "ImageID" $form.ImageID "Images" .Images "GardenID" .Garden.ID)}}
<input type='hidden' name='attributes' value='{{$form.Attributes}}'>
<label for='category_id'>Kategorie</label>
<select id='category_id' name='category_id'>
<option value='0' {{if eqInt $form.CategoryID 0}}selected{{end}}>Keine Kategorie</option>
{{range .SpeciesCategories}}{{if or .Active (eqInt $form.CategoryID .ID)}}<option value='{{.ID}}' {{if eqInt $form.CategoryID .ID}}selected{{end}}>{{.Name}}{{with lifecycleName .Lifecycle}} ({{.}}){{end}}{{if not .Active}} (inaktiv){{end}}</option>{{end}}{{end}}
</select>
{{with index $form.Errors "category_id"}}<p class='field-error'>{{.}}</p>{{end}}
<div class='form-grid'><label>Licht<select name='sun_exposure'><option value=''>Nicht angegeben</option><option value='sunny' {{if eqString $form.SunExposure "sunny"}}selected{{end}}>Sonnig</option><option value='partial_shade' {{if eqString $form.SunExposure "partial_shade"}}selected{{end}}>Halbschattig</option><option value='shade' {{if eqString $form.SunExposure "shade"}}selected{{end}}>Schattig</option></select></label><label>Bodenbeschaffenheit<select name='soil_condition'><option value=''>Nicht angegeben</option><option value='dry' {{if eqString $form.SoilCondition "dry"}}selected{{end}}>Trocken</option><option value='moist' {{if eqString $form.SoilCondition "moist"}}selected{{end}}>Feucht</option><option value='boggy' {{if eqString $form.SoilCondition "boggy"}}selected{{end}}>Sumpfig</option></select></label><label>Bodenreaktion<select name='soil_reaction'><option value=''>Nicht angegeben</option><option value='alkaline' {{if eqString $form.SoilReaction "alkaline"}}selected{{end}}>Basisch</option><option value='acidic' {{if eqString $form.SoilReaction "acidic"}}selected{{end}}>Sauer</option><option value='neutral' {{if eqString $form.SoilReaction "neutral"}}selected{{end}}>Neutral</option></select></label><label>Winterschutz<input name='winter_protection' value='{{$form.WinterProtection}}'></label><label>Pflanzabstand in cm<input type='number' min='1' name='spacing_cm' value='{{if $form.SpacingCM}}{{$form.SpacingCM}}{{end}}'></label><label>Höhe in cm<input type='number' min='1' name='height_cm' value='{{if $form.HeightCM}}{{$form.HeightCM}}{{end}}'></label></div>
{{template "season_range" (dict "Legend" "Aussaat" "Prefix" "sow" "Month" $form.SowMonthFrom "Day" $form.SowDayFrom "Duration" $form.SowDuration "Unit" $form.SowDurationUnit)}}
{{template "season_range" (dict "Legend" "Pflanzzeit" "Prefix" "planting" "Month" $form.PlantingMonthFrom "Day" $form.PlantingDayFrom "Duration" $form.PlantingDuration "Unit" $form.PlantingDurationUnit)}}
{{template "season_range" (dict "Legend" "Ernte" "Prefix" "harvest" "Month" $form.HarvestMonthFrom "Day" $form.HarvestDayFrom "Duration" $form.HarvestDuration "Unit" $form.HarvestDurationUnit)}}
{{template "tag_editor" .}}
<label>Notizen</label><textarea name='notes'>{{$form.Notes}}</textarea>
</fieldset>
<div class='actions'>{{if $editable}}{{if $all}}<button type='submit'>Speichern</button>{{else}}<button type='submit' name='continue' value='care'>Speichern und weiter</button><button type='submit' class='secondary'>Speichern und beenden</button>{{end}}{{end}}<a href='{{webPath "species" .Garden.ID}}'>{{if $editable}}Abbrechen{{else}}Zurück{{end}}</a>{{if and .SpeciesID $editable}}<button class='danger' type='submit' formaction='{{webPath "species.delete" .Garden.ID .SpeciesID}}' formmethod='post' formnovalidate>Art löschen</button>{{end}}</div>
</form>
</section>
{{end}}
{{if and .SpeciesID (or $all (eqString $step "care"))}}<div class='species-support-grid'>
<section class='panel care-instructions' id='species-care'>
<h3>Pflegeanweisungen</h3>
{{template "care_instruction_list" .}}
{{if $editable}}<details class='care-instruction-add'><summary class='icon-button' aria-label='Pflegeanweisung hinzufügen' title='Pflegeanweisung hinzufügen'></summary><form method='POST' action='{{webPath "species.care.new" .Garden.ID .SpeciesID}}' hx-post='{{webPath "species.care.new" .Garden.ID .SpeciesID}}' hx-target='#care-instruction-list' hx-swap='innerHTML'><input type='hidden' name='csrf_token' value='{{.CSRFToken}}'><label>Text<textarea name='text' required></textarea></label><label>Status<select name='status'>{{range careStatuses}}<option value='{{.Value}}'>{{.Label}}</option>{{end}}</select></label><button>Hinzufügen</button></form></details>{{end}}
{{if not $all}}<div class='actions'><a class='button' href='{{pathWithQuery (webPath "species.edit" .Garden.ID .SpeciesID) "step" "tasks"}}'>Weiter zu Aufgabenvorlagen</a><a href='{{webPath "species" .Garden.ID}}'>Überspringen und beenden</a></div>{{end}}
</section>
</div>{{end}}
{{if and .SpeciesID (or $all (eqString $step "tasks"))}}<div class='species-support-grid'>
<section class='panel species-task-templates' id='species-tasks'>
<h3>Aufgabenvorlagen</h3>
<div class='species-template-list'>
{{range index .TaskTemplates .SpeciesID}}
<div class='species-template-row'>
{{if $editable}}
<button type='button' class='species-template-open' hx-get='{{pathWithQuery (webPath "task-template.edit" $.Garden.ID .ID) "species_id" $.SpeciesID}}' hx-target='#task-template-dialog-host' hx-swap='innerHTML'>{{.Title}}{{if and .Origin (not (eqString .Origin "manual"))}} · automatisch{{end}}{{if not .Active}} · inaktiv{{end}}</button>
{{if or (not .Origin) (eqString .Origin "manual")}}<form method='POST' action='{{pathWithQuery (webPath "task-template.delete" $.Garden.ID .ID) "species_id" $.SpeciesID}}'><input type='hidden' name='csrf_token' value='{{$.CSRFToken}}'><button type='submit' class='template-remove' aria-label='{{.Title}} entfernen' title='Vorlage entfernen'>×</button></form>{{end}}
{{else}}<span>{{.Title}}</span>{{end}}
</div>
{{else}}<p class='muted'>Noch keine Vorlagen.</p>{{end}}
</div>
{{if $editable}}<button type='button' class='icon-button species-template-add' hx-get='{{pathWithQuery (webPath "task-template.new" .Garden.ID) "species_id" .SpeciesID}}' hx-target='#task-template-dialog-host' hx-swap='innerHTML' aria-label='Aufgabenvorlage hinzufügen' title='Aufgabenvorlage hinzufügen'></button>{{end}}
<div id='task-template-dialog-host'></div>
{{if not $all}}<div class='actions'><a class='button' href='{{webPath "species" .Garden.ID}}'>Fertig</a></div>{{end}}
</section>
</div>{{end}}
</div></div>
{{end}}