feat(06-01): extend FeatureViewModelBase with GlobalSites support
- Add protected GlobalSites property (IReadOnlyList<SiteInfo>) initialized to Array.Empty - Register GlobalSitesChangedMessage in OnActivated alongside TenantSwitchedMessage - Add private OnGlobalSitesReceived to update GlobalSites and invoke virtual hook - Add protected virtual OnGlobalSitesChanged for derived VMs to override - [Rule 3 - Blocking] Fix MainWindowViewModel missing ExecuteOpenGlobalSitePicker and BroadcastGlobalSites stubs referenced in constructor (pre-existing partial state from earlier TODO commit)
This commit is contained in:
@@ -23,6 +23,12 @@ public abstract partial class FeatureViewModelBase : ObservableRecipient
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int _progressValue;
|
private int _progressValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sites selected in the global toolbar picker. Updated via GlobalSitesChangedMessage.
|
||||||
|
/// Derived VMs check this in RunOperationAsync before falling back to per-tab SiteUrl.
|
||||||
|
/// </summary>
|
||||||
|
protected IReadOnlyList<SiteInfo> GlobalSites { get; private set; } = Array.Empty<SiteInfo>();
|
||||||
|
|
||||||
public IAsyncRelayCommand RunCommand { get; }
|
public IAsyncRelayCommand RunCommand { get; }
|
||||||
public RelayCommand CancelCommand { get; }
|
public RelayCommand CancelCommand { get; }
|
||||||
|
|
||||||
@@ -73,10 +79,26 @@ public abstract partial class FeatureViewModelBase : ObservableRecipient
|
|||||||
protected override void OnActivated()
|
protected override void OnActivated()
|
||||||
{
|
{
|
||||||
Messenger.Register<TenantSwitchedMessage>(this, (r, m) => ((FeatureViewModelBase)r).OnTenantSwitched(m.Value));
|
Messenger.Register<TenantSwitchedMessage>(this, (r, m) => ((FeatureViewModelBase)r).OnTenantSwitched(m.Value));
|
||||||
|
Messenger.Register<GlobalSitesChangedMessage>(this, (r, m) => ((FeatureViewModelBase)r).OnGlobalSitesReceived(m.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnTenantSwitched(TenantProfile profile)
|
protected virtual void OnTenantSwitched(TenantProfile profile)
|
||||||
{
|
{
|
||||||
// Derived classes override to reset their state
|
// Derived classes override to reset their state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGlobalSitesReceived(IReadOnlyList<SiteInfo> sites)
|
||||||
|
{
|
||||||
|
GlobalSites = sites;
|
||||||
|
OnGlobalSitesChanged(sites);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the global site selection changes. Override in derived VMs
|
||||||
|
/// to update UI state (e.g., pre-fill SiteUrl from first global site).
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void OnGlobalSitesChanged(IReadOnlyList<SiteInfo> sites)
|
||||||
|
{
|
||||||
|
// Derived classes override to react to global site changes
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user