Skip to content

Commit

Permalink
Added some explanation text to the cutoff modal.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfly committed Sep 7, 2017
1 parent 03def6c commit f67cf2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion WcaOnRails/app/javascript/edit-events/modals/Cutoff.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import React from 'react'
import events from 'wca/events.js.erb'
import formats from 'wca/formats.js.erb'
import AttemptResultInput from './AttemptResultInput'
import { attemptResultToString, roundIdToString, matchResult } from './utils'
import {
pluralize,
matchResult,
roundIdToString,
attemptResultToString,
} from './utils'

export default {
Title({ wcifRound }) {
Expand Down Expand Up @@ -36,6 +41,12 @@ export default {
onChange(newCutoff);
};

let explanationText = null;
if(cutoff) {
explanationText = `Competitors get ${pluralize(cutoff.numberOfAttempts, "attempt")} to get ${matchResult(cutoff.attemptResult, wcifEvent.id)}.`;
explanationText += ` If they succeed, they get to do all ${formats.byId[wcifRound.format].expected_solve_count} solves.`;
}

return (
<div>
<div className="form-group">
Expand Down Expand Up @@ -74,6 +85,8 @@ export default {
</div>
</div>
)}

{explanationText}
</div>
);
},
Expand Down
2 changes: 1 addition & 1 deletion WcaOnRails/app/javascript/edit-events/modals/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function matchResult(attemptResult, eventId, { short } = {}) {
return `${comparisonString} ${attemptResultToString(attemptResult, eventId, { short })}`;
}

let pluralize = function(count, word, { fixed, abbreviate } = {}) {
export function pluralize(count, word, { fixed, abbreviate } = {}) {
let countStr = (fixed && count % 1 > 0) ? count.toFixed(fixed) : count;
let countDesc = abbreviate ? word[0] : " " + (count == 1 ? word : word + "s");
return countStr + countDesc;
Expand Down

0 comments on commit f67cf2c

Please sign in to comment.