Skip to content

Commit

Permalink
add warning if there are multiple prompts on a stage
Browse files Browse the repository at this point in the history
  • Loading branch information
jthrilly committed Mar 22, 2022
1 parent ab8a15b commit 8604e97
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 32 additions & 5 deletions src/components/sections/MinMaxAlterLimits.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { Number } from '@codaco/ui/lib/components/Fields';
import { ValidatedField } from '../Form';
import IssueAnchor from '../IssueAnchor';
import Tip from '../Tip';

const maxValidation = (value, allValues) => {
const minValue = get(allValues, 'behaviours.minNodes', null);
Expand Down Expand Up @@ -38,6 +39,10 @@ const MinMaxAlterLimits = () => {
const getFormValue = formValueSelector('edit-stage');
const currentMinValue = useSelector((state) => getFormValue(state, 'behaviours.minNodes'));
const currentMaxValue = useSelector((state) => getFormValue(state, 'behaviours.maxNodes'));
const hasMultiplePrompts = useSelector((state) => {
const prompts = getFormValue(state, 'prompts');
return !!prompts && prompts.length > 1;
});

const dispatch = useDispatch();
const openDialog = useCallback(
Expand Down Expand Up @@ -76,16 +81,38 @@ const MinMaxAlterLimits = () => {
<Section
title="Set minimum or maximum alter numbers"
summary={(
<p>
This feature allows you to specify that a minimum or maximum number of alters that can
be named. These limits apply to the stage as a whole, regardless of the number of
prompts you have.
</p>
<>
<p>
This feature allows you to specify a minimum or maximum number of alters that can
be named on this stage. Please note that these limits apply to the
{' '}
<strong>
stage as a whole
</strong>
, regardless of the number of
prompts you have created.
</p>
</>
)}
toggleable
startExpanded={startExpanded}
handleToggleChange={handleToggleChange}
>
{ hasMultiplePrompts && (
<Tip type="warning">
<p>
You have multiple prompts configured on this stage. Remember that the limits you
specify here apply to the
{' '}
<strong>
stage as a whole
</strong>
. Consider splitting your prompts up into multiple stages, or ensure you take extra
care in the phrasing of your prompts so that you communicate the alter limits
to your participants.
</p>
</Tip>
)}
<FormSection name="behaviours">
<IssueAnchor fieldName="behaviours.minNodes" description="Minimum alters" />
<ValidatedField
Expand Down

0 comments on commit 8604e97

Please sign in to comment.