change some code in the Build-Checkboxes function
This commit is contained in:
@@ -265,15 +265,12 @@ function Build-Checkboxes {
|
|||||||
|
|
||||||
(
|
(
|
||||||
$Global:Tasks |
|
$Global:Tasks |
|
||||||
Where-Object Page -EQ $Page |
|
Where-Object Page -EQ $Page |
|
||||||
Where-Object Column -EQ $Column |
|
Where-Object Column -EQ $Column |
|
||||||
ForEach-Object {
|
ForEach-Object {
|
||||||
# 1) render the main checkbox
|
|
||||||
$html = "<label><input type='checkbox' id='$($_.Id)' name='$($_.Name)' data-column='$Column'> $($_.Label)</label>"
|
$html = "<label><input type='checkbox' id='$($_.Id)' name='$($_.Name)' data-column='$Column'> $($_.Label)</label>"
|
||||||
|
|
||||||
# 2) if this task has SubOptions, render them in a hidden container
|
|
||||||
if ($_.SubOptions) {
|
if ($_.SubOptions) {
|
||||||
|
|
||||||
Write-Host "👉 Rendering SubOptions for task $($_.Id)"
|
Write-Host "👉 Rendering SubOptions for task $($_.Id)"
|
||||||
|
|
||||||
$subHtml = (
|
$subHtml = (
|
||||||
@@ -285,26 +282,27 @@ function Build-Checkboxes {
|
|||||||
) -join "`n"
|
) -join "`n"
|
||||||
|
|
||||||
$html += @"
|
$html += @"
|
||||||
<div id='${($_.Id)}OptionsContainer' style='display:none; margin-top:4px;'>
|
<div id='${($_.Id)}OptionsContainer' style='display:none; margin-top:4px;'>
|
||||||
$subHtml
|
$subHtml
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const masterCheckbox = document.getElementById('${($_.Id)}');
|
const masterCheckbox = document.getElementById('${($_.Id)}');
|
||||||
const container = document.getElementById('${($_.Id)}OptionsContainer');
|
const container = document.getElementById('${($_.Id)}OptionsContainer');
|
||||||
if (masterCheckbox && container) {
|
if (masterCheckbox && container) {
|
||||||
masterCheckbox.addEventListener('change', function () {
|
const subCheckboxes = container.querySelectorAll('input[type="checkbox"]');
|
||||||
container.style.display = this.checked ? 'block' : 'none';
|
masterCheckbox.addEventListener('change', function () {
|
||||||
});
|
container.style.display = this.checked ? 'block' : 'none';
|
||||||
// Auto-show if already checked (e.g. page reload with checkbox checked)
|
subCheckboxes.forEach(cb => cb.checked = this.checked);
|
||||||
if (masterCheckbox.checked) {
|
});
|
||||||
container.style.display = 'block';
|
if (masterCheckbox.checked) {
|
||||||
}
|
container.style.display = 'block';
|
||||||
}
|
subCheckboxes.forEach(cb => cb.checked = true);
|
||||||
});
|
}
|
||||||
</script>
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
"@
|
"@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$html
|
$html
|
||||||
@@ -314,6 +312,7 @@ function Build-Checkboxes {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Get-UIHtml {
|
function Get-UIHtml {
|
||||||
param([string]$Page = 'onboard')
|
param([string]$Page = 'onboard')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user