Refactor: Centralize Install Apps checkbox logic

Consolidates the state management for the "Install Apps" checkbox into a single, reusable function.

Previously, the logic to automatically check and disable "Install Apps" when selecting an update or installing Office was duplicated and scattered across multiple event handlers and files.

This change introduces a new core function that centralizes this behavior. A single event handler is now used for all relevant checkboxes (Updates and Office), simplifying the UI code, reducing redundancy, and making the logic more robust and maintainable. The initial state is also set correctly on startup.
This commit is contained in:
rbalsleyMSFT
2025-06-18 13:07:07 -07:00
parent af5d5206f8
commit fd39b0008e
4 changed files with 66 additions and 70 deletions
@@ -235,6 +235,9 @@ function Initialize-UIDefaults {
$State.Controls.chkInstallDrivers.IsChecked = $State.Defaults.generalDefaults.InstallDrivers
$State.Controls.chkCopyDrivers.IsChecked = $State.Defaults.generalDefaults.CopyDrivers
$State.Controls.chkCopyPEDrivers.IsChecked = $State.Defaults.generalDefaults.CopyPEDrivers
# Set initial state for InstallApps checkbox based on updates
Update-InstallAppsState -State $State
}
function Initialize-DynamicUIElements {