Skip to content

Commit ce15591

Browse files
authored
feat: add start field to task panel (CCExtractor#283)
1 parent f83f718 commit ce15591

9 files changed

Lines changed: 39 additions & 4 deletions

File tree

backend/controllers/add_task.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func AddTaskHandler(w http.ResponseWriter, r *http.Request) {
4646
project := requestBody.Project
4747
priority := requestBody.Priority
4848
dueDate := requestBody.DueDate
49+
start := requestBody.Start
4950
tags := requestBody.Tags
5051
annotations := requestBody.Annotations
5152

@@ -63,7 +64,7 @@ func AddTaskHandler(w http.ResponseWriter, r *http.Request) {
6364
Name: "Add Task",
6465
Execute: func() error {
6566
logStore.AddLog("INFO", fmt.Sprintf("Adding task: %s", description), uuid, "Add Task")
66-
err := tw.AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDateStr, tags, annotations)
67+
err := tw.AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDateStr, start, tags, annotations)
6768
if err != nil {
6869
logStore.AddLog("ERROR", fmt.Sprintf("Failed to add task: %v", err), uuid, "Add Task")
6970
return err

backend/models/request_body.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type AddTaskRequestBody struct {
99
Project string `json:"project"`
1010
Priority string `json:"priority"`
1111
DueDate *string `json:"due"`
12+
Start string `json:"start"`
1213
Tags []string `json:"tags"`
1314
Annotations []Annotation `json:"annotations"`
1415
}

backend/utils/tw/add_task.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
// add task to the user's tw client
13-
func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate string, tags []string, annotations []models.Annotation) error {
13+
func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate, start string, tags []string, annotations []models.Annotation) error {
1414
if err := utils.ExecCommand("rm", "-rf", "/root/.task"); err != nil {
1515
return fmt.Errorf("error deleting Taskwarrior data: %v", err)
1616
}
@@ -40,6 +40,9 @@ func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, p
4040
if dueDate != "" {
4141
cmdArgs = append(cmdArgs, "due:"+dueDate)
4242
}
43+
if start != "" {
44+
cmdArgs = append(cmdArgs, "start:"+start)
45+
}
4346
// Add tags to the task
4447
if len(tags) > 0 {
4548
for _, tag := range tags {

backend/utils/tw/taskwarrior_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestExportTasks(t *testing.T) {
4242
}
4343

4444
func TestAddTaskToTaskwarrior(t *testing.T) {
45-
err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", nil, []models.Annotation{{Description: "note"}})
45+
err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", "2025-03-01", nil, []models.Annotation{{Description: "note"}})
4646
if err != nil {
4747
t.Errorf("AddTaskToTaskwarrior failed: %v", err)
4848
} else {
@@ -60,7 +60,7 @@ func TestCompleteTaskInTaskwarrior(t *testing.T) {
6060
}
6161

6262
func TestAddTaskWithTags(t *testing.T) {
63-
err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", []string{"work", "important"}, []models.Annotation{{Description: "note"}})
63+
err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", "2025-03-01", []string{"work", "important"}, []models.Annotation{{Description: "note"}})
6464
if err != nil {
6565
t.Errorf("AddTaskToTaskwarrior with tags failed: %v", err)
6666
} else {

frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,23 @@ export const AddTaskdialog = ({
228228
/>
229229
</div>
230230
</div>
231+
<div className="grid grid-cols-4 items-center gap-4">
232+
<Label htmlFor="start" className="text-right">
233+
Start
234+
</Label>
235+
<div className="col-span-3">
236+
<DatePicker
237+
date={newTask.start ? new Date(newTask.start) : undefined}
238+
onDateChange={(date) => {
239+
setNewTask({
240+
...newTask,
241+
start: date ? format(date, 'yyyy-MM-dd') : '',
242+
});
243+
}}
244+
placeholder="Select a start date"
245+
/>
246+
</div>
247+
</div>
231248
<div className="grid grid-cols-8 items-center gap-4">
232249
<Label htmlFor="tags" className="text-right col-span-2">
233250
Tags

frontend/src/components/HomeComponents/Tasks/Tasks.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export const Tasks = (
7272
priority: '',
7373
project: '',
7474
due: '',
75+
start: '',
7576
tags: [],
7677
annotations: [],
7778
});
@@ -306,6 +307,7 @@ export const Tasks = (
306307
project: task.project,
307308
priority: task.priority,
308309
due: task.due || undefined,
310+
start: task.start || '',
309311
tags: task.tags,
310312
annotations: task.annotations,
311313
backendURL: url.backendURL,
@@ -317,6 +319,7 @@ export const Tasks = (
317319
priority: '',
318320
project: '',
319321
due: '',
322+
start: '',
320323
tags: [],
321324
annotations: [],
322325
});

frontend/src/components/HomeComponents/Tasks/__tests__/AddTaskDialog.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ describe('AddTaskDialog Component', () => {
5858
priority: 'M',
5959
project: '',
6060
due: '',
61+
start: '',
6162
tags: [],
6263
annotations: [],
6364
},
@@ -219,6 +220,7 @@ describe('AddTaskDialog Component', () => {
219220
priority: 'H',
220221
project: 'Work',
221222
due: '2024-12-25',
223+
start: '',
222224
tags: ['urgent'],
223225
annotations: [],
224226
};

frontend/src/components/HomeComponents/Tasks/hooks.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const addTaskToBackend = async ({
4242
project,
4343
priority,
4444
due,
45+
start,
4546
tags,
4647
annotations,
4748
backendURL,
@@ -53,6 +54,7 @@ export const addTaskToBackend = async ({
5354
project: string;
5455
priority: string;
5556
due?: string;
57+
start: string;
5658
tags: string[];
5759
annotations: { entry: string; description: string }[];
5860
backendURL: string;
@@ -72,6 +74,11 @@ export const addTaskToBackend = async ({
7274
requestBody.due = due;
7375
}
7476

77+
// Only include start if it's provided
78+
if (start !== undefined && start !== '') {
79+
requestBody.start = start;
80+
}
81+
7582
// Add annotations to request body, filtering out empty descriptions
7683
requestBody.annotations = annotations.filter(
7784
(annotation) =>

frontend/src/components/utils/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export interface TaskFormData {
9999
priority: string;
100100
project: string;
101101
due: string;
102+
start: string;
102103
tags: string[];
103104
annotations: Annotation[];
104105
}

0 commit comments

Comments
 (0)