From 58ae0960611bb811b1ddefef1f1b5f8cd2fcbdd1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 10:44:22 +0000 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- i18n/en/Archive.resx | 17 +- i18n/it/Archive.it.resx | 23 +- .../Archive/ArchiveDialogViewModels.cs | 60 +++- .../Archive/ArchiveRowViewModels.cs | 6 + src/Titano.App/Archive/ArchiveScenes.cs | 15 +- src/Titano.App/Archive/MassOperations.cs | 32 ++ src/Titano.App/Sections/ArchiveView.xaml | 164 ++++++--- src/Titano.App/Sections/ArchiveView.xaml.cs | 83 ++++- src/Titano.App/Sections/ArchiveViewModel.cs | 338 +++++++++++++++--- 9 files changed, 614 insertions(+), 124 deletions(-) diff --git a/i18n/en/Archive.resx b/i18n/en/Archive.resx index 951c7220..2148b764 100644 --- a/i18n/en/Archive.resx +++ b/i18n/en/Archive.resx @@ -4,12 +4,20 @@ 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + Copy into the layout… + Index in place… {0:N0} sequence changed {0:N0} sequences changed offline online read-only + The database backup stoppedlong + Wait until the changes are applied.long + The set is empty: change the selection or the filter.long + Nothing would change.long The archive must be online and writable.long + Wait for the dry run.long + A search is running; cancel it or wait.long By camera By format {0} · {1} · {2}invariant @@ -25,6 +33,7 @@ Remove row Remove {0} from the index?long Its sidecar is gone. Only the index row is removed; no file is deleted.long + Folder to copy into the archivelong Cancel {0:N0} copy {0:N0} copies @@ -45,6 +54,7 @@ {0} changed after the plan was made.long: error sentence The card or folder {0} is no longer available.long: error sentence The archive changed after this plan was made.long: error sentence + Cancel None found Find Searching… @@ -82,6 +92,7 @@ {0} folders, {1} indexed, {2} adopted, {3} removedlong: job log line Sequence not found: {0}long: job log line {0} photos checked, {1} intact, {2} hashed, {3} with problemslong: job log line + Back up database Dry run Rebuild proxies Relink moved archive… @@ -114,6 +125,7 @@ Sidecars Rebuild State + No maintenance yet.long History {0} · {1}invariant Recent maintenance @@ -139,8 +151,10 @@ {0:N0} sequence · all {0:N0} sequences · all Analyse + Clear filter Export CSV - Selected set + Set filter + Filtered set Move… Proxies Rename… @@ -159,6 +173,7 @@ sequences {0} – {1}invariant Adopt folder… + Adopt folder Archive Duplicates Maintenance diff --git a/i18n/it/Archive.it.resx b/i18n/it/Archive.it.resx index 8689b0be..fd159c3b 100644 --- a/i18n/it/Archive.it.resx +++ b/i18n/it/Archive.it.resx @@ -4,12 +4,20 @@ 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + Copia nella struttura… + Indicizza sul posto… {0:N0} sequenza modificata {0:N0} sequenze modificate offline online sola lettura + La copia del database si è interrotta + Attendi che le modifiche siano applicate. + La selezione è vuota: cambia la selezione o il filtro. + Non cambierebbe nulla. L'archivio deve essere raggiungibile e scrivibile. + Attendi la simulazione. + Una ricerca è in corso: annullala o attendi. Per fotocamera Per formato Foto al mese @@ -17,11 +25,12 @@ {0:N0} altre Altro Spazio per anno - Fotocamera ignota + Fotocamera sconosciuta Mantieni riga Rimuovi riga Rimuovere {0} dall'indice? Il suo sidecar non c'è più. Viene rimossa solo la riga dell'indice; nessun file viene eliminato. + Cartella da copiare nell'archivio Annulla {0:N0} copia {0:N0} copie @@ -41,6 +50,7 @@ {0} è cambiato dopo la creazione del piano. La scheda o cartella {0} non è più disponibile. L'archivio è cambiato dopo la creazione del piano. + Annulla Nessuno trovato Cerca Ricerca… @@ -60,12 +70,12 @@ {0:N0} sequenze senza proxy {0:N0} sequenza non analizzata {0:N0} sequenze non analizzate - Proxy pronti per tutte + Ogni sequenza ha i proxy Stato dell'indice {0:N0} sequenza non verificata {0:N0} sequenze non verificate Ultima scansione {0} · {1} - Prova: nulla è stato modificato. + Simulazione: nulla è stato modificato. Non indicizzata: {0} ({1}) Modificato: {0} Danneggiato: {0} @@ -78,6 +88,7 @@ {0} cartelle, {1} indicizzate, {2} adottate, {3} rimosse Sequenza non trovata: {0} {0} foto controllate, {1} integre, {2} con impronta nuova, {3} con problemi + Copia del database Simulazione Ricrea proxy Ricollega archivio spostato… @@ -110,6 +121,7 @@ Sidecar Ricostruisci Stato + Ancora nessuna manutenzione. Cronologia Manutenzione recente {0} ricollegato @@ -134,8 +146,10 @@ {0:N0} sequenza · tutte {0:N0} sequenze · tutte Analizza + Togli filtro Esporta CSV - Insieme scelto + Filtro selezione + Selezione Sposta… Proxy Rinomina… @@ -153,6 +167,7 @@ sequenza sequenze Adotta cartella… + Adotta cartella Archivio Doppioni Manutenzione diff --git a/src/Titano.App/Archive/ArchiveDialogViewModels.cs b/src/Titano.App/Archive/ArchiveDialogViewModels.cs index 8415a930..2ac3c6d0 100644 --- a/src/Titano.App/Archive/ArchiveDialogViewModels.cs +++ b/src/Titano.App/Archive/ArchiveDialogViewModels.cs @@ -13,20 +13,29 @@ using Titano.Ui.Mvvm; namespace Titano.App.Archiving; -/// An in-window dialog of the Archive screen: one primary action, one way out. -public abstract class ArchiveDialogViewModel(Action close) : LocalizedViewModel +/// +/// An in-window dialog of the Archive screen: one primary action, one way out. While its action runs it cannot be +/// closed; receives the dialog, so a late close never closes another one. +/// +public abstract class ArchiveDialogViewModel : LocalizedViewModel { private bool _isBusy; private string? _busyText; - public ICommand CloseCommand { get; } = new RelayCommand(close); + protected ArchiveDialogViewModel(Action 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 _rebuild; private IReadOnlyList _facts; - public RebuildDialogViewModel(Core.Model.Archive archive, ArchiveAvailability availability, int indexed, Func rebuild, Action close) + public RebuildDialogViewModel(Core.Model.Archive archive, ArchiveAvailability availability, int indexed, Func rebuild, + Action 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 set, Func applied, - Action close) + Action 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); } + /// Why Apply is disabled; null when it can run. + 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 _set; private readonly Func _applied; - public RetagDialogViewModel(ArchiveService archives, IReadOnlyList set, Func applied, Action close) + public RetagDialogViewModel(ArchiveService archives, IReadOnlyList set, Func applied, Action 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); } + /// Why Apply is disabled; null when it can run. + 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; } + /// Typing changes the dry run, and with it whether Apply can run. + private void OnTagsTyped() + { + OnPropertyChanged(nameof(SummaryText)); + OnPropertyChanged(nameof(ApplyToolTip)); + CommandManager.InvalidateRequerySuggested(); + } + private IReadOnlyList<(Sequence Sequence, IReadOnlyList Tags)> Changes() => Add.HasErrors || Remove.HasErrors ? [] : Retag.Changes(_set, Retag.Parse(Add.Text), Retag.Parse(Remove.Text)); diff --git a/src/Titano.App/Archive/ArchiveRowViewModels.cs b/src/Titano.App/Archive/ArchiveRowViewModels.cs index b386232e..08b9b5cb 100644 --- a/src/Titano.App/Archive/ArchiveRowViewModels.cs +++ b/src/Titano.App/Archive/ArchiveRowViewModels.cs @@ -24,6 +24,9 @@ public sealed class ArchiveTreeRowViewModel(ArchiveTreeNode node, ArchiveAvailab public string ToggleToolTip => Loc.L(Node.IsExpanded ? "Tooltips.Archive.Collapse" : "Tooltips.Archive.Expand"); + /// The row's figures; a year also says how the keyboard opens and closes it. + public string RowToolTip => IsYear ? Loc.L("Tooltips.Archive.YearRow", Detail) : Detail; + public ICommand ToggleCommand { get; } = new RelayCommand(() => toggle(node)); /// The archive's availability (BRIEF §7: online, read-only, offline) on the archive row. @@ -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); } + +/// A value of a set filter menu (camera, status, tag): checked while chosen; choosing it again clears it. +public sealed record FilterChoice(string Label, bool IsChecked, ICommand Command); diff --git a/src/Titano.App/Archive/ArchiveScenes.cs b/src/Titano.App/Archive/ArchiveScenes.cs index f9572fc8..c6fa089d 100644 --- a/src/Titano.App/Archive/ArchiveScenes.cs +++ b/src/Titano.App/Archive/ArchiveScenes.cs @@ -4,12 +4,12 @@ namespace Titano.App.Archiving; /// /// The Archive views that --capture renders (archive-<view>-<theme>.png) 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. /// public static class ArchiveScenes { - public static readonly IReadOnlyList Views = ["overview", "maintenance", "rebuild"]; + public static readonly IReadOnlyList 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."); } diff --git a/src/Titano.App/Archive/MassOperations.cs b/src/Titano.App/Archive/MassOperations.cs index 9f953f39..6a6564af 100644 --- a/src/Titano.App/Archive/MassOperations.cs +++ b/src/Titano.App/Archive/MassOperations.cs @@ -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)), ]; } + +/// +/// 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. +/// +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; + } + + /// "Canon EOS R5 · Not analysed · sunset"; empty without a filter. + public string Describe() => string.Join(" · ", new[] + { + Camera ?? string.Empty, + Status == StatusFilter.Any ? string.Empty : StatusLabel(Status), + Tag ?? string.Empty, + }.Where(t => t.Length > 0)); + + /// The camera a sequence is filed under, as the camera chart names it. + 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); +} diff --git a/src/Titano.App/Sections/ArchiveView.xaml b/src/Titano.App/Sections/ArchiveView.xaml index ddf723ce..42a18f7b 100644 --- a/src/Titano.App/Sections/ArchiveView.xaml +++ b/src/Titano.App/Sections/ArchiveView.xaml @@ -18,6 +18,25 @@ + + + + + + + @@ -214,7 +252,8 @@ -