--- phase: 06-global-site-selection plan: 02 subsystem: ui tags: [wpf, mvvm, observable-collection, weak-reference-messenger, community-toolkit] # Dependency graph requires: - phase: 06-global-site-selection/06-01 provides: GlobalSitesChangedMessage class in Core/Messages provides: - GlobalSelectedSites ObservableCollection on MainWindowViewModel - OpenGlobalSitePickerCommand (disabled when no profile) - GlobalSitesSelectedLabel computed property for toolbar - WeakReferenceMessenger broadcast on GlobalSelectedSites change - Clear on tenant switch and session clear affects: - 06-03 (toolbar XAML binds to these properties) - 06-04 (FeatureViewModelBase registers for GlobalSitesChangedMessage) # Tech tracking tech-stack: added: [] patterns: - "Func? factory property for dialog opening (keeps Window refs out of VMs)" - "CollectionChanged subscription to broadcast messenger message and update computed label" - "ObservableCollection clear in OnSelectedProfileChanged for tenant-scoped state" key-files: created: [] modified: - SharepointToolbox/ViewModels/MainWindowViewModel.cs key-decisions: - "Used using SharepointToolbox.Views.Dialogs in ViewModel for SitePickerDialog cast — acceptable given existing Window reference pattern in this VM" - "GlobalSitesSelectedLabel uses hardcoded string; plan 06-03 will replace with localized keys" - "CollectionChanged event subscribes in constructor to trigger both label update and messenger broadcast atomically" patterns-established: - "OpenGlobalSitePickerDialog: same Func? factory pattern as OpenProfileManagementDialog" - "BroadcastGlobalSites(): single helper centralizes messenger send for GlobalSitesChangedMessage" requirements-completed: - SITE-01 # Metrics duration: 8min completed: 2026-04-07 --- # Phase 06 Plan 02: MainWindowViewModel Global Site Selection Summary **ObservableCollection GlobalSelectedSites with dialog command, computed label, messenger broadcast, and clear-on-tenant-switch added to MainWindowViewModel** ## Performance - **Duration:** 8 min - **Started:** 2026-04-07T10:10:00Z - **Completed:** 2026-04-07T10:18:00Z - **Tasks:** 1 - **Files modified:** 1 ## Accomplishments - Added GlobalSelectedSites and OpenGlobalSitePickerCommand to MainWindowViewModel — toolbar UI (06-03) can bind directly - WeakReferenceMessenger broadcasts GlobalSitesChangedMessage on every collection change — all tab VMs receive live updates - GlobalSelectedSites cleared on tenant switch and session clear, keeping site selection scoped to the current tenant ## Task Commits Each task was committed atomically: 1. **Task 1: Add global site selection state, command, and broadcast to MainWindowViewModel** - `a10f03e` (feat) **Plan metadata:** _(docs commit to follow)_ ## Files Created/Modified - `SharepointToolbox/ViewModels/MainWindowViewModel.cs` - Added OpenGlobalSitePickerDialog factory, GlobalSelectedSites, GlobalSitesSelectedLabel, OpenGlobalSitePickerCommand, ExecuteOpenGlobalSitePicker, BroadcastGlobalSites; clear on tenant switch and session clear ## Decisions Made - Added `using SharepointToolbox.Views.Dialogs;` to MainWindowViewModel — acceptable because this VM already holds `Func?` factory properties that reference the View layer. The cast in `ExecuteOpenGlobalSitePicker` requires knowing the concrete dialog type. - `GlobalSitesSelectedLabel` uses a hardcoded English string for now; plan 06-03 will replace it with a localized key from Strings.resx once toolbar XAML is added. ## Deviations from Plan None - plan executed exactly as written. (Note: `GlobalSitesChangedMessage.cs` was already present from plan 06-01 — no deviation needed.) ## Issues Encountered None. ## User Setup Required None - no external service configuration required. ## Next Phase Readiness - MainWindowViewModel now exposes all properties and commands needed for the toolbar XAML (plan 06-03) - `OpenGlobalSitePickerDialog` factory property ready to be wired in MainWindow.xaml.cs (plan 06-03) - GlobalSitesChangedMessage broadcasting is live; FeatureViewModelBase can register for it (plan 06-04) --- *Phase: 06-global-site-selection* *Completed: 2026-04-07*