From a30e015639cfd85f1381b3ff822aa83923a9558f Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Thu, 15 Aug 2024 04:18:35 +0200 Subject: [PATCH] Add inline tags form to payments --- pkg/payments.go | 8 ++++++++ pkg/router.go | 2 ++ 2 files changed, 10 insertions(+) diff --git a/pkg/payments.go b/pkg/payments.go index d0e064f..fd4c7d4 100644 --- a/pkg/payments.go +++ b/pkg/payments.go @@ -314,3 +314,11 @@ func servePaymentAttachment(w http.ResponseWriter, r *http.Request, params httpr where slug = $1 `) } + +func servePaymentTagsEditForm(w http.ResponseWriter, r *http.Request, params httprouter.Params) { + serveTagsEditForm(w, r, params, "/payments/", "select tags from payment where slug = $1") +} + +func handleUpdatePaymentTags(w http.ResponseWriter, r *http.Request, params httprouter.Params) { + handleUpdateTags(w, r, params, "/payments/", "update payment set tags = $1 where slug = $2 returning slug") +} diff --git a/pkg/router.go b/pkg/router.go index 92cbed4..b5596b7 100644 --- a/pkg/router.go +++ b/pkg/router.go @@ -67,6 +67,8 @@ func NewRouter(db *Db, demo bool) http.Handler { companyRouter.GET("/payments/:slug", servePaymentForm) companyRouter.PUT("/payments/:slug", handleEditPayment) companyRouter.DELETE("/payments/:slug", handleRemovePayment) + companyRouter.PUT("/payments/:slug/tags", handleUpdatePaymentTags) + companyRouter.GET("/payments/:slug/tags/edit", servePaymentTagsEditForm) companyRouter.GET("/payments/:slug/download/:filename", servePaymentAttachment) companyRouter.GET("/payment-accounts", servePaymentAccountIndex) companyRouter.POST("/payment-accounts", handleAddPaymentAccount)