1
0
Files
breadcrumb-the-shire/web/js/components/app-settings-audit.js
fs 5f3aff08cb refactor(settings/audit): conditional retention disclosure + flat layout
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) <noreply@anthropic.com>
2026-04-25 11:50:04 +02:00

25 lines
837 B
JavaScript

/**
* 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,
});