Skip to content

Commit

Permalink
Merge pull request #169 from the-orange-alliance/fix-nexus-match-editor
Browse files Browse the repository at this point in the history
Allow match editor to work independently of running matches
  • Loading branch information
kyle-flynn authored Sep 26, 2024
2 parents e82b4d5 + 6075346 commit 3333f18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions front-end/src/seasons/fgc-2024/match-detail-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const MatchDetailInfo: FC<
state={match.details.redNexusState}
opposingState={match.details.blueNexusState}
alliance='red'
editMode
onChange={(goal, state) => updateNexus('red', goal, state)}
onOpposingChange={(goal, state) => updateNexus('blue', goal, state)}
/>
Expand Down Expand Up @@ -144,6 +145,7 @@ export const MatchDetailInfo: FC<
state={match.details.blueNexusState}
opposingState={match.details.redNexusState}
alliance='blue'
editMode
onChange={(goal, state) => updateNexus('blue', goal, state)}
onOpposingChange={(goal, state) => updateNexus('red', goal, state)}
/>
Expand Down
20 changes: 15 additions & 5 deletions front-end/src/seasons/fgc-2024/nexus-sheets/nexus-scoresheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface NexusScoresheetProps {
side: 'near' | 'far' | 'both';
scorekeeperView?: boolean;
allowForceRelease?: boolean;
editMode?: boolean;
}

const StairGoal = styled(Box)((props: { alliance: Alliance }) => ({
Expand Down Expand Up @@ -62,7 +63,8 @@ const NexusScoresheet: React.FC<NexusScoresheetProps> = ({
onOpposingChange,
side,
scorekeeperView,
allowForceRelease
allowForceRelease,
editMode
}) => {
const cancelQueue = useRef<any[]>([]);

Expand Down Expand Up @@ -172,6 +174,7 @@ const NexusScoresheet: React.FC<NexusScoresheetProps> = ({
alliance={alliance === 'red' ? 'blue' : 'red'} // intentionally inverted
onForceRelease={(g) => onForceRelease(alliance, g)}
allowForceRelease={!!allowForceRelease}
editMode={editMode}
/>
<Typography
variant='h6'
Expand Down Expand Up @@ -212,6 +215,7 @@ const NexusScoresheet: React.FC<NexusScoresheetProps> = ({
fullWidth={scorekeeperView}
onForceRelease={(g) => onForceRelease(alliance, g)}
allowForceRelease={!!allowForceRelease}
editMode={editMode}
/>
{/* Placeholder for better alignment */}
<SideText variant='h6'>&nbsp;</SideText>
Expand All @@ -230,6 +234,7 @@ interface GoalGridProps {
alliance: Alliance;
onForceRelease?: (goal: keyof AllianceNexusGoalState) => void;
allowForceRelease: boolean;
editMode?: boolean;
}

interface CenterGoalGridProps extends GoalGridProps {
Expand Down Expand Up @@ -427,6 +432,7 @@ interface GoalToggleProps {
single?: boolean;
onForceRelease?: () => void;
allowForceRelease: boolean;
editMode?: boolean;
}

const BallCheckbox = styled(Checkbox)(
Expand All @@ -453,15 +459,17 @@ const GoalToggle: React.FC<GoalToggleProps> = ({
onChange,
single,
onForceRelease,
allowForceRelease
allowForceRelease,
editMode
}) => {
const matchState = useRecoilValue(matchStateAtom);

// If the food has been produced, we'll disable the toggle during and before the match is complete
// after the match, we'll allow the toggles to be changed
if (
state === NexusGoalState.Produced &&
matchState < MatchState.MATCH_COMPLETE
matchState < MatchState.MATCH_COMPLETE &&
!editMode
) {
disabled = true;
}
Expand Down Expand Up @@ -511,7 +519,8 @@ const GoalToggle: React.FC<GoalToggleProps> = ({
<>
{NexusGoalState.Produced === state &&
allowForceRelease &&
matchState < MatchState.MATCH_COMPLETE && (
matchState < MatchState.MATCH_COMPLETE &&
!editMode && (
<Box sx={{ position: 'relative', top: '35%', height: 0, px: 1 }}>
<Button
variant='contained'
Expand All @@ -535,7 +544,8 @@ const GoalToggle: React.FC<GoalToggleProps> = ({
width: '100%',
border:
matchState === MatchState.MATCH_IN_PROGRESS &&
state === NexusGoalState.Produced
state === NexusGoalState.Produced &&
!editMode
? '5px dashed orange'
: undefined
}}
Expand Down

0 comments on commit 3333f18

Please sign in to comment.