feat(06-04): update PermissionsViewModel for multi-site global consumption
- Add _hasLocalSiteOverride field to track local user selection - Override OnGlobalSitesChanged to pre-populate SelectedSites from global sites - Set _hasLocalSiteOverride=true when user picks sites via site picker dialog - Reset _hasLocalSiteOverride=false on tenant switch (OnTenantSwitched)
This commit is contained in:
@@ -75,6 +75,12 @@ public partial class PermissionsViewModel : FeatureViewModelBase
|
|||||||
|
|
||||||
public ObservableCollection<SiteInfo> SelectedSites { get; } = new();
|
public ObservableCollection<SiteInfo> SelectedSites { get; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True when the user has manually selected sites via the site picker on this tab.
|
||||||
|
/// Prevents global site changes from overwriting the user's local selection.
|
||||||
|
/// </summary>
|
||||||
|
private bool _hasLocalSiteOverride;
|
||||||
|
|
||||||
// ── Dialog factory (set by View layer — keeps Window out of ViewModel) ──
|
// ── Dialog factory (set by View layer — keeps Window out of ViewModel) ──
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -152,6 +158,15 @@ public partial class PermissionsViewModel : FeatureViewModelBase
|
|||||||
|
|
||||||
// ── FeatureViewModelBase implementation ─────────────────────────────────
|
// ── FeatureViewModelBase implementation ─────────────────────────────────
|
||||||
|
|
||||||
|
protected override void OnGlobalSitesChanged(IReadOnlyList<SiteInfo> sites)
|
||||||
|
{
|
||||||
|
if (_hasLocalSiteOverride) return;
|
||||||
|
|
||||||
|
SelectedSites.Clear();
|
||||||
|
foreach (var site in sites)
|
||||||
|
SelectedSites.Add(site);
|
||||||
|
}
|
||||||
|
|
||||||
protected override async Task RunOperationAsync(CancellationToken ct, IProgress<OperationProgress> progress)
|
protected override async Task RunOperationAsync(CancellationToken ct, IProgress<OperationProgress> progress)
|
||||||
{
|
{
|
||||||
var urls = SelectedSites.Count > 0
|
var urls = SelectedSites.Count > 0
|
||||||
@@ -214,6 +229,7 @@ public partial class PermissionsViewModel : FeatureViewModelBase
|
|||||||
protected override void OnTenantSwitched(TenantProfile profile)
|
protected override void OnTenantSwitched(TenantProfile profile)
|
||||||
{
|
{
|
||||||
_currentProfile = profile;
|
_currentProfile = profile;
|
||||||
|
_hasLocalSiteOverride = false;
|
||||||
Results = new ObservableCollection<PermissionEntry>();
|
Results = new ObservableCollection<PermissionEntry>();
|
||||||
SiteUrl = string.Empty;
|
SiteUrl = string.Empty;
|
||||||
SelectedSites.Clear();
|
SelectedSites.Clear();
|
||||||
@@ -288,6 +304,7 @@ public partial class PermissionsViewModel : FeatureViewModelBase
|
|||||||
var dialog = OpenSitePickerDialog.Invoke();
|
var dialog = OpenSitePickerDialog.Invoke();
|
||||||
if (dialog?.ShowDialog() == true && dialog is Views.Dialogs.SitePickerDialog picker)
|
if (dialog?.ShowDialog() == true && dialog is Views.Dialogs.SitePickerDialog picker)
|
||||||
{
|
{
|
||||||
|
_hasLocalSiteOverride = true;
|
||||||
SelectedSites.Clear();
|
SelectedSites.Clear();
|
||||||
foreach (var site in picker.SelectedUrls)
|
foreach (var site in picker.SelectedUrls)
|
||||||
SelectedSites.Add(site);
|
SelectedSites.Add(site);
|
||||||
|
|||||||
Reference in New Issue
Block a user