diff --git a/runbot/static/src/css/runbot.css b/runbot/static/src/css/runbot.css index 89c79f32..308d8d68 100644 --- a/runbot/static/src/css/runbot.css +++ b/runbot/static/src/css/runbot.css @@ -418,3 +418,9 @@ body, .table { code { white-space: pre-wrap; } + +input:checked + label.o_runbot_hidden_checkbox, input + label.o_runbot_hidden_checkbox:hover { + color: var(--bs-btn-active-color); + background-color: var(--bs-btn-active-bg); + border-color: var(--bs-btn-active-border-color); +} diff --git a/runbot/static/src/js/runbot.js b/runbot/static/src/js/runbot.js index 4775c9e7..ec43703a 100644 --- a/runbot/static/src/js/runbot.js +++ b/runbot/static/src/js/runbot.js @@ -37,3 +37,42 @@ function copyToClipboard(text) { } navigator.clipboard.writeText(text); } + +/** + * Shamelessly stolen from owl's code, execute a function when the DOM is ready. + * + * @param {*} fn function to call when the DOM is ready. + * @returns {Promise} Promise that can be awaited for after DOM is ready. + */ +function whenReady(fn) { + return new Promise(function (resolve) { + if (document.readyState !== "loading") { + resolve(true); + } else { + document.addEventListener("DOMContentLoaded", resolve, false); + } + }).then(fn || function () { }); +} + +// Hidden checkbox with keyboard support +whenReady(() => { + Array.from( + document.querySelectorAll('label.o_runbot_hidden_checkbox') + ).filter( + (label) => !!label.control + ).forEach( + (label) => { + label.addEventListener( + 'keydown', (event) => { + const { key } = event; + if (key === ' ') { + label.control.checked = !label.control.checked; + event.preventDefault(); + } else if (key === 'Enter') { + label.closest('form').submit(); + } + } + ); + } + ); +}) diff --git a/runbot/templates/frontend.xml b/runbot/templates/frontend.xml index e66d51c8..ffbb3d1e 100644 --- a/runbot/templates/frontend.xml +++ b/runbot/templates/frontend.xml @@ -7,12 +7,10 @@