feat(06-04): update single-site tab VMs for global site consumption

- StorageViewModel: add OnGlobalSitesChanged, OnSiteUrlChanged, _hasLocalSiteOverride
- SearchViewModel: add OnGlobalSitesChanged, OnSiteUrlChanged, _hasLocalSiteOverride
- DuplicatesViewModel: add OnGlobalSitesChanged, OnSiteUrlChanged, _hasLocalSiteOverride
- FolderStructureViewModel: add OnGlobalSitesChanged, OnSiteUrlChanged, _hasLocalSiteOverride
- All four VMs pre-fill SiteUrl from first global site; local typing sets override flag
- Tenant switch resets _hasLocalSiteOverride in all four VMs
This commit is contained in:
Dev
2026-04-07 10:08:19 +02:00
parent 45eb531128
commit 6a2e4d1d89
4 changed files with 88 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ public partial class DuplicatesViewModel : FeatureViewModelBase
private readonly DuplicatesHtmlExportService _htmlExportService;
private readonly ILogger<FeatureViewModelBase> _logger;
private TenantProfile? _currentProfile;
private bool _hasLocalSiteOverride;
private IReadOnlyList<DuplicateGroup> _lastGroups = Array.Empty<DuplicateGroup>();
[ObservableProperty] private string _siteUrl = string.Empty;
@@ -76,6 +77,26 @@ public partial class DuplicatesViewModel : FeatureViewModelBase
ExportHtmlCommand = new AsyncRelayCommand(ExportHtmlAsync, CanExport);
}
protected override void OnGlobalSitesChanged(IReadOnlyList<SiteInfo> sites)
{
if (_hasLocalSiteOverride) return;
SiteUrl = sites.Count > 0 ? sites[0].Url : string.Empty;
}
partial void OnSiteUrlChanged(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
_hasLocalSiteOverride = false;
if (GlobalSites.Count > 0)
SiteUrl = GlobalSites[0].Url;
}
else if (GlobalSites.Count == 0 || value != GlobalSites[0].Url)
{
_hasLocalSiteOverride = true;
}
}
protected override async Task RunOperationAsync(CancellationToken ct, IProgress<OperationProgress> progress)
{
if (_currentProfile == null)
@@ -137,6 +158,7 @@ public partial class DuplicatesViewModel : FeatureViewModelBase
protected override void OnTenantSwitched(Core.Models.TenantProfile profile)
{
_currentProfile = profile;
_hasLocalSiteOverride = false;
Results = new ObservableCollection<DuplicateRow>();
_lastGroups = Array.Empty<DuplicateGroup>();
SiteUrl = string.Empty;

View File

@@ -22,6 +22,7 @@ public partial class FolderStructureViewModel : FeatureViewModelBase
private readonly BulkResultCsvExportService _exportService;
private readonly ILogger<FeatureViewModelBase> _logger;
private TenantProfile? _currentProfile;
private bool _hasLocalSiteOverride;
private List<FolderStructureRow>? _validRows;
private BulkOperationSummary<string>? _lastResult;
@@ -65,6 +66,26 @@ public partial class FolderStructureViewModel : FeatureViewModelBase
ExportFailedCommand = new AsyncRelayCommand(ExportFailedAsync, () => HasFailures);
}
protected override void OnGlobalSitesChanged(IReadOnlyList<SiteInfo> sites)
{
if (_hasLocalSiteOverride) return;
SiteUrl = sites.Count > 0 ? sites[0].Url : string.Empty;
}
partial void OnSiteUrlChanged(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
_hasLocalSiteOverride = false;
if (GlobalSites.Count > 0)
SiteUrl = GlobalSites[0].Url;
}
else if (GlobalSites.Count == 0 || value != GlobalSites[0].Url)
{
_hasLocalSiteOverride = true;
}
}
private void ImportCsv()
{
var dlg = new OpenFileDialog
@@ -154,6 +175,7 @@ public partial class FolderStructureViewModel : FeatureViewModelBase
protected override void OnTenantSwitched(TenantProfile profile)
{
_currentProfile = profile;
_hasLocalSiteOverride = false;
SiteUrl = string.Empty;
LibraryTitle = string.Empty;
PreviewRows = new();

View File

@@ -19,6 +19,7 @@ public partial class SearchViewModel : FeatureViewModelBase
private readonly SearchHtmlExportService _htmlExportService;
private readonly ILogger<FeatureViewModelBase> _logger;
private TenantProfile? _currentProfile;
private bool _hasLocalSiteOverride;
// ── Filter observable properties ─────────────────────────────────────────
@@ -73,6 +74,26 @@ public partial class SearchViewModel : FeatureViewModelBase
ExportHtmlCommand = new AsyncRelayCommand(ExportHtmlAsync, CanExport);
}
protected override void OnGlobalSitesChanged(IReadOnlyList<SiteInfo> sites)
{
if (_hasLocalSiteOverride) return;
SiteUrl = sites.Count > 0 ? sites[0].Url : string.Empty;
}
partial void OnSiteUrlChanged(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
_hasLocalSiteOverride = false;
if (GlobalSites.Count > 0)
SiteUrl = GlobalSites[0].Url;
}
else if (GlobalSites.Count == 0 || value != GlobalSites[0].Url)
{
_hasLocalSiteOverride = true;
}
}
protected override async Task RunOperationAsync(CancellationToken ct, IProgress<OperationProgress> progress)
{
if (_currentProfile == null)
@@ -119,6 +140,7 @@ public partial class SearchViewModel : FeatureViewModelBase
protected override void OnTenantSwitched(Core.Models.TenantProfile profile)
{
_currentProfile = profile;
_hasLocalSiteOverride = false;
Results = new ObservableCollection<SearchResult>();
SiteUrl = string.Empty;
OnPropertyChanged(nameof(CurrentProfile));

View File

@@ -19,6 +19,7 @@ public partial class StorageViewModel : FeatureViewModelBase
private readonly StorageHtmlExportService _htmlExportService;
private readonly ILogger<FeatureViewModelBase> _logger;
private TenantProfile? _currentProfile;
private bool _hasLocalSiteOverride;
[ObservableProperty]
private string _siteUrl = string.Empty;
@@ -96,6 +97,26 @@ public partial class StorageViewModel : FeatureViewModelBase
ExportHtmlCommand = new AsyncRelayCommand(ExportHtmlAsync, CanExport);
}
protected override void OnGlobalSitesChanged(IReadOnlyList<SiteInfo> sites)
{
if (_hasLocalSiteOverride) return;
SiteUrl = sites.Count > 0 ? sites[0].Url : string.Empty;
}
partial void OnSiteUrlChanged(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
_hasLocalSiteOverride = false;
if (GlobalSites.Count > 0)
SiteUrl = GlobalSites[0].Url;
}
else if (GlobalSites.Count == 0 || value != GlobalSites[0].Url)
{
_hasLocalSiteOverride = true;
}
}
protected override async Task RunOperationAsync(CancellationToken ct, IProgress<OperationProgress> progress)
{
if (_currentProfile == null)
@@ -147,6 +168,7 @@ public partial class StorageViewModel : FeatureViewModelBase
protected override void OnTenantSwitched(TenantProfile profile)
{
_currentProfile = profile;
_hasLocalSiteOverride = false;
Results = new ObservableCollection<StorageNode>();
SiteUrl = string.Empty;
OnPropertyChanged(nameof(CurrentProfile));