This commit is contained in:
+34
-2
@@ -293,6 +293,9 @@ func (s *Server) routes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("POST /board/tasks/{id}/delete", s.requireAuth(s.csrf(s.deleteBoardTask)))
|
||||
mux.HandleFunc("POST /board/tasks/{id}/tags", s.requireAuth(s.csrf(s.setBoardTaskTags)))
|
||||
mux.HandleFunc("POST /board/tasks/{id}/details", s.requireAuth(s.csrf(s.setBoardTaskDetails)))
|
||||
mux.HandleFunc("POST /board/tasks/{id}/todos", s.requireAuth(s.csrf(s.createBoardTaskTodo)))
|
||||
mux.HandleFunc("POST /board/tasks/{id}/todos/{todoID}/toggle", s.requireAuth(s.csrf(s.toggleBoardTaskTodo)))
|
||||
mux.HandleFunc("POST /board/tasks/{id}/todos/{todoID}/delete", s.requireAuth(s.csrf(s.deleteBoardTaskTodo)))
|
||||
mux.HandleFunc("POST /board/tags", s.requireAuth(s.csrf(s.createBoardTag)))
|
||||
mux.HandleFunc("POST /board/tags/{id}/delete", s.requireAuth(s.csrf(s.deleteBoardTag)))
|
||||
mux.HandleFunc("GET /admin/requests", s.requireAdmin(s.adminPage))
|
||||
@@ -807,9 +810,9 @@ func (s *Server) boardPage(w http.ResponseWriter, r *http.Request) {
|
||||
tasks = filtered
|
||||
}
|
||||
columns := []BoardColumn{
|
||||
{Status: "backlog", Title: "Backlog", Hint: "Ready to pick up"},
|
||||
{Status: "backlog", Title: "Backlog", Hint: "Untriaged work"},
|
||||
{Status: "todo", Title: "To do", Hint: "Ready to start"},
|
||||
{Status: "in_progress", Title: "In progress", Hint: "Actively being worked"},
|
||||
{Status: "blocked", Title: "Blocked", Hint: "Needs help"},
|
||||
{Status: "done", Title: "Done", Hint: "Completed work"},
|
||||
}
|
||||
for _, task := range tasks {
|
||||
@@ -970,6 +973,35 @@ func (s *Server) setBoardTaskDetails(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/board?flash=Card+details+updated", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) createBoardTaskTodo(w http.ResponseWriter, r *http.Request) {
|
||||
taskID, _ := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err := s.store.CreateBoardTaskTodo(taskID, r.FormValue("body")); err != nil {
|
||||
http.Redirect(w, r, "/board?error="+url.QueryEscape(err.Error()), http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/board?flash=To-do+item+added", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) toggleBoardTaskTodo(w http.ResponseWriter, r *http.Request) {
|
||||
taskID, _ := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
todoID, _ := strconv.ParseInt(r.PathValue("todoID"), 10, 64)
|
||||
if err := s.store.SetBoardTaskTodoCompleted(taskID, todoID, r.FormValue("completed") == "on"); err != nil {
|
||||
http.Redirect(w, r, "/board?error="+url.QueryEscape(err.Error()), http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/board?flash=To-do+item+updated", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) deleteBoardTaskTodo(w http.ResponseWriter, r *http.Request) {
|
||||
taskID, _ := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
todoID, _ := strconv.ParseInt(r.PathValue("todoID"), 10, 64)
|
||||
if err := s.store.DeleteBoardTaskTodo(taskID, todoID); err != nil {
|
||||
http.Redirect(w, r, "/board?error="+url.QueryEscape(err.Error()), http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/board?flash=To-do+item+removed", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) createBoardTag(w http.ResponseWriter, r *http.Request) {
|
||||
if err := s.store.CreateBoardTag(r.FormValue("name"), r.FormValue("color")); err != nil {
|
||||
http.Redirect(w, r, "/board?error="+url.QueryEscape(err.Error()), http.StatusSeeOther)
|
||||
|
||||
Reference in New Issue
Block a user