From 5f3aff08cb0d0f1204f70dfae53b38eced297cde Mon Sep 17 00:00:00 2001 From: fs Date: Sat, 25 Apr 2026 11:50:04 +0200 Subject: [PATCH] refactor(settings/audit): conditional retention disclosure + flat layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drops the wrapping details-card so the audit toggle and retention input read like the email page. The audit switch now uses role="switch" and a new app-settings-audit component (built on the existing createConditionalToggleInit primitive) hides the retention block when audit is disabled — the input is meaningless without audit on, and the control state syncs automatically on toggle. The redundant info blockquote and the toggle's paraphrased DB description are gone. Co-Authored-By: Claude Opus 4.7 (1M context) --- pages/admin/settings/audit(default).phtml | 35 +++++++------------ .../FrontendRuntimeContractSupport.php | 1 + web/js/app-init.js | 5 +++ web/js/components/app-settings-audit.js | 24 +++++++++++++ 4 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 web/js/components/app-settings-audit.js diff --git a/pages/admin/settings/audit(default).phtml b/pages/admin/settings/audit(default).phtml index 5e76b47..b80f581 100644 --- a/pages/admin/settings/audit(default).phtml +++ b/pages/admin/settings/audit(default).phtml @@ -46,37 +46,26 @@ $disabledAttr = $isReadOnly ? 'disabled' : ''; require templatePath('partials/app-details-titlebar.phtml'); ?> -
-
- - - - - - -
-
- -
- + +
+ +
>
-
+
diff --git a/tests/Architecture/FrontendRuntimeContractSupport.php b/tests/Architecture/FrontendRuntimeContractSupport.php index 357f48c..65a89d5 100644 --- a/tests/Architecture/FrontendRuntimeContractSupport.php +++ b/tests/Architecture/FrontendRuntimeContractSupport.php @@ -27,6 +27,7 @@ trait FrontendRuntimeContractSupport 'web/js/components/app-custom-field-options-toggle.js', 'web/js/components/app-tenant-sso-toggle.js', 'web/js/components/app-settings-telemetry.js', + 'web/js/components/app-settings-audit.js', 'web/js/components/app-standard-detail-page.js', 'web/js/components/app-auto-submit.js', 'modules/bookmarks/web/js/components/app-bookmark-save.js', diff --git a/web/js/app-init.js b/web/js/app-init.js index 497c25e..cc5aee9 100644 --- a/web/js/app-init.js +++ b/web/js/app-init.js @@ -20,6 +20,7 @@ import { initCustomFieldOptionsToggle } from './components/app-custom-field-opti import { initTenantSsoToggle } from './components/app-tenant-sso-toggle.js'; import { initTenantLdapToggle } from './components/app-tenant-ldap-toggle.js'; import { initTelemetrySettings } from './components/app-settings-telemetry.js'; +import { initSettingsAudit } from './components/app-settings-audit.js'; import { initStandardDetailPages } from './components/app-standard-detail-page.js'; import { initAutoSubmit } from './components/app-auto-submit.js'; import { initTabs } from './components/app-tabs.js'; @@ -196,6 +197,10 @@ const bootRuntime = async () => { scope: 'global', configPath: 'components.settingsTelemetry', }); + runtime.register('settings-audit', initSettingsAudit, { + scope: 'global', + configPath: 'components.settingsAudit', + }); runtime.register('auto-submit', initAutoSubmit, { scope: 'global', configPath: 'components.autoSubmit', diff --git a/web/js/components/app-settings-audit.js b/web/js/components/app-settings-audit.js new file mode 100644 index 0000000..214ef5f --- /dev/null +++ b/web/js/components/app-settings-audit.js @@ -0,0 +1,24 @@ +/** + * Shows/hides audit retention field based on the audit-enabled toggle. + */ +import { syncControlState, createConditionalToggleInit } from '../core/app-conditional-controls.js'; + +const initRoot = (root) => { + const enabledInput = root.querySelector('[data-audit-enabled-toggle]'); + const dependent = root.querySelector('[data-audit-when-enabled]'); + if (!(enabledInput instanceof HTMLInputElement) || !(dependent instanceof HTMLElement)) { + return null; + } + const sync = () => syncControlState(dependent, enabledInput.checked); + enabledInput.addEventListener('change', sync); + sync(); + return () => { + enabledInput.removeEventListener('change', sync); + }; +}; + +export const initSettingsAudit = createConditionalToggleInit({ + rootSelector: '[data-settings-audit-root]', + boundKey: 'settingsAuditBound', + initRoot, +});