Compare commits
5 Commits
6c28e4d24a
...
393b7a144a
| Author | SHA1 | Date | |
|---|---|---|---|
| 393b7a144a | |||
| 201f32d095 | |||
| e86d063912 | |||
| 10421b0ec6 | |||
| 08123aa3c5 |
@@ -0,0 +1,77 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.jnss.me/joakim/opal/internal/engine"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var olderFlag string
|
||||
|
||||
var cleanCmd = &cobra.Command{
|
||||
Use: "clean",
|
||||
Short: "Purge soft-deleted tasks from the database",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if err := cleanTasks(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
cleanCmd.Flags().StringVar(&olderFlag, "older", "", "Only purge tasks deleted longer than this duration ago (e.g. 30d, 1w)")
|
||||
}
|
||||
|
||||
func cleanTasks() error {
|
||||
var olderThan *time.Duration
|
||||
if olderFlag != "" {
|
||||
d, err := engine.ParseRecurrencePattern(olderFlag)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid duration %q: %w", olderFlag, err)
|
||||
}
|
||||
olderThan = &d
|
||||
}
|
||||
|
||||
tasks, err := engine.GetDeletedTasks(olderThan)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(tasks) == 0 {
|
||||
fmt.Println("No deleted tasks to purge.")
|
||||
return nil
|
||||
}
|
||||
|
||||
if dryRunFlag {
|
||||
fmt.Printf("Would permanently remove %d deleted task(s).\n", len(tasks))
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(tasks) > 1 {
|
||||
fmt.Printf("Permanently remove %d deleted task(s)? This cannot be undone. (y/N): ", len(tasks))
|
||||
var confirm string
|
||||
fmt.Scanln(&confirm)
|
||||
if confirm != "y" && confirm != "Y" {
|
||||
fmt.Println("Cancelled.")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
for _, task := range tasks {
|
||||
if err := task.Delete(true); err != nil {
|
||||
return fmt.Errorf("failed to purge task %s: %w", task.UUID, err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("Purged %d deleted task(s).\n", len(tasks))
|
||||
|
||||
if err := engine.CleanupChangeLog(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: failed to clean up change log: %v\n", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -2,14 +2,37 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.jnss.me/joakim/opal/internal/engine"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// taskFilterCompletion provides dynamic completions for task filter arguments.
|
||||
// Suggests +tag and project:name completions from the database.
|
||||
// Suggests +tag, project:name, and attribute value completions from the database.
|
||||
func taskFilterCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
// If typing a key:value, complete the value part
|
||||
if idx := strings.IndexByte(toComplete, ':'); idx >= 0 {
|
||||
key := toComplete[:idx]
|
||||
if engine.ValidAttributeKeys[key] {
|
||||
return attributeValueCompletions(key, toComplete), cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
}
|
||||
|
||||
// If toComplete is a prefix of an attribute key, return only key:
|
||||
// completions with NoSpace so the cursor stays after the colon.
|
||||
if toComplete != "" && !strings.HasPrefix(toComplete, "+") && !strings.HasPrefix(toComplete, "-") {
|
||||
var keyCompletions []string
|
||||
for key := range engine.ValidAttributeKeys {
|
||||
if strings.HasPrefix(key, toComplete) {
|
||||
keyCompletions = append(keyCompletions, fmt.Sprintf("%s:", key))
|
||||
}
|
||||
}
|
||||
if len(keyCompletions) > 0 {
|
||||
return keyCompletions, cobra.ShellCompDirectiveNoFileComp | cobra.ShellCompDirectiveNoSpace
|
||||
}
|
||||
}
|
||||
|
||||
var completions []string
|
||||
|
||||
tags, err := engine.GetAllTags()
|
||||
@@ -31,10 +54,69 @@ func taskFilterCompletion(cmd *cobra.Command, args []string, toComplete string)
|
||||
completions = append(completions, fmt.Sprintf("%s:", key))
|
||||
}
|
||||
|
||||
return completions, cobra.ShellCompDirectiveNoFileComp
|
||||
return completions, cobra.ShellCompDirectiveNoFileComp | cobra.ShellCompDirectiveNoSpace
|
||||
}
|
||||
|
||||
// attributeValueCompletions returns key:value completions for a known attribute key.
|
||||
// Cobra filters by prefix automatically, so we return all values prefixed with "key:".
|
||||
func attributeValueCompletions(key, toComplete string) []string {
|
||||
var values []string
|
||||
|
||||
switch key {
|
||||
case "status":
|
||||
values = []string{"pending", "completed", "deleted", "recurring"}
|
||||
case "priority":
|
||||
values = []string{"H", "M", "L"}
|
||||
case "project":
|
||||
projects, err := engine.GetAllProjects()
|
||||
if err == nil {
|
||||
values = projects
|
||||
}
|
||||
case "due", "wait", "scheduled", "until":
|
||||
values = []string{
|
||||
"today", "tomorrow", "yesterday", "now",
|
||||
"eod", "sow", "eow", "som", "eom",
|
||||
"mon", "tue", "wed", "thu", "fri", "sat", "sun",
|
||||
}
|
||||
case "recur":
|
||||
values = []string{"daily", "weekly", "monthly", "yearly", "1d", "1w", "2w", "1m", "1y"}
|
||||
}
|
||||
|
||||
completions := make([]string, 0, len(values))
|
||||
for _, v := range values {
|
||||
completions = append(completions, fmt.Sprintf("%s:%s", key, v))
|
||||
}
|
||||
return completions
|
||||
}
|
||||
|
||||
// rootValidArgsFunction provides completions for root-level arguments,
|
||||
// enabling flexible syntax like "opal 1 de<TAB>" to complete to "delete".
|
||||
func rootValidArgsFunction(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
// Delegate to taskFilterCompletion first — if toComplete is a partial
|
||||
// attribute key, it returns early with NoSpace and we should honour that.
|
||||
filterCompletions, directive := taskFilterCompletion(cmd, args, toComplete)
|
||||
|
||||
var completions []string
|
||||
|
||||
// Suggest command names
|
||||
for _, name := range commandNames {
|
||||
completions = append(completions, name)
|
||||
}
|
||||
|
||||
// Suggest report names
|
||||
for _, name := range reportNames {
|
||||
completions = append(completions, name)
|
||||
}
|
||||
|
||||
completions = append(completions, filterCompletions...)
|
||||
|
||||
return completions, directive
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Root command completions for flexible syntax (e.g., "opal 1 de<TAB>")
|
||||
rootCmd.ValidArgsFunction = rootValidArgsFunction
|
||||
|
||||
// Register dynamic completions for commands that accept filters
|
||||
addCmd.ValidArgsFunction = taskFilterCompletion
|
||||
doneCmd.ValidArgsFunction = taskFilterCompletion
|
||||
|
||||
+29
-8
@@ -8,19 +8,25 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var hardDeleteFlag bool
|
||||
|
||||
var deleteCmd = &cobra.Command{
|
||||
Use: "delete [filter...]",
|
||||
Short: "Delete tasks",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
parsed := getParsedArgs(cmd)
|
||||
if err := deleteTasks(parsed.Filters); err != nil {
|
||||
if err := deleteTasks(parsed.Filters, hardDeleteFlag); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func deleteTasks(args []string) error {
|
||||
func init() {
|
||||
deleteCmd.Flags().BoolVar(&hardDeleteFlag, "hard", false, "Permanently remove task from database")
|
||||
}
|
||||
|
||||
func deleteTasks(args []string, hard bool) error {
|
||||
filter, err := engine.ParseFilter(args)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -53,15 +59,24 @@ func deleteTasks(args []string) error {
|
||||
return fmt.Errorf("no tasks matched filter")
|
||||
}
|
||||
|
||||
action := "delete"
|
||||
if hard {
|
||||
action = "permanently delete"
|
||||
}
|
||||
|
||||
if dryRunFlag {
|
||||
fmt.Print(engine.FormatTaskConfirmList("delete", tasks, ws))
|
||||
fmt.Print(engine.FormatTaskConfirmList(action, tasks, ws))
|
||||
fmt.Println("Dry run — no changes made.")
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(tasks) > 1 {
|
||||
fmt.Print(engine.FormatTaskConfirmList("delete", tasks, ws))
|
||||
if len(tasks) > 1 || hard {
|
||||
fmt.Print(engine.FormatTaskConfirmList(action, tasks, ws))
|
||||
if hard {
|
||||
fmt.Printf("This cannot be undone. Proceed? (y/N): ")
|
||||
} else {
|
||||
fmt.Printf("Proceed? (y/N): ")
|
||||
}
|
||||
var confirm string
|
||||
fmt.Scanln(&confirm)
|
||||
if confirm != "y" && confirm != "Y" {
|
||||
@@ -71,14 +86,20 @@ func deleteTasks(args []string) error {
|
||||
}
|
||||
|
||||
for _, task := range tasks {
|
||||
task.Delete(false) // Soft delete
|
||||
task.Delete(hard)
|
||||
if !hard {
|
||||
engine.RecordUndo("delete", task.UUID)
|
||||
}
|
||||
}
|
||||
|
||||
verb := "Deleted"
|
||||
if hard {
|
||||
verb = "Permanently deleted"
|
||||
}
|
||||
if len(tasks) == 1 {
|
||||
fmt.Printf("Deleted task %s\n", engine.FormatTaskSummary(tasks[0], ws))
|
||||
fmt.Printf("%s task %s\n", verb, engine.FormatTaskSummary(tasks[0], ws))
|
||||
} else {
|
||||
fmt.Printf("Deleted %d task(s).\n", len(tasks))
|
||||
fmt.Printf("%s %d task(s).\n", verb, len(tasks))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ var (
|
||||
|
||||
// Command classification
|
||||
var commandNames = []string{
|
||||
"add", "done", "modify", "delete",
|
||||
"add", "done", "modify", "delete", "clean",
|
||||
"start", "stop", "count", "projects", "tags",
|
||||
"info", "edit", "server", "sync", "reports", "setup",
|
||||
"version", "annotate", "denotate", "undo", "uncomplete", "log", "completion",
|
||||
@@ -56,6 +56,7 @@ var rootCmd = &cobra.Command{
|
||||
Short: "Opal task manager - taskwarrior-inspired CLI task management",
|
||||
Long: `Opal is a powerful command-line task manager.
|
||||
It supports filtering, tags, priorities, projects, and recurring tasks.`,
|
||||
Args: cobra.ArbitraryArgs,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Default behavior: run configured default report (defaults to "list")
|
||||
parsed := getParsedArgs(cmd)
|
||||
@@ -87,6 +88,11 @@ func Execute() error {
|
||||
if firstArg == "-h" || firstArg == "--help" || firstArg == "help" {
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
// Let Cobra's built-in completion machinery handle shell completions
|
||||
// directly, bypassing preprocessing that would create tasks.
|
||||
if firstArg == "__complete" || firstArg == "__completeNoDesc" {
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
}
|
||||
|
||||
// Preprocess arguments (read-only scan — os.Args is never mutated)
|
||||
@@ -278,6 +284,7 @@ func init() {
|
||||
undoCmd.GroupID = "task"
|
||||
uncompleteCmd.GroupID = "task"
|
||||
logCmd.GroupID = "task"
|
||||
cleanCmd.GroupID = "task"
|
||||
|
||||
rootCmd.AddCommand(addCmd)
|
||||
rootCmd.AddCommand(doneCmd)
|
||||
@@ -292,6 +299,7 @@ func init() {
|
||||
rootCmd.AddCommand(undoCmd)
|
||||
rootCmd.AddCommand(uncompleteCmd)
|
||||
rootCmd.AddCommand(logCmd)
|
||||
rootCmd.AddCommand(cleanCmd)
|
||||
|
||||
// Other commands
|
||||
countCmd.GroupID = "other"
|
||||
|
||||
@@ -130,35 +130,35 @@ func CreateTask(w http.ResponseWriter, r *http.Request) {
|
||||
mod.AddTags = req.Tags
|
||||
|
||||
if req.Project != nil {
|
||||
mod.SetAttributes["project"] = req.Project
|
||||
mod.Set("project", req.Project)
|
||||
}
|
||||
|
||||
if req.Priority != nil {
|
||||
mod.SetAttributes["priority"] = req.Priority
|
||||
mod.Set("priority", req.Priority)
|
||||
}
|
||||
|
||||
if req.Due != nil {
|
||||
dueStr := fmt.Sprintf("%d", *req.Due)
|
||||
mod.SetAttributes["due"] = &dueStr
|
||||
mod.Set("due", &dueStr)
|
||||
}
|
||||
|
||||
if req.Scheduled != nil {
|
||||
scheduledStr := fmt.Sprintf("%d", *req.Scheduled)
|
||||
mod.SetAttributes["scheduled"] = &scheduledStr
|
||||
mod.Set("scheduled", &scheduledStr)
|
||||
}
|
||||
|
||||
if req.Wait != nil {
|
||||
waitStr := fmt.Sprintf("%d", *req.Wait)
|
||||
mod.SetAttributes["wait"] = &waitStr
|
||||
mod.Set("wait", &waitStr)
|
||||
}
|
||||
|
||||
if req.Until != nil {
|
||||
untilStr := fmt.Sprintf("%d", *req.Until)
|
||||
mod.SetAttributes["until"] = &untilStr
|
||||
mod.Set("until", &untilStr)
|
||||
}
|
||||
|
||||
if req.Recurrence != nil {
|
||||
mod.SetAttributes["recurrence"] = req.Recurrence
|
||||
mod.Set("recur", req.Recurrence)
|
||||
}
|
||||
|
||||
// Create task
|
||||
@@ -232,39 +232,39 @@ func UpdateTask(w http.ResponseWriter, r *http.Request) {
|
||||
mod := engine.NewModifier()
|
||||
|
||||
if req.Description != nil {
|
||||
mod.SetAttributes["description"] = req.Description
|
||||
mod.Set("description", req.Description)
|
||||
}
|
||||
|
||||
if req.Status != nil {
|
||||
mod.SetAttributes["status"] = req.Status
|
||||
mod.Set("status", req.Status)
|
||||
}
|
||||
|
||||
if req.Priority != nil {
|
||||
mod.SetAttributes["priority"] = req.Priority
|
||||
mod.Set("priority", req.Priority)
|
||||
}
|
||||
|
||||
if req.Project != nil {
|
||||
mod.SetAttributes["project"] = req.Project
|
||||
mod.Set("project", req.Project)
|
||||
}
|
||||
|
||||
if req.Due != nil {
|
||||
dueStr := fmt.Sprintf("%d", *req.Due)
|
||||
mod.SetAttributes["due"] = &dueStr
|
||||
mod.Set("due", &dueStr)
|
||||
}
|
||||
|
||||
if req.Scheduled != nil {
|
||||
scheduledStr := fmt.Sprintf("%d", *req.Scheduled)
|
||||
mod.SetAttributes["scheduled"] = &scheduledStr
|
||||
mod.Set("scheduled", &scheduledStr)
|
||||
}
|
||||
|
||||
if req.Wait != nil {
|
||||
waitStr := fmt.Sprintf("%d", *req.Wait)
|
||||
mod.SetAttributes["wait"] = &waitStr
|
||||
mod.Set("wait", &waitStr)
|
||||
}
|
||||
|
||||
if req.Until != nil {
|
||||
untilStr := fmt.Sprintf("%d", *req.Until)
|
||||
mod.SetAttributes["until"] = &untilStr
|
||||
mod.Set("until", &untilStr)
|
||||
}
|
||||
|
||||
if req.Start != nil {
|
||||
@@ -273,7 +273,7 @@ func UpdateTask(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if req.Recurrence != nil {
|
||||
mod.SetAttributes["recurrence"] = req.Recurrence
|
||||
mod.Set("recur", req.Recurrence)
|
||||
}
|
||||
|
||||
// Apply modifier
|
||||
|
||||
@@ -4,6 +4,7 @@ package engine
|
||||
// Used by parseAddArgs (cmd/add.go), ParseFilter, and ParseModifier
|
||||
// to distinguish modifiers from description text.
|
||||
var ValidAttributeKeys = map[string]bool{
|
||||
"description": true,
|
||||
"due": true,
|
||||
"priority": true,
|
||||
"project": true,
|
||||
|
||||
@@ -23,6 +23,13 @@ func NewModifier() *Modifier {
|
||||
}
|
||||
}
|
||||
|
||||
// Set adds an attribute to the modifier, maintaining the SetAttributes and
|
||||
// AttributeOrder invariant. Pass nil to clear the attribute.
|
||||
func (m *Modifier) Set(key string, value *string) {
|
||||
m.SetAttributes[key] = value
|
||||
m.AttributeOrder = append(m.AttributeOrder, key)
|
||||
}
|
||||
|
||||
// ParseModifier parses command-line args into Modifier.
|
||||
// Only recognized attribute keys (ValidAttributeKeys) are accepted;
|
||||
// unrecognized key:value tokens produce an error.
|
||||
@@ -86,6 +93,14 @@ func (m *Modifier) Apply(task *Task) error {
|
||||
resolvedDates["created"] = task.Created
|
||||
resolvedDates["modified"] = task.Modified
|
||||
|
||||
// Safety net: if SetAttributes were populated without AttributeOrder,
|
||||
// reconstruct order from map keys so updates aren't silently dropped.
|
||||
if len(m.AttributeOrder) == 0 && len(m.SetAttributes) > 0 {
|
||||
for key := range m.SetAttributes {
|
||||
m.AttributeOrder = append(m.AttributeOrder, key)
|
||||
}
|
||||
}
|
||||
|
||||
// Apply attributes in the order they were specified (important for relative references)
|
||||
dateKeys := DateKeys
|
||||
|
||||
@@ -134,6 +149,14 @@ func (m *Modifier) ApplyToNew(task *Task) error {
|
||||
resolvedDates["created"] = task.Created
|
||||
}
|
||||
|
||||
// Safety net: if SetAttributes were populated without AttributeOrder,
|
||||
// reconstruct order from map keys so updates aren't silently dropped.
|
||||
if len(m.AttributeOrder) == 0 && len(m.SetAttributes) > 0 {
|
||||
for key := range m.SetAttributes {
|
||||
m.AttributeOrder = append(m.AttributeOrder, key)
|
||||
}
|
||||
}
|
||||
|
||||
// Apply attributes in the order they were specified (important for relative references)
|
||||
dateKeys := DateKeys
|
||||
|
||||
@@ -156,9 +179,17 @@ func (m *Modifier) ApplyToNew(task *Task) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// applyNonDateAttribute applies a non-date attribute (priority, project, recur) to a task.
|
||||
// applyNonDateAttribute applies a non-date attribute to a task.
|
||||
func applyNonDateAttribute(key string, valuePtr *string, task *Task) error {
|
||||
switch key {
|
||||
case "description":
|
||||
if valuePtr != nil {
|
||||
task.Description = *valuePtr
|
||||
}
|
||||
case "status":
|
||||
if valuePtr != nil && len(*valuePtr) > 0 {
|
||||
task.Status = Status((*valuePtr)[0])
|
||||
}
|
||||
case "priority":
|
||||
if valuePtr == nil {
|
||||
task.Priority = PriorityDefault
|
||||
|
||||
@@ -736,6 +736,48 @@ func (t *Task) IsRecurringInstance() bool {
|
||||
return t.ParentUUID != nil
|
||||
}
|
||||
|
||||
// GetDeletedTasks retrieves soft-deleted tasks, optionally filtered by age.
|
||||
// If olderThan is non-nil, only returns tasks deleted more than that duration ago.
|
||||
func GetDeletedTasks(olderThan *time.Duration) ([]*Task, error) {
|
||||
db := GetDB()
|
||||
if db == nil {
|
||||
return nil, fmt.Errorf("database not initialized")
|
||||
}
|
||||
|
||||
query := `
|
||||
SELECT id, uuid, status, description, project, priority,
|
||||
created, modified, start, end, due, scheduled, wait, until_date,
|
||||
recurrence_duration, parent_uuid, annotations
|
||||
FROM tasks
|
||||
WHERE status = ?`
|
||||
args := []interface{}{byte(StatusDeleted)}
|
||||
|
||||
if olderThan != nil {
|
||||
cutoff := timeNow().Add(-*olderThan).Unix()
|
||||
query += ` AND end < ?`
|
||||
args = append(args, cutoff)
|
||||
}
|
||||
|
||||
query += ` ORDER BY end ASC`
|
||||
|
||||
rows, err := db.Query(query, args...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to query deleted tasks: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var tasks []*Task
|
||||
for rows.Next() {
|
||||
task, err := scanTask(rows)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to scan task: %w", err)
|
||||
}
|
||||
tasks = append(tasks, task)
|
||||
}
|
||||
|
||||
return tasks, nil
|
||||
}
|
||||
|
||||
// PopulateUrgency computes and sets the Urgency field on the given tasks.
|
||||
func PopulateUrgency(tasks ...*Task) {
|
||||
cfg, _ := GetConfig()
|
||||
|
||||
@@ -402,6 +402,12 @@
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events a11y-no-static-element-interactions -->
|
||||
<div class="field-row editable" on:click={() => startEdit('scheduled')}>
|
||||
<span class="field-label">Scheduled</span>
|
||||
<span class="field-value clickable">Set...</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Wait -->
|
||||
@@ -425,6 +431,12 @@
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events a11y-no-static-element-interactions -->
|
||||
<div class="field-row editable" on:click={() => startEdit('wait')}>
|
||||
<span class="field-label">Wait</span>
|
||||
<span class="field-value clickable">Set...</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Until -->
|
||||
@@ -448,6 +460,12 @@
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events a11y-no-static-element-interactions -->
|
||||
<div class="field-row editable" on:click={() => startEdit('until')}>
|
||||
<span class="field-label">Until</span>
|
||||
<span class="field-value clickable">Set...</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Active since -->
|
||||
|
||||
@@ -37,6 +37,11 @@
|
||||
// Subscribe to store
|
||||
const unsubscribe = tasksStore.subscribe(value => {
|
||||
tasks = value;
|
||||
// Keep selectedTask in sync with store changes
|
||||
if (selectedTask) {
|
||||
const updated = value.find(t => t.uuid === selectedTask.uuid);
|
||||
if (updated) selectedTask = updated;
|
||||
}
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
@@ -197,10 +202,6 @@
|
||||
async function handleUpdate(uuid, updates) {
|
||||
try {
|
||||
await tasksStore.updateTask(uuid, updates);
|
||||
// Keep selectedTask fresh
|
||||
if (selectedTask?.uuid === uuid) {
|
||||
selectedTask = { ...selectedTask, ...updates };
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to update task:', error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user