Job refactor 2: less hardcoded lists (#60578)

* Job refactor 2: less hardcoded lists

* Obsessed can happen
This commit is contained in:
Rohesie
2021-08-05 16:13:05 -03:00
committed by GitHub
parent 392a74693d
commit 6c4134d1ea
67 changed files with 644 additions and 489 deletions
+38 -42
View File
@@ -110,7 +110,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()]")
@@ -195,6 +196,7 @@
</div>
</div>
"}
if(edit_id)
output += {"<label class='inputlabel checkbox'>Mirror edits to matching bans
<input type='checkbox' id='mirroredit' name='mirroredit' value='1'>
@@ -232,48 +234,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>"
//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]
@@ -283,8 +278,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,
@@ -317,7 +312,7 @@
),
)
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))
@@ -330,9 +325,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
+1 -1
View File
@@ -154,7 +154,7 @@ GLOBAL_DATUM(current_anonymous_theme, /datum/anonymous_theme)
priority_announce("As punishment for this station's poor productivity when compared to neighbor stations, names and identities will be restricted until further notice.", "Finance Report", SSstation.announcer.get_rand_alert_sound())
/datum/anonymous_theme/employees/anonymous_name(mob/target)
var/is_head_of_staff = target.mind.assigned_role.departments & DEPARTMENT_COMMAND
var/is_head_of_staff = target.mind.assigned_role.departments_bitflags & DEPARTMENT_BITFLAG_COMMAND
var/name = "[is_head_of_staff ? "Manager" : "Employee"] "
for(var/i in 1 to 6)
if(prob(30) || i == 1)