From 2bfd812b82ac15c205b5d7ef00b5530da8a9bb4b Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Mon, 26 May 2025 22:10:22 -0400 Subject: [PATCH] Update testTaskGate.ps1 --- testTaskGate.ps1 | 56 ++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/testTaskGate.ps1 b/testTaskGate.ps1 index da418c2..fc108dc 100644 --- a/testTaskGate.ps1 +++ b/testTaskGate.ps1 @@ -286,28 +286,7 @@ function Build-Checkboxes { - "@ } @@ -596,6 +575,41 @@ $style = @' fetch("/quit", { method: "GET" }) .finally(() => window.close()); } + + // ======================================================================= + // Sub-Options Auto-Toggle for Tasks + // ======================================================================= + + + document.addEventListener('DOMContentLoaded', function () { + // Auto-handle visibility and checking for tasks with sub-options + const tasksWithSubOptions = document.querySelectorAll('[id$="OptionsContainer"]'); + + tasksWithSubOptions.forEach(container => { + const taskId = container.id.replace('OptionsContainer', ''); + const masterCheckbox = document.getElementById(taskId); + + if (!masterCheckbox) return; + + function updateVisibility() { + const checked = masterCheckbox.checked; + container.style.display = checked ? 'block' : 'none'; + container.querySelectorAll('input[type="checkbox"]').forEach(cb => cb.checked = checked); + + // Show/hide Password and RMM only if it's installDattoRMM + if (taskId === 'installDattoRMM') { + const pwdBox = document.getElementById('PasswordContainer'); + const rmmBox = document.getElementById('dattoRmmContainer'); + if (pwdBox) pwdBox.style.display = checked ? 'block' : 'none'; + if (rmmBox) rmmBox.style.display = checked ? 'block' : 'none'; + } + } + + masterCheckbox.addEventListener('change', updateVisibility); + updateVisibility(); // call once on load + }); + }); + '@