Added Checkbox Controller javascript

This commit is contained in:
2026-01-19 19:34:59 -05:00
parent bcdd515cf1
commit 5649ba05cd
2 changed files with 27 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
document.addEventListener("turbo:load", () => {
const selectAllBox = document.getElementById("select-all-batches");
const checkboxes = document.querySelectorAll(".item-checkbox");
if (selectAllBox) {
selectAllBox.addEventListener("change", function() {
checkboxes.forEach((checkbox) => {
checkbox.checked = this.checked;
});
});
// Optional: Uncheck "Select All" if an individual box is unchecked
checkboxes.forEach((checkbox) => {
checkbox.addEventListener("change", () => {
if (!checkbox.checked) {
selectAllBox.checked = false;
} else if (Array.from(checkboxes).every(c => c.checked)) {
selectAllBox.checked = true;
}
});
});
}
});

View File

@@ -12,8 +12,10 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener
# Load the javascript to support the autocomplete forms # Load the javascript to support the autocomplete forms
def view_layouts_base_html_head(context = {}) def view_layouts_base_html_head(context = {})
js = javascript_include_tag 'application', :plugin => 'redmine_qbo' logger.info("IssuesFormHookListener.view_layouts_base_html_head")
js += javascript_include_tag 'autocomplete-rails', :plugin => 'redmine_qbo' js = javascript_include_tag 'application.js', :plugin => 'redmine_qbo'
js += javascript_include_tag 'autocomplete-rails.js', :plugin => 'redmine_qbo'
js += javascript_include_tag 'checkbox_controller.js', :plugin => 'redmine_qbo'
return js return js
end end