Add inline tags form to payments

This commit is contained in:
jordi fita mas 2024-08-15 04:18:35 +02:00
parent fa57c4b191
commit a30e015639
2 changed files with 10 additions and 0 deletions

View File

@ -314,3 +314,11 @@ func servePaymentAttachment(w http.ResponseWriter, r *http.Request, params httpr
where slug = $1 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")
}

View File

@ -67,6 +67,8 @@ func NewRouter(db *Db, demo bool) http.Handler {
companyRouter.GET("/payments/:slug", servePaymentForm) companyRouter.GET("/payments/:slug", servePaymentForm)
companyRouter.PUT("/payments/:slug", handleEditPayment) companyRouter.PUT("/payments/:slug", handleEditPayment)
companyRouter.DELETE("/payments/:slug", handleRemovePayment) 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("/payments/:slug/download/:filename", servePaymentAttachment)
companyRouter.GET("/payment-accounts", servePaymentAccountIndex) companyRouter.GET("/payment-accounts", servePaymentAccountIndex)
companyRouter.POST("/payment-accounts", handleAddPaymentAccount) companyRouter.POST("/payment-accounts", handleAddPaymentAccount)