From 0796b3c2d577370a55b38d4f6e3610bfd1272eb1 Mon Sep 17 00:00:00 2001 From: Mika Kuns Date: Tue, 14 Apr 2026 10:21:47 +0200 Subject: [PATCH] feat(ui): add ToggleDone command and checkbox state to TaskItemViewModel --- .../ViewModels/TaskItemViewModel.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ClaudeDo.Ui/ViewModels/TaskItemViewModel.cs b/src/ClaudeDo.Ui/ViewModels/TaskItemViewModel.cs index bf4c3d7..af7ad09 100644 --- a/src/ClaudeDo.Ui/ViewModels/TaskItemViewModel.cs +++ b/src/ClaudeDo.Ui/ViewModels/TaskItemViewModel.cs @@ -20,9 +20,10 @@ public partial class TaskItemViewModel : ViewModelBase private readonly Func? _runNow; private readonly Func _canRunNow; + private readonly Func? _toggleDone; public TaskItemViewModel(TaskEntity entity, IReadOnlyList tags, - Func? runNow, Func canRunNow) + Func? runNow, Func canRunNow, Func? toggleDone = null) { Entity = entity; Id = entity.Id; @@ -35,8 +36,13 @@ public partial class TaskItemViewModel : ViewModelBase _description = entity.Description; _runNow = runNow; _canRunNow = canRunNow; + _toggleDone = toggleDone; } + public bool IsDone => Status == TaskStatus.Done; + public bool IsRunning => Status == TaskStatus.Running; + public bool CanToggleDone => Status != TaskStatus.Running && Status != TaskStatus.Failed; + public void Refresh(TaskEntity entity, IReadOnlyList tags) { Entity = entity; @@ -47,6 +53,10 @@ public partial class TaskItemViewModel : ViewModelBase CommitType = entity.CommitType; Description = entity.Description; RunNowCommand.NotifyCanExecuteChanged(); + OnPropertyChanged(nameof(IsDone)); + OnPropertyChanged(nameof(IsRunning)); + OnPropertyChanged(nameof(CanToggleDone)); + ToggleDoneCommand.NotifyCanExecuteChanged(); } [RelayCommand(CanExecute = nameof(CanRunNow))] @@ -58,4 +68,11 @@ public partial class TaskItemViewModel : ViewModelBase private bool CanRunNow() => _canRunNow() && Status == TaskStatus.Queued; + + [RelayCommand(CanExecute = nameof(CanToggleDone))] + private async Task ToggleDone() + { + if (_toggleDone is not null) + await _toggleDone(Id); + } }