Pode.Web
Pode.Web copied to clipboard
Update Actions to move from "SwitchState" parameters to actual switch parameters
In #450 I tested an approach of using a [switch] parameter on Update-PodeWebIcon for -Spin, instead of doing -SpinState and having Unchanged, Enabled, Disabled values.
This worked, so it could be ideal to shift other actions that use a similar approach (like Update-PodeWebTextbox with -ReadOnlyState and -DisabledState) to use switch instead too (ie: -ReadOnly and -Disabled).
If the switch isn't supplied then no action is taken on the element, using $PSBoundParameters to check. If the switch is supplied then it's true/false value is used and the element is updated.
For example:
# no action is performed on readonly
Update-PodeWebTextbox -Name 'Example'
# the textbox is updated to be readonly
Update-PodeWebTextbox -Name 'Example' -ReadOnly
# the textbox is updated to have readonly removed
Update-PodeWebTextbox -Name 'Example' -ReadOnly:$false
# the textbox is updated to be disabled
Update-PodeWebTextbox -Name 'Example' -Disabled
# the textbox is updated to be enabled
Update-PodeWebTextbox -Name 'Example' -Disabled:$false
Thanks to @RobinBeismann in #412 for showing me this 😉