Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/controllers/edit_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func EditTaskHandler(w http.ResponseWriter, r *http.Request) {
taskID := requestBody.TaskID
description := requestBody.Description
tags := requestBody.Tags
project := requestBody.Project

if taskID == "" {
http.Error(w, "taskID is required", http.StatusBadRequest)
Expand All @@ -61,7 +62,7 @@ func EditTaskHandler(w http.ResponseWriter, r *http.Request) {
Name: "Edit Task",
Execute: func() error {
logStore.AddLog("INFO", fmt.Sprintf("Editing task ID: %s", taskID), uuid, "Edit Task")
err := tw.EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskID, tags)
err := tw.EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskID, tags, project)
if err != nil {
logStore.AddLog("ERROR", fmt.Sprintf("Failed to edit task ID %s: %v", taskID, err), uuid, "Edit Task")
return err
Expand Down
2 changes: 1 addition & 1 deletion backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.19
require (
github.com/gorilla/sessions v1.2.2
github.com/swaggo/http-swagger v1.3.4
github.com/swaggo/swag v1.16.3
golang.org/x/oauth2 v0.20.0
)

Expand All @@ -20,7 +21,6 @@ require (
github.com/mailru/easyjson v0.7.6 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe // indirect
github.com/swaggo/swag v1.16.3 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/tools v0.7.0 // indirect
Expand Down
1 change: 1 addition & 0 deletions backend/models/request_body.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type EditTaskRequestBody struct {
TaskID string `json:"taskid"`
Description string `json:"description"`
Tags []string `json:"tags"`
Project string `json:"project"`
}
type CompleteTaskRequestBody struct {
Email string `json:"email"`
Expand Down
9 changes: 8 additions & 1 deletion backend/utils/tw/edit_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
)

func EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskID string, tags []string) error {
func EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskID string, tags []string, project string) error {
if err := utils.ExecCommand("rm", "-rf", "/root/.task"); err != nil {
return fmt.Errorf("error deleting Taskwarrior data: %v", err)
}
Expand All @@ -32,6 +32,13 @@ func EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskID st
return fmt.Errorf("failed to edit task: %v", err)
}

// Handle project
if project != "" {
if err := utils.ExecCommand("task", taskID, "modify", "project:"+project); err != nil {
return fmt.Errorf("failed to set project %s: %v", project, err)
}
}

// Handle tags
if len(tags) > 0 {
for _, tag := range tags {
Expand Down
8 changes: 4 additions & 4 deletions backend/utils/tw/taskwarrior_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestSyncTaskwarrior(t *testing.T) {
}

func TestEditTaskInATaskwarrior(t *testing.T) {
err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", nil)
err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", nil, "project")
if err != nil {
t.Errorf("EditTaskInTaskwarrior() failed: %v", err)
} else {
Expand Down Expand Up @@ -68,7 +68,7 @@ func TestAddTaskWithTags(t *testing.T) {
}

func TestEditTaskWithTagAddition(t *testing.T) {
err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"+urgent", "+important"})
err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"+urgent", "+important"}, "project")
if err != nil {
t.Errorf("EditTaskInTaskwarrior with tag addition failed: %v", err)
} else {
Expand All @@ -77,7 +77,7 @@ func TestEditTaskWithTagAddition(t *testing.T) {
}

func TestEditTaskWithTagRemoval(t *testing.T) {
err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"-work", "-lowpriority"})
err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"-work", "-lowpriority"}, "project")
if err != nil {
t.Errorf("EditTaskInTaskwarrior with tag removal failed: %v", err)
} else {
Expand All @@ -86,7 +86,7 @@ func TestEditTaskWithTagRemoval(t *testing.T) {
}

func TestEditTaskWithMixedTagOperations(t *testing.T) {
err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"+urgent", "-work", "normal"})
err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"+urgent", "-work", "normal"}, "project")
if err != nil {
t.Errorf("EditTaskInTaskwarrior with mixed tag operations failed: %v", err)
} else {
Expand Down
34 changes: 10 additions & 24 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading