Commit f796093e authored by Paul Kaplan's avatar Paul Kaplan

Revise comments to clarify functionality

parent bc3a454f
...@@ -34,8 +34,8 @@ class FormStep extends React.Component { ...@@ -34,8 +34,8 @@ class FormStep extends React.Component {
} }
render () { render () {
const {onNext, children, isWaiting, nextLabel} = this.props; const {onNext, children, isWaiting, nextLabel} = this.props;
// Allow submit to be force-enabled by submitEnabled prop. Otherwise use form validation, // Submit button is enabled if form isn't already submitting, and either the form passes validation,
// with default being not-submittable. // or the submitEnabled prop is true. This lets submitEnabled prop override validation.
const submitEnabled = (this.props.submitEnabled || this.state.valid) && !isWaiting; const submitEnabled = (this.props.submitEnabled || this.state.valid) && !isWaiting;
const submitDisabledParam = submitEnabled ? {} : {disabled: 'disabled'}; const submitDisabledParam = submitEnabled ? {} : {disabled: 'disabled'};
return ( return (
......
...@@ -19,8 +19,8 @@ const {reportOptionsShape, REPORT_OPTIONS} = require('./report-options.js'); ...@@ -19,8 +19,8 @@ const {reportOptionsShape, REPORT_OPTIONS} = require('./report-options.js');
require('../../forms/button.scss'); require('../../forms/button.scss');
require('./modal.scss'); require('./modal.scss');
// Progression component only addresses steps by number, but this flow // The Progression component uses numbers to track which step it's on, but that's
// may skip steps so the code is easier to read with a map. // hard to read. Make the code easier to read by giving each step number a label.
const STEPS = { const STEPS = {
category: 0, category: 0,
textInput: 1, textInput: 1,
...@@ -66,6 +66,11 @@ class ReportModal extends React.Component { ...@@ -66,6 +66,11 @@ class ReportModal extends React.Component {
const contentLabel = intl.formatMessage({id: `report.${type}`}); const contentLabel = intl.formatMessage({id: `report.${type}`});
const categoryRequiredMessage = intl.formatMessage({id: 'report.reasonMissing'}); const categoryRequiredMessage = intl.formatMessage({id: 'report.reasonMissing'});
const category = reportOptions.find(o => o.value === this.state.categoryValue) || reportOptions[0]; const category = reportOptions.find(o => o.value === this.state.categoryValue) || reportOptions[0];
// Confirmation step is shown if a report has been submitted, even if state is reset by closing the modal.
// This prevents multiple report submission within the same session because submission is stored in redux.
const step = isConfirmed ? STEPS.confirmation : this.state.step;
return ( return (
<Modal <Modal
useStandardSizes useStandardSizes
...@@ -85,7 +90,8 @@ class ReportModal extends React.Component { ...@@ -85,7 +90,8 @@ class ReportModal extends React.Component {
<FormattedMessage id="report.error" /> <FormattedMessage id="report.error" />
</div> </div>
)} )}
<Progression step={isConfirmed ? STEPS.confirmation : this.state.step}> <Progression step={step}>
{/* Category selection step */}
<FormStep <FormStep
nextLabel={{id: 'general.next'}} nextLabel={{id: 'general.next'}}
onNext={this.handleSetCategory} onNext={this.handleSetCategory}
...@@ -118,6 +124,8 @@ class ReportModal extends React.Component { ...@@ -118,6 +124,8 @@ class ReportModal extends React.Component {
}} }}
/> />
</FormStep> </FormStep>
{/* Text input step */}
<FormStep <FormStep
isWaiting={isWaiting} isWaiting={isWaiting}
nextLabel={{id: 'report.send'}} nextLabel={{id: 'report.send'}}
...@@ -147,6 +155,8 @@ class ReportModal extends React.Component { ...@@ -147,6 +155,8 @@ class ReportModal extends React.Component {
}} }}
/> />
</FormStep> </FormStep>
{/* Confirmation step */}
<FormStep <FormStep
submitEnabled submitEnabled
nextLabel={{id: 'general.close'}} nextLabel={{id: 'general.close'}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment