UX: Add a required attribute to password of the chosen action is delete on blogs page management

This commit is contained in:
franck 2024-12-08 11:02:26 +01:00
parent 227cccc332
commit 7ae2acbd3a
No known key found for this signature in database
GPG key ID: BC0939B7E6CF71E7

View file

@ -11,6 +11,18 @@ dotclear.ready(() => {
dotclear.condSubmit('#form-blogs td input[type=checkbox]', '#form-blogs #do-action');
dotclear.responsiveCellHeaders(document.querySelector('#form-blogs table'), '#form-blogs table', 1);
// If password is mandatory for action, set the field as required
const password = document.getElementById('pwd');
const action = document.querySelector('select[name="action"]');
if (password && action) {
const setRequired = () => {
if (action.value === 'delete') password.setAttribute('required', 'required');
else password.removeAttribute('required');
};
setRequired();
action.addEventListener('change', setRequired);
}
// Ask confirmation before blog(s) deletion
document.getElementById('form-blogs')?.addEventListener('submit', (event) => {
if (document.querySelector('select[name="action"]')?.value === 'delete') {