fix(app): archive tree selection, toolbar, filters and dialogs after review
- reloads and expanding never clear the tree selection; only jobs on this archive reload it, once they settle - one-row toolbar with the view switch and last scan on their own row; figure tiles shrink instead of cutting at the minimum width - set filter by camera, status and tag; duplicates and orphans searches can be cancelled; health fixes cover every matching sequence - Right/Left/Enter open and close years; dialogs hold the keyboard and only close themselves; disabled commands say why - adopt folder can copy into the layout (Import screen); database backup in Maintenance; Move dialog capture state Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
9 files changed
+614
-124
No files matched your search
@@ -13,20 +13,29 @@ using Titano.Ui.Mvvm;
|
||||
|
||||
namespace Titano.App.Archiving;
|
||||
|
||||
/// <summary>An in-window dialog of the Archive screen: one primary action, one way out.</summary>
|
||||
public abstract class ArchiveDialogViewModel(Action close) : LocalizedViewModel
|
||||
/// <summary>
|
||||
/// An in-window dialog of the Archive screen: one primary action, one way out. While its action runs it cannot be
|
||||
/// closed; <paramref name="close"/> receives the dialog, so a late close never closes another one.
|
||||
/// </summary>
|
||||
public abstract class ArchiveDialogViewModel : LocalizedViewModel
|
||||
{
|
||||
private bool _isBusy;
|
||||
private string? _busyText;
|
||||
|
||||
public ICommand CloseCommand { get; } = new RelayCommand(close);
|
||||
protected ArchiveDialogViewModel(Action<ArchiveDialogViewModel> close) => CloseCommand = new RelayCommand(() => close(this), () => !IsBusy);
|
||||
|
||||
public ICommand CloseCommand { get; }
|
||||
|
||||
public string CloseToolTip => IsBusy ? Loc.L("Archive.Blocked.Applying") : Loc.L("Tooltips.Archive.CloseDialog");
|
||||
|
||||
public bool IsBusy
|
||||
{
|
||||
get => _isBusy;
|
||||
protected set
|
||||
{
|
||||
if (Set(ref _isBusy, value)) CommandManager.InvalidateRequerySuggested();
|
||||
if (!Set(ref _isBusy, value)) return;
|
||||
OnPropertyChanged(nameof(CloseToolTip));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +56,8 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
|
||||
private readonly Func<Task> _rebuild;
|
||||
private IReadOnlyList<DialogFact> _facts;
|
||||
|
||||
public RebuildDialogViewModel(Core.Model.Archive archive, ArchiveAvailability availability, int indexed, Func<Task> rebuild, Action close)
|
||||
public RebuildDialogViewModel(Core.Model.Archive archive, ArchiveAvailability availability, int indexed, Func<Task> rebuild,
|
||||
Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
_rebuild = rebuild;
|
||||
@@ -137,7 +147,7 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
|
||||
private CancellationTokenSource? _planning;
|
||||
|
||||
public RenameDialogViewModel(RenameMode mode, ArchiveService archives, Core.Model.Archive archive, IReadOnlyList<Sequence> set, Func<int, Task> applied,
|
||||
Action close)
|
||||
Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
Mode = mode;
|
||||
@@ -159,9 +169,19 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
|
||||
_delay.Stop();
|
||||
_ = PlanAsync();
|
||||
};
|
||||
ApplyCommand = new AsyncRelayCommand(ApplyAsync, () => !IsBusy && _plan is { Steps.Count: > 0 } && !Template.HasErrors);
|
||||
ApplyCommand = new AsyncRelayCommand(ApplyAsync, () => ApplyBlocker is null);
|
||||
}
|
||||
|
||||
/// <summary>Why Apply is disabled; null when it can run.</summary>
|
||||
private string? ApplyBlocker =>
|
||||
IsBusy ? Loc.L("Archive.Blocked.Applying")
|
||||
: Template.Error is { } error ? error
|
||||
: _plan is null ? Loc.L("Archive.Blocked.Planning")
|
||||
: _plan.Steps.Count == 0 ? Loc.L("Archive.Blocked.NoChanges")
|
||||
: null;
|
||||
|
||||
public string ApplyToolTip => ApplyBlocker ?? Loc.L("Tooltips.Archive.RenameApply");
|
||||
|
||||
public RenameMode Mode { get; }
|
||||
|
||||
public string Heading => Loc.Plural(Mode == RenameMode.Folders ? "Archive.Rename.MoveHeading" : "Archive.Rename.Heading", _set.Count);
|
||||
@@ -188,6 +208,7 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
|
||||
_plan = null;
|
||||
Rows = [];
|
||||
OnPropertyChanged(nameof(SummaryText));
|
||||
OnPropertyChanged(nameof(ApplyToolTip));
|
||||
if (Template.HasErrors) return;
|
||||
var cts = _planning = new CancellationTokenSource();
|
||||
var template = Template.Text;
|
||||
@@ -200,6 +221,7 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
|
||||
_plan = plan;
|
||||
Rows = MassRename.Rows(plan, Mode);
|
||||
OnPropertyChanged(nameof(SummaryText));
|
||||
OnPropertyChanged(nameof(ApplyToolTip));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
catch (OperationCanceledException) when (cts.IsCancellationRequested)
|
||||
@@ -242,7 +264,7 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
|
||||
private readonly IReadOnlyList<Sequence> _set;
|
||||
private readonly Func<int, Task> _applied;
|
||||
|
||||
public RetagDialogViewModel(ArchiveService archives, IReadOnlyList<Sequence> set, Func<int, Task> applied, Action close)
|
||||
public RetagDialogViewModel(ArchiveService archives, IReadOnlyList<Sequence> set, Func<int, Task> applied, Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
_archives = archives;
|
||||
@@ -250,11 +272,19 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
|
||||
_applied = applied;
|
||||
Add = new EditableField(string.Empty, Retag.Validate, _ => OnPropertyChanged(nameof(SummaryText)), () => Loc.L("Tooltips.Archive.TagsAdd"));
|
||||
Remove = new EditableField(string.Empty, Retag.Validate, _ => OnPropertyChanged(nameof(SummaryText)), () => Loc.L("Tooltips.Archive.TagsRemove"));
|
||||
Add.PropertyChanged += (_, _) => OnPropertyChanged(nameof(SummaryText));
|
||||
Remove.PropertyChanged += (_, _) => OnPropertyChanged(nameof(SummaryText));
|
||||
ApplyCommand = new AsyncRelayCommand(ApplyAsync, () => !IsBusy && Changes().Count > 0);
|
||||
Add.PropertyChanged += (_, _) => OnTagsTyped();
|
||||
Remove.PropertyChanged += (_, _) => OnTagsTyped();
|
||||
ApplyCommand = new AsyncRelayCommand(ApplyAsync, () => ApplyBlocker is null);
|
||||
}
|
||||
|
||||
/// <summary>Why Apply is disabled; null when it can run.</summary>
|
||||
private string? ApplyBlocker =>
|
||||
IsBusy ? Loc.L("Archive.Blocked.Applying")
|
||||
: Add.Error ?? Remove.Error
|
||||
?? (Changes().Count == 0 ? Loc.L("Archive.Blocked.NoChanges") : null);
|
||||
|
||||
public string ApplyToolTip => ApplyBlocker ?? Loc.L("Tooltips.Archive.RetagApply");
|
||||
|
||||
public string Heading => Loc.Plural("Archive.Retag.Heading", _set.Count);
|
||||
|
||||
public EditableField Add { get; }
|
||||
@@ -265,6 +295,14 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
|
||||
|
||||
public ICommand ApplyCommand { get; }
|
||||
|
||||
/// <summary>Typing changes the dry run, and with it whether Apply can run.</summary>
|
||||
private void OnTagsTyped()
|
||||
{
|
||||
OnPropertyChanged(nameof(SummaryText));
|
||||
OnPropertyChanged(nameof(ApplyToolTip));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
private IReadOnlyList<(Sequence Sequence, IReadOnlyList<string> Tags)> Changes() =>
|
||||
Add.HasErrors || Remove.HasErrors ? [] : Retag.Changes(_set, Retag.Parse(Add.Text), Retag.Parse(Remove.Text));
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ public sealed class ArchiveTreeRowViewModel(ArchiveTreeNode node, ArchiveAvailab
|
||||
|
||||
public string ToggleToolTip => Loc.L(Node.IsExpanded ? "Tooltips.Archive.Collapse" : "Tooltips.Archive.Expand");
|
||||
|
||||
/// <summary>The row's figures; a year also says how the keyboard opens and closes it.</summary>
|
||||
public string RowToolTip => IsYear ? Loc.L("Tooltips.Archive.YearRow", Detail) : Detail;
|
||||
|
||||
public ICommand ToggleCommand { get; } = new RelayCommand(() => toggle(node));
|
||||
|
||||
/// <summary>The archive's availability (BRIEF §7: online, read-only, offline) on the archive row.</summary>
|
||||
@@ -71,3 +74,6 @@ public sealed class OrphanRowViewModel(OrphanRow row, ICommand fix) : Observable
|
||||
public string FixText => Loc.L("Archive.Orphans.Fix." + Row.Kind);
|
||||
public string FixToolTip => Loc.L("Tooltips.Archive.Orphans." + Row.Kind);
|
||||
}
|
||||
|
||||
/// <summary>A value of a set filter menu (camera, status, tag): checked while chosen; choosing it again clears it.</summary>
|
||||
public sealed record FilterChoice(string Label, bool IsChecked, ICommand Command);
|
||||
@@ -4,12 +4,12 @@ namespace Titano.App.Archiving;
|
||||
|
||||
/// <summary>
|
||||
/// The Archive views that <c>--capture</c> renders (<c>archive-<view>-<theme>.png</c>) and the screen smoke
|
||||
/// tests check, on the sample archive: the tree with figures and charts, the maintenance view with its reports, and
|
||||
/// the rebuild dialog.
|
||||
/// tests check, on the sample archive: the tree with figures and charts, the maintenance view with its reports, the
|
||||
/// rebuild dialog, and the Move dialog with its dry run.
|
||||
/// </summary>
|
||||
public static class ArchiveScenes
|
||||
{
|
||||
public static readonly IReadOnlyList<string> Views = ["overview", "maintenance", "rebuild"];
|
||||
public static readonly IReadOnlyList<string> Views = ["overview", "maintenance", "rebuild", "move"];
|
||||
|
||||
public static async Task ShowAsync(ShellViewModel shell, string view)
|
||||
{
|
||||
@@ -32,6 +32,15 @@ public static class ArchiveScenes
|
||||
archive.ViewIndex = 0;
|
||||
(await archive.OpenRebuildDialogAsync())?.ShowFolders(SampleReports.Folders(locations));
|
||||
break;
|
||||
case "move":
|
||||
archive.ViewIndex = 0;
|
||||
await archive.OpenRenameDialogAsync(RenameMode.Folders);
|
||||
if (archive.Dialog is RenameDialogViewModel move)
|
||||
{
|
||||
move.Template.Text = "{year}/{date} {title}";
|
||||
await move.PlanAsync();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(view), view, "Unknown Archive view.");
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Titano.App.Library;
|
||||
using Titano.App.Settings;
|
||||
using Titano.Core.Archiving;
|
||||
using Titano.Core.Localization;
|
||||
@@ -80,3 +81,34 @@ public static class Retag
|
||||
.Where(c => !c.Tags.SequenceEqual(c.Sequence.Tags, StringComparer.Ordinal)),
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Narrows the mass-operation set on top of the tree selection (Archive.html "Filtered set ▾"): camera, status and tag;
|
||||
/// years and single sequences are chosen in the tree.
|
||||
/// </summary>
|
||||
public sealed record ArchiveSetFilter(string? Camera = null, StatusFilter Status = StatusFilter.Any, string? Tag = null)
|
||||
{
|
||||
public bool IsEmpty => Camera is null && Status == StatusFilter.Any && Tag is null;
|
||||
|
||||
public bool Matches(Sequence sequence)
|
||||
{
|
||||
if (Camera is not null && CameraOf(sequence) != Camera) return false;
|
||||
if (Tag is not null && !sequence.Tags.Contains(Tag, StringComparer.OrdinalIgnoreCase)) return false;
|
||||
var (with, without) = LibraryFilter.Flags(Status);
|
||||
return (sequence.Status & with) == with && (sequence.Status & without) == 0;
|
||||
}
|
||||
|
||||
/// <summary>"Canon EOS R5 · Not analysed · sunset"; empty without a filter.</summary>
|
||||
public string Describe() => string.Join(" · ", new[]
|
||||
{
|
||||
Camera ?? string.Empty,
|
||||
Status == StatusFilter.Any ? string.Empty : StatusLabel(Status),
|
||||
Tag ?? string.Empty,
|
||||
}.Where(t => t.Length > 0));
|
||||
|
||||
/// <summary>The camera a sequence is filed under, as the camera chart names it.</summary>
|
||||
public static string CameraOf(Sequence sequence) =>
|
||||
PathTemplate.CameraName(sequence.CameraMake, sequence.CameraModel) is { Length: > 0 } name ? name : Loc.L("Archive.Chart.UnknownCamera");
|
||||
|
||||
public static string StatusLabel(StatusFilter status) => Loc.L(status == StatusFilter.Any ? "Library.Filter.AnyStatus" : "Library.Filter.Status." + status);
|
||||
}
|
||||
Reference in new issue
Block a user