Compare commits
4 Commits
33fedc7e26
...
fca2bdb596
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fca2bdb596 | ||
|
|
721f0cd903 | ||
|
|
32bb52875f | ||
|
|
4f25c3dd40 |
118
docs/superpowers/specs/2026-04-16-subtask-tree-view-design.md
Normal file
118
docs/superpowers/specs/2026-04-16-subtask-tree-view-design.md
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
# Subtask Tree View in Task List
|
||||||
|
|
||||||
|
## Problem
|
||||||
|
|
||||||
|
Subtasks are invisible in the task list — users only see them after opening the detail pane or editor modal. This makes it hard to get an overview of task progress without clicking into each task individually.
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
Show subtasks indented below their parent task in the task list, with expand/collapse. Tasks start collapsed with a visual indicator when subtasks exist.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
Pure UI/ViewModel change. No data model changes, no new migrations, no repository schema changes.
|
||||||
|
|
||||||
|
## Design
|
||||||
|
|
||||||
|
### ViewModel Changes
|
||||||
|
|
||||||
|
**TaskItemViewModel** — add:
|
||||||
|
|
||||||
|
- `ObservableCollection<SubtaskItemViewModel> Subtasks` — populated on first expand
|
||||||
|
- `bool IsExpanded` — observable, default `false`; toggles subtask visibility
|
||||||
|
- `bool HasSubtasks` — observable, set during initial load from a count query
|
||||||
|
- `int SubtaskCount` — observable, used for the indicator
|
||||||
|
- `ToggleExpandedCommand` — flips `IsExpanded`; on first expand, loads subtasks from `SubtaskRepository.GetByTaskIdAsync`
|
||||||
|
- `ToggleSubtaskDoneCommand(string subtaskId)` — toggles a subtask's `Completed` and persists via `SubtaskRepository.UpdateAsync`
|
||||||
|
|
||||||
|
Constructor gains `SubtaskRepository` and initial `subtaskCount` parameter.
|
||||||
|
|
||||||
|
**TaskListViewModel.LoadAsync** — after fetching tasks, run a single batch query to get subtask counts per task. Pass counts into each `TaskItemViewModel`. This avoids N+1 queries on load.
|
||||||
|
|
||||||
|
**TaskListViewModel.RefreshSingleAsync** — if the refreshed task's `IsExpanded` is true, also reload its subtasks from DB and update the collection.
|
||||||
|
|
||||||
|
### Repository Changes
|
||||||
|
|
||||||
|
**SubtaskRepository** — add one method:
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
Task<Dictionary<string, int>> GetCountsByTaskIdsAsync(IEnumerable<string> taskIds, CancellationToken ct = default)
|
||||||
|
```
|
||||||
|
|
||||||
|
Single query: `SELECT task_id, COUNT(*) FROM subtasks WHERE task_id IN (...) GROUP BY task_id`. Returns a map of taskId -> count. Tasks with no subtasks won't appear in the result (count defaults to 0).
|
||||||
|
|
||||||
|
### XAML Changes
|
||||||
|
|
||||||
|
**TaskListView.axaml** — the `DataTemplate` for `TaskItemViewModel` becomes a 2-row grid:
|
||||||
|
|
||||||
|
```
|
||||||
|
Row 0: [ExpandChevron] [StatusCircle] [Title + Tags/Status subtitle]
|
||||||
|
Row 1: [SubtaskItemsControl, margin-left ~40px, visible when IsExpanded]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Row 0 — Expand chevron:**
|
||||||
|
- Column 0 gets a small chevron button (12x12 `Path` data) before the status circle
|
||||||
|
- Right-pointing when collapsed, down-pointing when expanded
|
||||||
|
- Bound to `ToggleExpandedCommand`
|
||||||
|
- Only visible when `HasSubtasks` is true (via `IsVisible` binding)
|
||||||
|
- When `HasSubtasks` is false, the space is empty but reserved (fixed-width column) so all titles align
|
||||||
|
|
||||||
|
**Row 1 — Subtask list:**
|
||||||
|
- `ItemsControl` bound to `Subtasks`
|
||||||
|
- `IsVisible` bound to `IsExpanded`
|
||||||
|
- Left margin ~40px for visual indentation
|
||||||
|
- Each subtask item: `CheckBox` (bound to `Completed`) + `TextBlock` (bound to `Title`)
|
||||||
|
- Subtask row has its own context menu flyout with "Edit Task" (opens parent task's editor modal via `EditTaskCommand` on root `TaskListViewModel`)
|
||||||
|
- Checkbox toggle calls `ToggleSubtaskDoneCommand` on the parent `TaskItemViewModel`
|
||||||
|
|
||||||
|
**Column layout change:** The existing 2-column `Grid` (`Auto, *`) gets a third column prepended: `Auto, Auto, *`. The chevron goes in column 0, status circle in column 1, title stack in column 2. Row 1 spans all 3 columns.
|
||||||
|
|
||||||
|
### Subtask Checkbox Interaction
|
||||||
|
|
||||||
|
When a subtask checkbox is toggled in the list:
|
||||||
|
1. Update the `SubtaskItemViewModel.Completed` property
|
||||||
|
2. Call `SubtaskRepository.UpdateAsync` with the updated entity (same auto-save pattern as `TaskDetailView`)
|
||||||
|
3. No need to refresh the parent task — subtask completion doesn't affect task status
|
||||||
|
|
||||||
|
### Subtask Context Menu
|
||||||
|
|
||||||
|
Right-click on a subtask row shows:
|
||||||
|
- "Edit Task" — opens the parent task's editor modal (same flow as `EditTaskCommand`)
|
||||||
|
|
||||||
|
This reuses the existing editor which already has full subtask editing (add/remove/reorder/rename).
|
||||||
|
|
||||||
|
### Real-time Updates
|
||||||
|
|
||||||
|
When `RefreshSingleAsync` fires (via SignalR `TaskUpdatedEvent`):
|
||||||
|
1. Reload subtask count, update `HasSubtasks` and `SubtaskCount`
|
||||||
|
2. If `IsExpanded`, reload subtask list from DB and reconcile with the observable collection
|
||||||
|
|
||||||
|
### Detail Pane Sync
|
||||||
|
|
||||||
|
When the user edits subtasks in `TaskDetailView` (auto-save) or `TaskEditorView` (batch-save), the list view's subtask state may become stale. Two options:
|
||||||
|
|
||||||
|
**Chosen approach:** The detail pane and editor already trigger `TaskUpdatedEvent` (or the editor's save path calls `RefreshSingleAsync` via `SelectedTask.Refresh`). Extend `Refresh` on `TaskItemViewModel` to also reload subtasks if expanded, and update `HasSubtasks`/`SubtaskCount`.
|
||||||
|
|
||||||
|
### Visual Style
|
||||||
|
|
||||||
|
- Chevron: 10x10 path, `TextDimBrush` color, no background, cursor=Hand
|
||||||
|
- Subtask rows: smaller font (12px), `TextDimBrush` for unchecked title, strikethrough + dimmed for completed
|
||||||
|
- Subtask checkbox: standard Avalonia `CheckBox` (no custom circular border), small size
|
||||||
|
- Subtask row vertical padding: 2px (compact)
|
||||||
|
- Indent: 40px left margin on the subtask `ItemsControl`
|
||||||
|
|
||||||
|
## Files to Modify
|
||||||
|
|
||||||
|
1. `src/ClaudeDo.Data/Repositories/SubtaskRepository.cs` — add `GetCountsByTaskIdsAsync`
|
||||||
|
2. `src/ClaudeDo.Ui/ViewModels/TaskItemViewModel.cs` — add subtask collection, expand/collapse, toggle done
|
||||||
|
3. `src/ClaudeDo.Ui/ViewModels/TaskListViewModel.cs` — batch-load counts, pass SubtaskRepository, extend refresh
|
||||||
|
4. `src/ClaudeDo.Ui/Views/TaskListView.axaml` — restructure item template with chevron + nested ItemsControl
|
||||||
|
5. `src/ClaudeDo.Ui/Views/TaskListView.axaml.cs` — handle subtask context menu pointer-pressed if needed
|
||||||
|
6. `src/ClaudeDo.App/Program.cs` — pass SubtaskRepository to TaskListViewModel (if not already available via DI)
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
|
||||||
|
- Drag-to-reorder subtasks in the list view
|
||||||
|
- Add subtask directly from the list view
|
||||||
|
- Subtask progress indicator (e.g., "2/5 done") on collapsed tasks
|
||||||
|
- Recursive task nesting (tasks containing tasks)
|
||||||
@@ -8,14 +8,21 @@ using ClaudeDo.Ui.ViewModels;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace ClaudeDo.App;
|
namespace ClaudeDo.App;
|
||||||
|
|
||||||
sealed class Program
|
sealed class Program
|
||||||
{
|
{
|
||||||
|
[DllImport("shell32.dll", CharSet = CharSet.Unicode)]
|
||||||
|
private static extern int SetCurrentProcessExplicitAppUserModelID(string appId);
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
SetCurrentProcessExplicitAppUserModelID("ClaudeDo.App");
|
||||||
|
|
||||||
var services = BuildServices();
|
var services = BuildServices();
|
||||||
App.Services = services;
|
App.Services = services;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
using ClaudeDo.Data;
|
||||||
using ClaudeDo.Data.Models;
|
using ClaudeDo.Data.Models;
|
||||||
|
using ClaudeDo.Data.Repositories;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using TaskStatus = ClaudeDo.Data.Models.TaskStatus;
|
using TaskStatus = ClaudeDo.Data.Models.TaskStatus;
|
||||||
|
|
||||||
namespace ClaudeDo.Ui.ViewModels;
|
namespace ClaudeDo.Ui.ViewModels;
|
||||||
@@ -15,6 +19,11 @@ public partial class TaskItemViewModel : ViewModelBase
|
|||||||
[ObservableProperty] private string? _description;
|
[ObservableProperty] private string? _description;
|
||||||
[ObservableProperty] private TaskStatus _status;
|
[ObservableProperty] private TaskStatus _status;
|
||||||
[ObservableProperty] private bool _isStarting;
|
[ObservableProperty] private bool _isStarting;
|
||||||
|
[ObservableProperty] private bool _isExpanded;
|
||||||
|
[ObservableProperty] private bool _hasSubtasks;
|
||||||
|
[ObservableProperty] private int _subtaskCount;
|
||||||
|
|
||||||
|
public ObservableCollection<SubtaskItemViewModel> Subtasks { get; } = new();
|
||||||
|
|
||||||
public string Id { get; }
|
public string Id { get; }
|
||||||
public string ListId { get; }
|
public string ListId { get; }
|
||||||
@@ -23,9 +32,13 @@ public partial class TaskItemViewModel : ViewModelBase
|
|||||||
private readonly Func<string, Task>? _runNow;
|
private readonly Func<string, Task>? _runNow;
|
||||||
private readonly Func<bool> _canRunNow;
|
private readonly Func<bool> _canRunNow;
|
||||||
private readonly Func<string, Task>? _toggleDone;
|
private readonly Func<string, Task>? _toggleDone;
|
||||||
|
private readonly IDbContextFactory<ClaudeDoDbContext> _dbFactory;
|
||||||
|
private bool _subtasksLoaded;
|
||||||
|
|
||||||
public TaskItemViewModel(TaskEntity entity, IReadOnlyList<TagEntity> tags,
|
public TaskItemViewModel(TaskEntity entity, IReadOnlyList<TagEntity> tags,
|
||||||
Func<string, Task>? runNow, Func<bool> canRunNow, Func<string, Task>? toggleDone = null)
|
Func<string, Task>? runNow, Func<bool> canRunNow,
|
||||||
|
IDbContextFactory<ClaudeDoDbContext> dbFactory, int subtaskCount,
|
||||||
|
Func<string, Task>? toggleDone = null)
|
||||||
{
|
{
|
||||||
Entity = entity;
|
Entity = entity;
|
||||||
Id = entity.Id;
|
Id = entity.Id;
|
||||||
@@ -39,6 +52,9 @@ public partial class TaskItemViewModel : ViewModelBase
|
|||||||
_runNow = runNow;
|
_runNow = runNow;
|
||||||
_canRunNow = canRunNow;
|
_canRunNow = canRunNow;
|
||||||
_toggleDone = toggleDone;
|
_toggleDone = toggleDone;
|
||||||
|
_dbFactory = dbFactory;
|
||||||
|
_subtaskCount = subtaskCount;
|
||||||
|
_hasSubtasks = subtaskCount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsDone => Status == TaskStatus.Done;
|
public bool IsDone => Status == TaskStatus.Done;
|
||||||
@@ -104,4 +120,55 @@ public partial class TaskItemViewModel : ViewModelBase
|
|||||||
if (_toggleDone is not null)
|
if (_toggleDone is not null)
|
||||||
await _toggleDone(Id);
|
await _toggleDone(Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task ToggleExpanded()
|
||||||
|
{
|
||||||
|
IsExpanded = !IsExpanded;
|
||||||
|
if (IsExpanded && !_subtasksLoaded)
|
||||||
|
await LoadSubtasksAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadSubtasksAsync()
|
||||||
|
{
|
||||||
|
using var context = _dbFactory.CreateDbContext();
|
||||||
|
var repo = new SubtaskRepository(context);
|
||||||
|
var entities = await repo.GetByTaskIdAsync(Id);
|
||||||
|
Subtasks.Clear();
|
||||||
|
foreach (var e in entities)
|
||||||
|
Subtasks.Add(SubtaskItemViewModel.From(e));
|
||||||
|
_subtasksLoaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task ToggleSubtaskDone(string subtaskId)
|
||||||
|
{
|
||||||
|
var vm = Subtasks.FirstOrDefault(s => s.Id == subtaskId);
|
||||||
|
if (vm is null) return;
|
||||||
|
vm.Completed = !vm.Completed;
|
||||||
|
|
||||||
|
using var context = _dbFactory.CreateDbContext();
|
||||||
|
var entity = await context.Subtasks.FindAsync(subtaskId);
|
||||||
|
if (entity is not null)
|
||||||
|
{
|
||||||
|
entity.Completed = vm.Completed;
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task RefreshSubtasksAsync(int newCount)
|
||||||
|
{
|
||||||
|
SubtaskCount = newCount;
|
||||||
|
HasSubtasks = newCount > 0;
|
||||||
|
if (!HasSubtasks)
|
||||||
|
{
|
||||||
|
IsExpanded = false;
|
||||||
|
Subtasks.Clear();
|
||||||
|
_subtasksLoaded = false;
|
||||||
|
}
|
||||||
|
else if (_subtasksLoaded || IsExpanded)
|
||||||
|
{
|
||||||
|
await LoadSubtasksAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,10 +91,17 @@ public partial class TaskListViewModel : ViewModelBase
|
|||||||
using var context = _dbFactory.CreateDbContext();
|
using var context = _dbFactory.CreateDbContext();
|
||||||
var taskRepo = new TaskRepository(context);
|
var taskRepo = new TaskRepository(context);
|
||||||
var entities = await taskRepo.GetByListIdAsync(listId);
|
var entities = await taskRepo.GetByListIdAsync(listId);
|
||||||
|
var taskIds = entities.Select(e => e.Id).ToList();
|
||||||
|
var subtaskCounts = await context.Subtasks
|
||||||
|
.Where(s => taskIds.Contains(s.TaskId))
|
||||||
|
.GroupBy(s => s.TaskId)
|
||||||
|
.ToDictionaryAsync(g => g.Key, g => g.Count());
|
||||||
foreach (var e in entities)
|
foreach (var e in entities)
|
||||||
{
|
{
|
||||||
var tags = await taskRepo.GetEffectiveTagsAsync(e.Id);
|
var tags = await taskRepo.GetEffectiveTagsAsync(e.Id);
|
||||||
Tasks.Add(new TaskItemViewModel(e, tags, RunNowAsync, () => _worker.IsConnected, ToggleDoneAsync));
|
subtaskCounts.TryGetValue(e.Id, out var count);
|
||||||
|
Tasks.Add(new TaskItemViewModel(e, tags, RunNowAsync, () => _worker.IsConnected,
|
||||||
|
_dbFactory, count, ToggleDoneAsync));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -135,7 +142,8 @@ public partial class TaskListViewModel : ViewModelBase
|
|||||||
var taskRepo = new TaskRepository(context);
|
var taskRepo = new TaskRepository(context);
|
||||||
await taskRepo.AddAsync(entity);
|
await taskRepo.AddAsync(entity);
|
||||||
var tags = await taskRepo.GetEffectiveTagsAsync(entity.Id);
|
var tags = await taskRepo.GetEffectiveTagsAsync(entity.Id);
|
||||||
var vm = new TaskItemViewModel(entity, tags, RunNowAsync, () => _worker.IsConnected, ToggleDoneAsync);
|
var vm = new TaskItemViewModel(entity, tags, RunNowAsync, () => _worker.IsConnected,
|
||||||
|
_dbFactory, 0, ToggleDoneAsync);
|
||||||
Tasks.Add(vm);
|
Tasks.Add(vm);
|
||||||
SelectedTask = vm;
|
SelectedTask = vm;
|
||||||
InlineAddTitle = "";
|
InlineAddTitle = "";
|
||||||
@@ -183,7 +191,8 @@ public partial class TaskListViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tags = await taskRepo.GetEffectiveTagsAsync(saved.Id);
|
var tags = await taskRepo.GetEffectiveTagsAsync(saved.Id);
|
||||||
Tasks.Add(new TaskItemViewModel(saved, tags, RunNowAsync, () => _worker.IsConnected, ToggleDoneAsync));
|
Tasks.Add(new TaskItemViewModel(saved, tags, RunNowAsync, () => _worker.IsConnected,
|
||||||
|
_dbFactory, 0, ToggleDoneAsync));
|
||||||
|
|
||||||
// Auto wake-queue if agent+queued
|
// Auto wake-queue if agent+queued
|
||||||
if (saved.Status == TaskStatus.Queued &&
|
if (saved.Status == TaskStatus.Queued &&
|
||||||
@@ -282,7 +291,11 @@ public partial class TaskListViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
var tags = await taskRepo.GetEffectiveTagsAsync(taskId);
|
var tags = await taskRepo.GetEffectiveTagsAsync(taskId);
|
||||||
if (existing is not null)
|
if (existing is not null)
|
||||||
|
{
|
||||||
existing.Refresh(entity, tags);
|
existing.Refresh(entity, tags);
|
||||||
|
var subtaskCount = await context.Subtasks.CountAsync(s => s.TaskId == taskId);
|
||||||
|
await existing.RefreshSubtasksAsync(subtaskCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RunNowAsync(string taskId)
|
private async Task RunNowAsync(string taskId)
|
||||||
|
|||||||
@@ -31,9 +31,11 @@
|
|||||||
KeyDown="OnTaskListKeyDown">
|
KeyDown="OnTaskListKeyDown">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate x:DataType="vm:TaskItemViewModel">
|
<DataTemplate x:DataType="vm:TaskItemViewModel">
|
||||||
<Grid ColumnDefinitions="Auto,*" Margin="4,4"
|
<Grid RowDefinitions="Auto,Auto"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
Opacity="{Binding RowOpacity}"
|
Opacity="{Binding RowOpacity}">
|
||||||
|
<!-- Row 0: Task row -->
|
||||||
|
<Grid Grid.Row="0" ColumnDefinitions="20,Auto,*" Margin="4,4"
|
||||||
DoubleTapped="OnTaskItemDoubleTapped"
|
DoubleTapped="OnTaskItemDoubleTapped"
|
||||||
PointerPressed="OnTaskItemPointerPressed">
|
PointerPressed="OnTaskItemPointerPressed">
|
||||||
<Grid.ContextFlyout>
|
<Grid.ContextFlyout>
|
||||||
@@ -48,8 +50,32 @@
|
|||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
</Grid.ContextFlyout>
|
</Grid.ContextFlyout>
|
||||||
|
|
||||||
|
<!-- Expand/collapse chevron -->
|
||||||
|
<Button Grid.Column="0"
|
||||||
|
Command="{Binding ToggleExpandedCommand}"
|
||||||
|
IsVisible="{Binding HasSubtasks}"
|
||||||
|
Background="Transparent"
|
||||||
|
BorderThickness="0"
|
||||||
|
Padding="0"
|
||||||
|
Width="16" Height="16"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Cursor="Hand">
|
||||||
|
<Panel>
|
||||||
|
<Canvas Width="10" Height="10"
|
||||||
|
IsVisible="{Binding !IsExpanded}">
|
||||||
|
<Path Stroke="{StaticResource TextDimBrush}" StrokeThickness="1.5"
|
||||||
|
Data="M 2,0 L 8,5 L 2,10"/>
|
||||||
|
</Canvas>
|
||||||
|
<Canvas Width="10" Height="10"
|
||||||
|
IsVisible="{Binding IsExpanded}">
|
||||||
|
<Path Stroke="{StaticResource TextDimBrush}" StrokeThickness="1.5"
|
||||||
|
Data="M 0,2 L 5,8 L 10,2"/>
|
||||||
|
</Canvas>
|
||||||
|
</Panel>
|
||||||
|
</Button>
|
||||||
|
|
||||||
<!-- Circular checkbox -->
|
<!-- Circular checkbox -->
|
||||||
<Border Grid.Column="0" Width="22" Height="22"
|
<Border Grid.Column="1" Width="22" Height="22"
|
||||||
CornerRadius="11"
|
CornerRadius="11"
|
||||||
BorderThickness="2"
|
BorderThickness="2"
|
||||||
BorderBrush="{Binding StatusText, Converter={x:Static conv:CheckboxBorderConverter.Instance}}"
|
BorderBrush="{Binding StatusText, Converter={x:Static conv:CheckboxBorderConverter.Instance}}"
|
||||||
@@ -58,19 +84,16 @@
|
|||||||
Cursor="Hand"
|
Cursor="Hand"
|
||||||
PointerPressed="OnCheckboxPressed">
|
PointerPressed="OnCheckboxPressed">
|
||||||
<Panel>
|
<Panel>
|
||||||
<!-- Checkmark for done -->
|
|
||||||
<Canvas Width="12" Height="12"
|
<Canvas Width="12" Height="12"
|
||||||
IsVisible="{Binding IsDone}"
|
IsVisible="{Binding IsDone}"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center">
|
HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
<Path Stroke="{StaticResource StatusGreenBrush}" StrokeThickness="2"
|
<Path Stroke="{StaticResource StatusGreenBrush}" StrokeThickness="2"
|
||||||
Data="M 1,6 L 4.5,9.5 L 11,3"/>
|
Data="M 1,6 L 4.5,9.5 L 11,3"/>
|
||||||
</Canvas>
|
</Canvas>
|
||||||
<!-- Running dot -->
|
|
||||||
<Ellipse Width="8" Height="8"
|
<Ellipse Width="8" Height="8"
|
||||||
Fill="{StaticResource StatusOrangeBrush}"
|
Fill="{StaticResource StatusOrangeBrush}"
|
||||||
IsVisible="{Binding IsRunning}"
|
IsVisible="{Binding IsRunning}"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
<!-- Starting dot -->
|
|
||||||
<Ellipse Width="8" Height="8" Fill="#FFD700"
|
<Ellipse Width="8" Height="8" Fill="#FFD700"
|
||||||
IsVisible="{Binding IsStarting}"
|
IsVisible="{Binding IsStarting}"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
@@ -78,7 +101,7 @@
|
|||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- Task content -->
|
<!-- Task content -->
|
||||||
<StackPanel Grid.Column="1" VerticalAlignment="Center">
|
<StackPanel Grid.Column="2" VerticalAlignment="Center">
|
||||||
<TextBlock Text="{Binding Title}" FontWeight="Medium"
|
<TextBlock Text="{Binding Title}" FontWeight="Medium"
|
||||||
Foreground="{Binding TitleForeground}"
|
Foreground="{Binding TitleForeground}"
|
||||||
TextDecorations="{Binding TitleDecorations}"
|
TextDecorations="{Binding TitleDecorations}"
|
||||||
@@ -98,6 +121,39 @@
|
|||||||
IsVisible="{Binding TagsText, Converter={x:Static StringConverters.IsNullOrEmpty}}"/>
|
IsVisible="{Binding TagsText, Converter={x:Static StringConverters.IsNullOrEmpty}}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Row 1: Subtask list (visible when expanded) -->
|
||||||
|
<ItemsControl Grid.Row="1"
|
||||||
|
ItemsSource="{Binding Subtasks}"
|
||||||
|
IsVisible="{Binding IsExpanded}"
|
||||||
|
Margin="40,0,0,4">
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="vm:SubtaskItemViewModel">
|
||||||
|
<Grid ColumnDefinitions="Auto,*" Margin="0,2"
|
||||||
|
PointerPressed="OnSubtaskPointerPressed">
|
||||||
|
<Grid.ContextFlyout>
|
||||||
|
<MenuFlyout>
|
||||||
|
<MenuItem Header="Edit Task"
|
||||||
|
Command="{Binding #Root.((vm:TaskListViewModel)DataContext).EditTaskCommand}"/>
|
||||||
|
</MenuFlyout>
|
||||||
|
</Grid.ContextFlyout>
|
||||||
|
<CheckBox Grid.Column="0"
|
||||||
|
IsChecked="{Binding Completed, Mode=OneWay}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="0,0,6,0"
|
||||||
|
MinWidth="0"
|
||||||
|
Click="OnSubtaskCheckboxClick"/>
|
||||||
|
<TextBlock Grid.Column="1"
|
||||||
|
Text="{Binding Title}"
|
||||||
|
FontSize="12"
|
||||||
|
Foreground="{StaticResource TextDimBrush}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
TextTrimming="CharacterEllipsis"/>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
@@ -97,6 +98,29 @@ public partial class TaskListView : UserControl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnSubtaskPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.GetCurrentPoint(null).Properties.IsRightButtonPressed
|
||||||
|
&& sender is Control { DataContext: SubtaskItemViewModel subtask }
|
||||||
|
&& DataContext is TaskListViewModel vm)
|
||||||
|
{
|
||||||
|
var parent = vm.Tasks.FirstOrDefault(t => t.Subtasks.Contains(subtask));
|
||||||
|
if (parent is not null)
|
||||||
|
vm.SelectedTask = parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnSubtaskCheckboxClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is CheckBox { DataContext: SubtaskItemViewModel subtask }
|
||||||
|
&& DataContext is TaskListViewModel vm)
|
||||||
|
{
|
||||||
|
var parent = vm.Tasks.FirstOrDefault(t => t.Subtasks.Contains(subtask));
|
||||||
|
if (parent is not null)
|
||||||
|
await parent.ToggleSubtaskDoneCommand.ExecuteAsync(subtask.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void FocusInlineAdd()
|
public void FocusInlineAdd()
|
||||||
{
|
{
|
||||||
this.FindControl<TextBox>("InlineAddBox")?.Focus();
|
this.FindControl<TextBox>("InlineAddBox")?.Focus();
|
||||||
|
|||||||
Reference in New Issue
Block a user