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:
@@ -33,6 +33,7 @@ public partial class DuplicatesViewModel : FeatureViewModelBase
|
|||||||
private readonly DuplicatesHtmlExportService _htmlExportService;
|
private readonly DuplicatesHtmlExportService _htmlExportService;
|
||||||
private readonly ILogger<FeatureViewModelBase> _logger;
|
private readonly ILogger<FeatureViewModelBase> _logger;
|
||||||
private TenantProfile? _currentProfile;
|
private TenantProfile? _currentProfile;
|
||||||
|
private bool _hasLocalSiteOverride;
|
||||||
private IReadOnlyList<DuplicateGroup> _lastGroups = Array.Empty<DuplicateGroup>();
|
private IReadOnlyList<DuplicateGroup> _lastGroups = Array.Empty<DuplicateGroup>();
|
||||||
|
|
||||||
[ObservableProperty] private string _siteUrl = string.Empty;
|
[ObservableProperty] private string _siteUrl = string.Empty;
|
||||||
@@ -76,6 +77,26 @@ public partial class DuplicatesViewModel : FeatureViewModelBase
|
|||||||
ExportHtmlCommand = new AsyncRelayCommand(ExportHtmlAsync, CanExport);
|
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)
|
protected override async Task RunOperationAsync(CancellationToken ct, IProgress<OperationProgress> progress)
|
||||||
{
|
{
|
||||||
if (_currentProfile == null)
|
if (_currentProfile == null)
|
||||||
@@ -137,6 +158,7 @@ public partial class DuplicatesViewModel : FeatureViewModelBase
|
|||||||
protected override void OnTenantSwitched(Core.Models.TenantProfile profile)
|
protected override void OnTenantSwitched(Core.Models.TenantProfile profile)
|
||||||
{
|
{
|
||||||
_currentProfile = profile;
|
_currentProfile = profile;
|
||||||
|
_hasLocalSiteOverride = false;
|
||||||
Results = new ObservableCollection<DuplicateRow>();
|
Results = new ObservableCollection<DuplicateRow>();
|
||||||
_lastGroups = Array.Empty<DuplicateGroup>();
|
_lastGroups = Array.Empty<DuplicateGroup>();
|
||||||
SiteUrl = string.Empty;
|
SiteUrl = string.Empty;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public partial class FolderStructureViewModel : FeatureViewModelBase
|
|||||||
private readonly BulkResultCsvExportService _exportService;
|
private readonly BulkResultCsvExportService _exportService;
|
||||||
private readonly ILogger<FeatureViewModelBase> _logger;
|
private readonly ILogger<FeatureViewModelBase> _logger;
|
||||||
private TenantProfile? _currentProfile;
|
private TenantProfile? _currentProfile;
|
||||||
|
private bool _hasLocalSiteOverride;
|
||||||
private List<FolderStructureRow>? _validRows;
|
private List<FolderStructureRow>? _validRows;
|
||||||
private BulkOperationSummary<string>? _lastResult;
|
private BulkOperationSummary<string>? _lastResult;
|
||||||
|
|
||||||
@@ -65,6 +66,26 @@ public partial class FolderStructureViewModel : FeatureViewModelBase
|
|||||||
ExportFailedCommand = new AsyncRelayCommand(ExportFailedAsync, () => HasFailures);
|
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()
|
private void ImportCsv()
|
||||||
{
|
{
|
||||||
var dlg = new OpenFileDialog
|
var dlg = new OpenFileDialog
|
||||||
@@ -154,6 +175,7 @@ public partial class FolderStructureViewModel : FeatureViewModelBase
|
|||||||
protected override void OnTenantSwitched(TenantProfile profile)
|
protected override void OnTenantSwitched(TenantProfile profile)
|
||||||
{
|
{
|
||||||
_currentProfile = profile;
|
_currentProfile = profile;
|
||||||
|
_hasLocalSiteOverride = false;
|
||||||
SiteUrl = string.Empty;
|
SiteUrl = string.Empty;
|
||||||
LibraryTitle = string.Empty;
|
LibraryTitle = string.Empty;
|
||||||
PreviewRows = new();
|
PreviewRows = new();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public partial class SearchViewModel : FeatureViewModelBase
|
|||||||
private readonly SearchHtmlExportService _htmlExportService;
|
private readonly SearchHtmlExportService _htmlExportService;
|
||||||
private readonly ILogger<FeatureViewModelBase> _logger;
|
private readonly ILogger<FeatureViewModelBase> _logger;
|
||||||
private TenantProfile? _currentProfile;
|
private TenantProfile? _currentProfile;
|
||||||
|
private bool _hasLocalSiteOverride;
|
||||||
|
|
||||||
// ── Filter observable properties ─────────────────────────────────────────
|
// ── Filter observable properties ─────────────────────────────────────────
|
||||||
|
|
||||||
@@ -73,6 +74,26 @@ public partial class SearchViewModel : FeatureViewModelBase
|
|||||||
ExportHtmlCommand = new AsyncRelayCommand(ExportHtmlAsync, CanExport);
|
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)
|
protected override async Task RunOperationAsync(CancellationToken ct, IProgress<OperationProgress> progress)
|
||||||
{
|
{
|
||||||
if (_currentProfile == null)
|
if (_currentProfile == null)
|
||||||
@@ -119,6 +140,7 @@ public partial class SearchViewModel : FeatureViewModelBase
|
|||||||
protected override void OnTenantSwitched(Core.Models.TenantProfile profile)
|
protected override void OnTenantSwitched(Core.Models.TenantProfile profile)
|
||||||
{
|
{
|
||||||
_currentProfile = profile;
|
_currentProfile = profile;
|
||||||
|
_hasLocalSiteOverride = false;
|
||||||
Results = new ObservableCollection<SearchResult>();
|
Results = new ObservableCollection<SearchResult>();
|
||||||
SiteUrl = string.Empty;
|
SiteUrl = string.Empty;
|
||||||
OnPropertyChanged(nameof(CurrentProfile));
|
OnPropertyChanged(nameof(CurrentProfile));
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public partial class StorageViewModel : FeatureViewModelBase
|
|||||||
private readonly StorageHtmlExportService _htmlExportService;
|
private readonly StorageHtmlExportService _htmlExportService;
|
||||||
private readonly ILogger<FeatureViewModelBase> _logger;
|
private readonly ILogger<FeatureViewModelBase> _logger;
|
||||||
private TenantProfile? _currentProfile;
|
private TenantProfile? _currentProfile;
|
||||||
|
private bool _hasLocalSiteOverride;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string _siteUrl = string.Empty;
|
private string _siteUrl = string.Empty;
|
||||||
@@ -96,6 +97,26 @@ public partial class StorageViewModel : FeatureViewModelBase
|
|||||||
ExportHtmlCommand = new AsyncRelayCommand(ExportHtmlAsync, CanExport);
|
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)
|
protected override async Task RunOperationAsync(CancellationToken ct, IProgress<OperationProgress> progress)
|
||||||
{
|
{
|
||||||
if (_currentProfile == null)
|
if (_currentProfile == null)
|
||||||
@@ -147,6 +168,7 @@ public partial class StorageViewModel : FeatureViewModelBase
|
|||||||
protected override void OnTenantSwitched(TenantProfile profile)
|
protected override void OnTenantSwitched(TenantProfile profile)
|
||||||
{
|
{
|
||||||
_currentProfile = profile;
|
_currentProfile = profile;
|
||||||
|
_hasLocalSiteOverride = false;
|
||||||
Results = new ObservableCollection<StorageNode>();
|
Results = new ObservableCollection<StorageNode>();
|
||||||
SiteUrl = string.Empty;
|
SiteUrl = string.Empty;
|
||||||
OnPropertyChanged(nameof(CurrentProfile));
|
OnPropertyChanged(nameof(CurrentProfile));
|
||||||
|
|||||||
Reference in New Issue
Block a user