From f932d71cc8f8c52c2e5f81d347a6b9ba03fb6dfe Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 1 Sep 2021 01:49:39 +0200 Subject: [PATCH] [MIRROR] Admins Can Once Again Click Ban Panel Categories to Toggle Their Checkboxes (#7896) * Admins Can Once Again Click Ban Panel Categories to Toggle Their Checkboxes (#60904) * Re-Adds Header Checkboxes - Ban Panel categories can now be clicked to click all the checkboxes in their category - Adds a new js method called header_click_all_checkboxes whichs clicks all the checkboxes whose class is the hidden checkbox's name Re-introduces a function that was lost with #60578 (6c4134d1eaa34f4ebbf1ea763f3d9fdb00a55620) , closes #60903 (Admins being unable to click on the ban category and check all subcheckboxes). The method was largely copied, but was changed to comply with the toggle_other_checkboxes() method introduced with the aforementioned PR by replacing a .checked assignment with a .click() call to ensure that duplicate entries are properly marked Admins can now click categories to more easily ban people from all entries in that category. Demonstrated below to show that checkboxes are being toggled correctly in all relevant categories Co-authored-by: John Willard <53777086+JohnFulpWillard@ users.noreply.github.com> * Admins Can Once Again Click Ban Panel Categories to Toggle Their Checkboxes Co-authored-by: Beatrice <83368538+SpaceDragon00@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@ users.noreply.github.com> --- code/modules/admin/sql_ban_system.dm | 7 ++++--- html/admin/banpanel.js | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/code/modules/admin/sql_ban_system.dm b/code/modules/admin/sql_ban_system.dm index 82816b5da25..58672366631 100644 --- a/code/modules/admin/sql_ban_system.dm +++ b/code/modules/admin/sql_ban_system.dm @@ -280,7 +280,8 @@ for(var/datum/job_department/department as anything in SSjob.joinable_departments) var/label_class = department.label_class var/department_name = department.department_name - output += "
" + output += "
" for(var/datum/job/job_datum as anything in department.department_jobs) if(break_counter > 0 && (break_counter % 3 == 0)) output += "
" @@ -307,7 +308,7 @@ "Abstract" = list("Appearance", "Emote", "Deadchat", "OOC"), ) for(var/department in other_job_lists) - output += "
" + output += "
" break_counter = 0 for(var/job in other_job_lists[department]) if(break_counter > 0 && (break_counter % 3 == 0)) @@ -362,7 +363,7 @@ ),//SKYRAT EDIT ADDITION - EXTRA_BANS ) for(var/department in long_job_lists) - output += "
" + output += "
" break_counter = 0 for(var/job in long_job_lists[department]) if(break_counter > 0 && (break_counter % 10 == 0)) diff --git a/html/admin/banpanel.js b/html/admin/banpanel.js index 3352617c5ab..e481cd2fc2a 100644 --- a/html/admin/banpanel.js +++ b/html/admin/banpanel.js @@ -8,3 +8,12 @@ function toggle_other_checkboxes(source, copycats_str, our_index_str) { document.getElementById(source.id.slice(0, -1) + i).checked = source.checked; } } + +function header_click_all_checkboxes(source) { + var checkboxes = document.getElementsByClassName(source.name); + for(var i = 0, n = checkboxes.length; i < n; i++) { + if(checkboxes[i].checked != source.checked && checkboxes[i] != source) { + checkboxes[i].click(); + } + } +}