From 2d8fe9f9216eb6e21e62255107324d5cb3a9a76c Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Sun, 21 Dec 2025 18:36:42 -0500 Subject: [PATCH] Update samy.js --- samy.js | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/samy.js b/samy.js index b0e57a4..38f6127 100644 --- a/samy.js +++ b/samy.js @@ -665,20 +665,38 @@ document.addEventListener("DOMContentLoaded", () => { 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)); + const checked = masterCheckbox.checked; + container.style.display = checked ? "block" : "none"; - 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"; + const subCbs = container.querySelectorAll('input[type="checkbox"]'); + + // Special-case: 1Password sub-options should be user-chosen + if (taskId === "install1Password") { + if (!checked) { + // turning OFF -> clear sub-options + subCbs.forEach((cb) => (cb.checked = false)); + } else { + // turning ON -> if nothing selected yet, default to desktop + const anySelected = Array.from(subCbs).some((cb) => cb.checked); + if (!anySelected) { + const desktop = container.querySelector('input[type="checkbox"][value="desktop"]'); + if (desktop) desktop.checked = true; + } } + } else { + // Default behavior for other tasks (Datto, etc): mirror master checkbox + subCbs.forEach((cb) => (cb.checked = checked)); } + // Keep your Datto UI show/hide behavior + 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(); });