From 4d9b3a2997dbcdea1ffda54beea1cc41a574bfb3 Mon Sep 17 00:00:00 2001 From: Kai Date: Tue, 17 Feb 2026 17:33:38 +0100 Subject: [PATCH] =?UTF-8?q?Aufgaben-Templates=20l=C3=B6schbar=20machen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/server/handlers_actions.go | 21 +++++++++++++++++++++ cmd/server/main.go | 1 + templates/planning.html | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/cmd/server/handlers_actions.go b/cmd/server/handlers_actions.go index ba0895d..da20ca9 100644 --- a/cmd/server/handlers_actions.go +++ b/cmd/server/handlers_actions.go @@ -498,6 +498,27 @@ func (a *App) handleCreateTaskTemplate(w http.ResponseWriter, r *http.Request) { redirectWithMessage(w, r, "/planning", "info", "Template gespeichert") } +func (a *App) handleDeleteTaskTemplate(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + http.Error(w, "method not allowed", http.StatusMethodNotAllowed) + return + } + if err := r.ParseForm(); err != nil { + redirectWithMessage(w, r, "/planning", "error", "Form ungültig") + return + } + id := mustInt64(r.FormValue("id"), 0) + if id <= 0 { + redirectWithMessage(w, r, "/planning", "error", "Template-ID ungültig") + return + } + if _, err := a.db.Exec(`DELETE FROM custom_task_templates WHERE id=?`, id); err != nil { + redirectWithMessage(w, r, "/planning", "error", "Template konnte nicht gelöscht werden") + return + } + redirectWithMessage(w, r, "/planning", "info", "Template gelöscht") +} + func (a *App) handleCreateCustomTask(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { http.Error(w, "method not allowed", http.StatusMethodNotAllowed) diff --git a/cmd/server/main.go b/cmd/server/main.go index 1c1e18f..afed76f 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -69,6 +69,7 @@ func main() { mux.HandleFunc("/crop-steps/create", app.handleCreateCropStep) mux.HandleFunc("/crop-steps/delete", app.handleDeleteCropStep) mux.HandleFunc("/task-templates/create", app.handleCreateTaskTemplate) + mux.HandleFunc("/task-templates/delete", app.handleDeleteTaskTemplate) mux.HandleFunc("/custom-tasks/create", app.handleCreateCustomTask) mux.HandleFunc("/custom-tasks/delete", app.handleDeleteCustomTask) diff --git a/templates/planning.html b/templates/planning.html index f77fb60..35f916e 100644 --- a/templates/planning.html +++ b/templates/planning.html @@ -69,6 +69,28 @@ +
+ + + + {{if .TaskTemplates}} + {{range .TaskTemplates}} + + + + + {{end}} + {{else}} + + {{end}} + +
TemplateAktion
{{.Title}} +
+ + +
+
Keine Templates vorhanden.
+