feat(prime): add the action kind to the settings viewmodels
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Globalization;
|
||||
using ClaudeDo.Data.Models;
|
||||
using ClaudeDo.Ui.Localization;
|
||||
using ClaudeDo.Ui.Services;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
@@ -22,6 +24,7 @@ public sealed partial class PrimeScheduleRowViewModel : ViewModelBase
|
||||
[ObservableProperty] private TimeSpan _timeOfDay;
|
||||
[ObservableProperty] private DateTimeOffset? _lastRunAt;
|
||||
[ObservableProperty] private string? _promptOverride;
|
||||
[ObservableProperty] private PrimeActionKind _kind;
|
||||
|
||||
public string LastRunLabel => LastRunAt is { } v ? v.LocalDateTime.ToString("g") : "—";
|
||||
|
||||
@@ -41,6 +44,50 @@ public sealed partial class PrimeScheduleRowViewModel : ViewModelBase
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Per-row group name. A shared GroupName would make every schedule in the
|
||||
/// ItemsControl share one selection.</summary>
|
||||
public string RadioGroup => $"prime-kind-{Id}";
|
||||
|
||||
// Three booleans rather than an enum-to-bool converter: RadioButton.IsChecked binds
|
||||
// TwoWay to a bool, and compiled bindings stay simple.
|
||||
public bool IsPing
|
||||
{
|
||||
get => Kind == PrimeActionKind.Ping;
|
||||
set { if (value) Kind = PrimeActionKind.Ping; }
|
||||
}
|
||||
|
||||
public bool IsFillMyDay
|
||||
{
|
||||
get => Kind == PrimeActionKind.FillMyDay;
|
||||
set { if (value) Kind = PrimeActionKind.FillMyDay; }
|
||||
}
|
||||
|
||||
public bool IsCustom
|
||||
{
|
||||
get => Kind == PrimeActionKind.Custom;
|
||||
set { if (value) Kind = PrimeActionKind.Custom; }
|
||||
}
|
||||
|
||||
public bool ShowPrompt => Kind != PrimeActionKind.Ping;
|
||||
|
||||
public string PromptLabel => Kind == PrimeActionKind.Custom
|
||||
? Loc.T("settings.prime.customPromptLabel")
|
||||
: Loc.T("settings.prime.promptOverrideLabel");
|
||||
|
||||
public string PromptPlaceholder => Kind == PrimeActionKind.Custom
|
||||
? Loc.T("settings.prime.customPromptPlaceholder")
|
||||
: Loc.T("settings.prime.promptOverridePlaceholder");
|
||||
|
||||
partial void OnKindChanged(PrimeActionKind value)
|
||||
{
|
||||
OnPropertyChanged(nameof(IsPing));
|
||||
OnPropertyChanged(nameof(IsFillMyDay));
|
||||
OnPropertyChanged(nameof(IsCustom));
|
||||
OnPropertyChanged(nameof(ShowPrompt));
|
||||
OnPropertyChanged(nameof(PromptLabel));
|
||||
OnPropertyChanged(nameof(PromptPlaceholder));
|
||||
}
|
||||
|
||||
partial void OnLastRunAtChanged(DateTimeOffset? value) => OnPropertyChanged(nameof(LastRunLabel));
|
||||
|
||||
partial void OnTimeOfDayChanged(TimeSpan value) => OnPropertyChanged(nameof(TimeText));
|
||||
@@ -60,6 +107,7 @@ public sealed partial class PrimeScheduleRowViewModel : ViewModelBase
|
||||
TimeOfDay = dto.TimeOfDay;
|
||||
LastRunAt = dto.LastRunAt;
|
||||
PromptOverride = dto.PromptOverride;
|
||||
Kind = dto.Kind;
|
||||
}
|
||||
|
||||
public int DaysMask()
|
||||
@@ -77,5 +125,5 @@ public sealed partial class PrimeScheduleRowViewModel : ViewModelBase
|
||||
|
||||
public PrimeScheduleDto ToDto() =>
|
||||
new(Id, DaysMask(), TimeOfDay, Enabled, LastRunAt,
|
||||
string.IsNullOrWhiteSpace(PromptOverride) ? null : PromptOverride);
|
||||
string.IsNullOrWhiteSpace(PromptOverride) ? null : PromptOverride, Kind);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user