Initial
This commit is contained in:
23
web/js/src/syncEmailValues.js
Normal file
23
web/js/src/syncEmailValues.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import { debounce } from './helpers';
|
||||
|
||||
// Synchronizes the "Email" input value with "Email login credentials to" input value
|
||||
// based on the "Send welcome email" checkbox state on Add User page
|
||||
export default function handleSyncEmailValues() {
|
||||
const emailInput = document.querySelector('.js-sync-email-input');
|
||||
const sendWelcomeEmailCheckbox = document.querySelector('.js-sync-email-checkbox');
|
||||
const emailCredentialsToInput = document.querySelector('.js-sync-email-output');
|
||||
|
||||
if (!emailInput || !sendWelcomeEmailCheckbox || !emailCredentialsToInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
function syncEmailValues() {
|
||||
emailCredentialsToInput.value = sendWelcomeEmailCheckbox.checked ? emailInput.value : '';
|
||||
}
|
||||
|
||||
emailInput.addEventListener(
|
||||
'input',
|
||||
debounce(() => syncEmailValues())
|
||||
);
|
||||
sendWelcomeEmailCheckbox.addEventListener('change', syncEmailValues);
|
||||
}
|
||||
Reference in New Issue
Block a user