[MIRROR] Job refactor 2: less hardcoded lists (#7410)

* Job refactor 2: less hardcoded lists

* CRITICAL DEP 1

* CRITCAL DEP 2

* Update nanotrasen_admiral.dm

* Update nanotrasen_admiral.dm

* Update nanotrasen_admiral.dm

Co-authored-by: Rohesie <rohesie@gmail.com>
Co-authored-by: Gandalf <jzo123@hotmail.com>
This commit is contained in:
SkyratBot
2021-08-06 02:42:53 +02:00
committed by GitHub
parent 5fcedca6e5
commit 91070a797c
82 changed files with 852 additions and 664 deletions

View File

@@ -130,7 +130,8 @@
var/datum/browser/panel = new(usr, "banpanel", "Banning Panel", 910, panel_height)
panel.add_stylesheet("admin_panelscss", 'html/admin/admin_panels.css')
panel.add_stylesheet("banpanelcss", 'html/admin/banpanel.css')
if(usr.client.prefs.tgui_fancy) //some browsers (IE8) have trouble with unsupported css3 elements and DOM methods that break the panel's functionality, so we won't load those if a user is in no frills tgui mode since that's for similar compatability support
var/tgui_fancy = usr.client.prefs.tgui_fancy
if(tgui_fancy) //some browsers (IE8) have trouble with unsupported css3 elements and DOM methods that break the panel's functionality, so we won't load those if a user is in no frills tgui mode since that's for similar compatability support
panel.add_stylesheet("admin_panelscss3", 'html/admin/admin_panels_css3.css')
panel.add_script("banpaneljs", 'html/admin/banpanel.js')
var/list/output = list("<form method='get' action='?src=[REF(src)]'>[HrefTokenFormField()]")
@@ -226,6 +227,7 @@
</div>
</div>
"}
if(edit_id)
output += /* SKYRAT EDIT CHANGE - MULTISERVER */{"<label class='inputlabel checkbox'>Mirror edits to matching bans
<input type='checkbox' id='mirroredit' name='mirroredit' value='1'>
@@ -264,62 +266,41 @@
banned_from += query_get_banned_roles.item[1]
qdel(query_get_banned_roles)
var/break_counter = 0
output += "<div class='row'><div class='column'><label class='rolegroup command'><input type='checkbox' name='Command' class='hidden' [usr.client.prefs.tgui_fancy ? " onClick='toggle_checkboxes(this, \"_dep\")'" : ""]>Command</label><div class='content'>"
//all heads are listed twice so have a javascript call to toggle both their checkboxes when one is pressed
//for simplicity this also includes the captain even though it doesn't do anything
for(var/job in GLOB.command_positions)
if(break_counter > 0 && (break_counter % 3 == 0))
output += "<br>"
output += {"<label class='inputlabel checkbox'>[job]
<input type='checkbox' id='[job]_com' name='[job]' class='Command' value='1'[usr.client.prefs.tgui_fancy ? " onClick='toggle_head(this, \"_dep\")'" : ""]>
<div class='inputbox[(job in banned_from) ? " banned" : ""]'></div></label>
"}
break_counter++
output += "</div></div>"
//SKYRAT EDIT ADDITION
output += "<div class='row'><div class='column'><label class='rolegroup command'><input type='checkbox' name='Central Command' class='hidden' [usr.client.prefs.tgui_fancy ? " onClick='toggle_checkboxes(this, \"_dep\")'" : ""]>Central Command</label><div class='content'>"
//all heads are listed twice so have a javascript call to toggle both their checkboxes when one is pressed
//for simplicity this also includes the captain even though it doesn't do anything
for(var/job in GLOB.central_command_positions)
if(break_counter > 0 && (break_counter % 3 == 0))
output += "<br>"
output += {"<label class='inputlabel checkbox'>[job]
<input type='checkbox' id='[job]_com' name='[job]' class='Command' value='1'[usr.client.prefs.tgui_fancy ? " onClick='toggle_head(this, \"_dep\")'" : ""]>
<div class='inputbox[(job in banned_from) ? " banned" : ""]'></div></label>
"}
break_counter++
output += "</div></div>"
//SKYRAT EDIT END
//standard departments all have identical handling
var/list/job_lists = list("Security" = GLOB.security_positions,
"Engineering" = GLOB.engineering_positions,
"Medical" = GLOB.medical_positions,
"Science" = GLOB.science_positions,
"Supply" = GLOB.supply_positions)
for(var/department in job_lists)
//the first element is the department head so they need the same javascript call as above
output += "<div class='column'><label class='rolegroup [ckey(department)]'><input type='checkbox' name='[department]' class='hidden' [usr.client.prefs.tgui_fancy ? " onClick='toggle_checkboxes(this, \"_com\")'" : ""]>[department]</label><div class='content'>"
output += {"<label class='inputlabel checkbox'>[job_lists[department][1]]
<input type='checkbox' id='[job_lists[department][1]]_dep' name='[job_lists[department][1]]' class='[department]' value='1'[usr.client.prefs.tgui_fancy ? " onClick='toggle_head(this, \"_com\")'" : ""]>
<div class='inputbox[(job_lists[department][1] in banned_from) ? " banned" : ""]'></div></label>
"}
break_counter = 1
for(var/job in job_lists[department] - job_lists[department][1]) //skip the first element since it's already been done
if(break_counter % 3 == 0)
output += "<div class='row'>"
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 += "<div class='column'><label class='rolegroup [label_class]'>[department_name]</label><div class='content'>"
for(var/datum/job/job_datum as anything in department.department_jobs)
if(break_counter > 0 && (break_counter % 3 == 0))
output += "<br>"
output += {"<label class='inputlabel checkbox'>[job]
<input type='checkbox' name='[job]' class='[department]' value='1'>
<div class='inputbox[(job in banned_from) ? " banned" : ""]'></div></label>
"}
break_counter++
var/job_name = job_datum.title
if(length(job_datum.departments_list) > 1) //This job is in multiple departments, so we need to check all the boxes.
// Clicking this will also toggle all the other boxes, minus this one.
var/department_index = job_datum.departments_list.Find(department.type)
if(!department_index)
stack_trace("Failed to find a department index for [department.type] in the departments_list of [job_datum.type]")
output += {"<label class='inputlabel checkbox'>[job_name]
<input type='checkbox' id='[job_name]_[department_index]' name='[job_name]' class='[label_class]' value='1'[tgui_fancy ? " onClick='toggle_other_checkboxes(this, \"[length(job_datum.departments_list)]\", \"[department_index]\")'" : ""]>
<div class='inputbox[(job_name in banned_from) ? " banned" : ""]'></div></label>
"}
else
output += {"<label class='inputlabel checkbox'>[job_name]
<input type='checkbox' name='[job_name]' class='[label_class]' value='1'>
<div class='inputbox[(job_name in banned_from) ? " banned" : ""]'></div></label>
"}
output += "</div></div>"
//departments/groups that don't have command staff would throw a javascript error since there's no corresponding reference for toggle_head()
var/list/headless_job_lists = list("Silicon" = GLOB.nonhuman_positions,
"Abstract" = list("Appearance", "Emote", "Deadchat", "OOC"))
for(var/department in headless_job_lists)
output += "<div class='column'><label class='rolegroup [ckey(department)]'><input type='checkbox' name='[department]' class='hidden' [usr.client.prefs.tgui_fancy ? " onClick='toggle_checkboxes(this, \"_com\")'" : ""]>[department]</label><div class='content'>"
break_counter = 0
for(var/job in headless_job_lists[department])
var/list/other_job_lists = list(
"Abstract" = list("Appearance", "Emote", "Deadchat", "OOC"),
)
for(var/department in other_job_lists)
output += "<div class='column'><label class='rolegroup [ckey(department)]'>[department]</label><div class='content'>"
break_counter = 0
for(var/job in other_job_lists[department])
if(break_counter > 0 && (break_counter % 3 == 0))
output += "<br>"
output += {"<label class='inputlabel checkbox'>[job]
@@ -329,8 +310,8 @@
break_counter++
output += "</div></div>"
var/list/long_job_lists = list(
"Service" = GLOB.service_positions,
"Ghost and Other Roles" = list(
ROLE_PAI,
ROLE_BRAINWASHED,
ROLE_DEATHSQUAD,
ROLE_DRONE,
@@ -372,7 +353,7 @@
),//SKYRAT EDIT ADDITION - EXTRA_BANS
)
for(var/department in long_job_lists)
output += "<div class='column'><label class='rolegroup long [ckey(department)]'><input type='checkbox' name='[department]' class='hidden' [usr.client.prefs.tgui_fancy ? " onClick='toggle_checkboxes(this, \"_com\")'" : ""]>[department]</label><div class='content'>"
output += "<div class='column'><label class='rolegroup long [ckey(department)]'>[department]</label><div class='content'>"
break_counter = 0
for(var/job in long_job_lists[department])
if(break_counter > 0 && (break_counter % 10 == 0))
@@ -385,9 +366,10 @@
output += "</div></div>"
output += "</div>"
output += "</form>"
panel.set_content(jointext(output, ""))
panel.set_content(output.Join())
panel.open()
/datum/admins/proc/ban_parse_href(list/href_list)
if(!check_rights(R_BAN))
return