mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 07:38:05 +01:00
Prevent negative open positions in crew manifest (#58300)
* Resolve open position issues in crew manifest * Use the classes helper for multiple classes Co-authored-by: celotajstg <celotajstg@users.noreply.github.com>
This commit is contained in:
@@ -160,6 +160,8 @@
|
||||
"Service" = GLOB.service_positions,
|
||||
"Silicon" = GLOB.nonhuman_positions
|
||||
)
|
||||
var/list/heads = GLOB.command_positions + list("Quartermaster")
|
||||
|
||||
for(var/datum/data/record/t in GLOB.data_core.general)
|
||||
var/name = t.fields["name"]
|
||||
var/rank = t.fields["rank"]
|
||||
@@ -170,7 +172,7 @@
|
||||
if(!manifest_out[department])
|
||||
manifest_out[department] = list()
|
||||
// Append to beginning of list if captain or department head
|
||||
if (rank == "Captain" || (department != "Command" && (rank in GLOB.command_positions)))
|
||||
if (rank == "Captain" || (department != "Command" && (rank in heads)))
|
||||
manifest_out[department] = list(list(
|
||||
"name" = name,
|
||||
"rank" = rank
|
||||
|
||||
@@ -18,14 +18,15 @@
|
||||
|
||||
/datum/crew_manifest/ui_data(mob/user)
|
||||
var/list/positions = list(
|
||||
"Command" = 0,
|
||||
"Security" = 0,
|
||||
"Engineering" = 0,
|
||||
"Medical" = 0,
|
||||
"Science" = 0,
|
||||
"Supply" = 0,
|
||||
"Service" = 0,
|
||||
"Silicon" = 0
|
||||
"Command" = list("exceptions" = list(), "open" = 0),
|
||||
"Security" = list("exceptions" = list(), "open" = 0),
|
||||
"Engineering" = list("exceptions" = list(), "open" = 0),
|
||||
"Medical" = list("exceptions" = list(), "open" = 0),
|
||||
"Misc" = list("exceptions" = list(), "open" = 0),
|
||||
"Science" = list("exceptions" = list(), "open" = 0),
|
||||
"Supply" = list("exceptions" = list(), "open" = 0),
|
||||
"Service" = list("exceptions" = list(), "open" = 0),
|
||||
"Silicon" = list("exceptions" = list(), "open" = 0)
|
||||
)
|
||||
var/list/departments = list(
|
||||
list("flag" = DEPARTMENT_COMMAND, "name" = "Command"),
|
||||
@@ -39,12 +40,18 @@
|
||||
)
|
||||
|
||||
for(var/job in SSjob.occupations)
|
||||
for(var/department in departments)
|
||||
// Check if the job is part of a department using its flag
|
||||
// Will return true for Research Director if the department is Science or Command, for example
|
||||
if(job["departments"] & department["flag"])
|
||||
// Add open positions to current department
|
||||
positions[department["name"]] += (job["total_positions"] - job["current_positions"])
|
||||
// Check if there are additional open positions or if there is no limit
|
||||
if ((job["total_positions"] > 0 && job["total_positions"] > job["current_positions"]) || (job["total_positions"] == -1))
|
||||
for(var/department in departments)
|
||||
// Check if the job is part of a department using its flag
|
||||
// Will return true for Research Director if the department is Science or Command, for example
|
||||
if(job["departments"] & department["flag"])
|
||||
if(job["total_positions"] == -1)
|
||||
// Add job to list of exceptions, meaning it does not have a position limit
|
||||
positions[department["name"]]["exceptions"] += list(job["title"])
|
||||
else
|
||||
// Add open positions to current department
|
||||
positions[department["name"]]["open"] += (job["total_positions"] - job["current_positions"])
|
||||
|
||||
return list(
|
||||
"manifest" = GLOB.data_core.get_manifest(),
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { classes } from 'common/react';
|
||||
import { useBackend } from "../backend";
|
||||
import { Icon, Section, Table } from "../components";
|
||||
import { Icon, Section, Table, Tooltip } from "../components";
|
||||
import { Window } from "../layouts";
|
||||
|
||||
const commandJobs = [
|
||||
"Captain",
|
||||
"Head of Personnel",
|
||||
"Head of Security",
|
||||
"Chief Engineer",
|
||||
@@ -17,12 +17,13 @@ export const CrewManifest = (props, context) => {
|
||||
return (
|
||||
<Window title="Crew Manifest" width={350} height={500}>
|
||||
<Window.Content scrollable>
|
||||
{Object.entries(manifest).map(([department, crew]) => (
|
||||
{Object.entries(manifest).map(([dept, crew]) => (
|
||||
<Section
|
||||
className={"CrewManifest--" + department}
|
||||
key={department}
|
||||
className={"CrewManifest--" + dept}
|
||||
key={dept}
|
||||
title={
|
||||
department + " (" + positions[department] + " positions open)"
|
||||
dept + (dept !== "Misc"
|
||||
? ` (${positions[dept].open} positions open)` : "")
|
||||
}
|
||||
>
|
||||
<Table>
|
||||
@@ -32,24 +33,56 @@ export const CrewManifest = (props, context) => {
|
||||
{crewMember.name}
|
||||
</Table.Cell>
|
||||
<Table.Cell
|
||||
className={
|
||||
"CrewManifest__Cell CrewManifest__Cell--"
|
||||
+ (crewMember.rank === "Captain" ? "Captain" : "Command")
|
||||
}
|
||||
className={classes([
|
||||
"CrewManifest__Cell",
|
||||
"CrewManifest__Icons",
|
||||
])}
|
||||
collapsing
|
||||
>
|
||||
{positions[dept].exceptions.includes(crewMember.rank) && (
|
||||
<Icon className="CrewManifest__Icon" name="infinity">
|
||||
<Tooltip
|
||||
content="No position limit"
|
||||
position="bottom"
|
||||
/>
|
||||
</Icon>
|
||||
)}
|
||||
{crewMember.rank === "Captain" && (
|
||||
<Icon
|
||||
className={classes([
|
||||
"CrewManifest__Icon",
|
||||
"CrewManifest__Icon--Command",
|
||||
])}
|
||||
name="star"
|
||||
>
|
||||
<Tooltip
|
||||
content="Captain"
|
||||
position="bottom"
|
||||
/>
|
||||
</Icon>
|
||||
)}
|
||||
{commandJobs.includes(crewMember.rank) && (
|
||||
<Icon
|
||||
name={
|
||||
crewMember.rank === "Captain" ? "star" : "chevron-up"
|
||||
}
|
||||
/>
|
||||
className={classes([
|
||||
"CrewManifest__Icon",
|
||||
"CrewManifest__Icon--Command",
|
||||
"CrewManifest__Icon--Chevron",
|
||||
])}
|
||||
name="chevron-up"
|
||||
>
|
||||
<Tooltip
|
||||
content="Member of command"
|
||||
position="bottom"
|
||||
/>
|
||||
</Icon>
|
||||
)}
|
||||
</Table.Cell>
|
||||
<Table.Cell
|
||||
className={"CrewManifest__Cell"}
|
||||
className={classes([
|
||||
"CrewManifest__Cell",
|
||||
"CrewManifest__Cell--Rank",
|
||||
])}
|
||||
collapsing
|
||||
color="label"
|
||||
>
|
||||
{crewMember.rank}
|
||||
</Table.Cell>
|
||||
|
||||
@@ -16,6 +16,7 @@ $border-radius: base.$border-radius !default;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
font-family: Verdana, sans-serif;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ $department_map: (
|
||||
'Security': colors.$red,
|
||||
'Engineering': colors.$orange,
|
||||
'Medical': colors.$teal,
|
||||
'Misc': colors.$white,
|
||||
'Science': colors.$purple,
|
||||
'Supply': colors.$brown,
|
||||
'Service': colors.$green,
|
||||
@@ -28,14 +29,30 @@ $department_map: (
|
||||
&__Cell {
|
||||
padding: 3px 0;
|
||||
|
||||
&--Captain {
|
||||
color: colors.$yellow;
|
||||
padding: 3px 8px;
|
||||
&--Rank {
|
||||
color: colors.$label;
|
||||
}
|
||||
}
|
||||
|
||||
&__Icons {
|
||||
padding: 3px 9px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
&__Icon {
|
||||
color: colors.$label;
|
||||
position: relative;
|
||||
|
||||
&:not(:last-child) {
|
||||
margin-right: 7px;
|
||||
}
|
||||
|
||||
&--Chevron {
|
||||
padding-right: 2px;
|
||||
}
|
||||
|
||||
&--Command {
|
||||
color: colors.$yellow;
|
||||
padding: 3px 9px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user