diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index eb33d70d438..c3757eb74ce 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -304,7 +304,7 @@ SUBSYSTEM_DEF(vote) ) if(!!user.client?.holder) - data["voting"] += list(voting) + data["voting"] = voting for(var/key in choices) data["choices"] += list(list( diff --git a/tgui/packages/tgui/interfaces/Vote.js b/tgui/packages/tgui/interfaces/Vote.js index 93762018b96..a534fc7c011 100644 --- a/tgui/packages/tgui/interfaces/Vote.js +++ b/tgui/packages/tgui/interfaces/Vote.js @@ -1,27 +1,27 @@ -import { useBackend } from "../backend"; -import { Box, Icon, Stack, Button, Section, NoticeBox, LabeledList, Collapsible } from "../components"; -import { Window } from "../layouts"; +import { useBackend } from '../backend'; +import { Box, Icon, Stack, Button, Section, NoticeBox, LabeledList, Collapsible } from '../components'; +import { Window } from '../layouts'; export const Vote = (props, context) => { const { data } = useBackend(context); const { mode, question, lower_admin } = data; - // Adds the voting type to title if there is an ongoing vote - let windowTitle = "Vote"; + /** + * Adds the voting type to title if there is an ongoing vote. + */ + let windowTitle = 'Vote'; if (mode) { - windowTitle += ": " + (question || mode).replace(/^\w/, c => c.toUpperCase()); + windowTitle += ': ' + (question || mode).replace(/^\w/, (c) => c.toUpperCase()); } return ( - {!!lower_admin && ( -
- - -
- )} +
+ + {!!lower_admin && } +
@@ -30,13 +30,17 @@ export const Vote = (props, context) => { ); }; -// Gives access to starting votes +/** + * The create vote options menu. Only upper admins can disable voting. + * @returns A section visible to everyone with vote options. + */ const VoteOptions = (props, context) => { const { act, data } = useBackend(context); const { allow_vote_mode, allow_vote_restart, allow_vote_map, + lower_admin, upper_admin, } = data; @@ -47,23 +51,22 @@ const VoteOptions = (props, context) => { - {!!upper_admin && ( + {!!lower_admin && ( act("toggle_map")}> - {allow_vote_map ? "Enabled" : "Disabled"} + disabled={!upper_admin} + onClick={() => act('toggle_map')}> + {allow_vote_map ? 'Enabled' : 'Disabled'} )} - - {!!upper_admin && ( + {!!lower_admin && ( { mr={!allow_vote_restart ? 1 : 1.6} color="red" checked={!!allow_vote_restart} - onClick={() => act("toggle_restart")}> - {allow_vote_restart ? "Enabled" : "Disabled"} + disabled={!upper_admin} + onClick={() => act('toggle_restart')}> + {allow_vote_restart ? 'Enabled' : 'Disabled'} )} - {!!upper_admin && ( + {!!lower_admin && ( { mr={!allow_vote_mode ? 1 : 1.6} color="red" checked={!!allow_vote_mode} - onClick={() => act("toggle_gamemode")}> - {allow_vote_mode ? "Enabled" : "Disabled"} + disabled={!upper_admin} + onClick={() => act('toggle_gamemode')}> + {allow_vote_mode ? 'Enabled' : 'Disabled'} )} - + {!!lower_admin && ( + + )} @@ -139,16 +146,19 @@ const VoteOptions = (props, context) => { ); }; -// Table to view voters by ckey +/** + * View Voters by ckey. Admin only. + * @returns A collapsible list of voters + */ const VotersList = (props, context) => { const { data } = useBackend(context); const { voting } = data; return ( - +
- {voting.map(voter => { + {voting.map((voter) => { return {voter}; })}
@@ -157,7 +167,10 @@ const VotersList = (props, context) => { ); }; -// Display choices +/** + * The choices panel which displays all options in the list. + * @returns A section visible to all users. + */ const ChoicesPanel = (props, context) => { const { act, data } = useBackend(context); const { choices, selected_choice } = data; @@ -170,13 +183,13 @@ const ChoicesPanel = (props, context) => { {choices.map((choice, i) => ( c.toUpperCase())} + label={choice.name.replace(/^\w/, (c) => c.toUpperCase())} textAlign="right" buttons={ @@ -186,7 +199,8 @@ const ChoicesPanel = (props, context) => { alignSelf="right" mr={2} color="green" - name="vote-yea" /> + name="vote-yea" + /> )} {choice.votes} Votes @@ -202,20 +216,24 @@ const ChoicesPanel = (props, context) => { ); }; -// Countdown timer at the bottom. Includes a cancel vote option for admins +/** + * Countdown timer at the bottom. Includes a cancel vote option for admins. + * @returns A section visible to everyone. + */ const TimePanel = (props, context) => { const { act, data } = useBackend(context); - const { upper_admin, time_remaining } = data; + const { lower_admin, time_remaining } = data; return (
- - Time Remaining: {time_remaining || 0}s - - {!!upper_admin && ( - )}