From 65324a21d293a9a0b08f9ba5ee16db1e363bedcf Mon Sep 17 00:00:00 2001 From: Wes Cutting Date: Wed, 25 Oct 2023 09:56:45 -0500 Subject: [PATCH 1/2] Modify reason list with deprecation check --- .../Steps/ExplanationOfProgress/ExplanationOfProgress.graphql | 1 + .../Steps/ExplanationOfProgress/ExplanationOfProgress.tsx | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.graphql b/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.graphql index 0e37c23b3c..dac4e1ae94 100644 --- a/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.graphql +++ b/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.graphql @@ -9,6 +9,7 @@ fragment ExplanationOfProgressStep on ProgressReport { ahead behind onTime + deprecated } reasons { ...SecuredStringList diff --git a/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx b/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx index 8ff338b7fe..2ae4f5bbba 100644 --- a/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx +++ b/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx @@ -170,8 +170,10 @@ export const ExplanationOfProgress: StepComponent = ({ report }) => { !optionsByGroup.deprecated.includes(reason) + )} layout="column" disabled={!explanation.reasons.canEdit} /> From 2032d0a15a853ca935bdadee171e1741aced00de Mon Sep 17 00:00:00 2001 From: Wes Cutting Date: Thu, 26 Oct 2023 16:30:00 -0500 Subject: [PATCH 2/2] Show deprecated reasons as disabled --- .../ExplanationOfProgress.tsx | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx b/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx index 2ae4f5bbba..894b1b9c3c 100644 --- a/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx +++ b/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx @@ -123,7 +123,7 @@ export const ExplanationOfProgress: StepComponent = ({ report }) => { autoSubmit keepDirtyOnReinitialize > - {({ handleSubmit, values: { group }, submitting }) => ( + {({ handleSubmit, values: { group, reasons }, submitting }) => ( { name="reasons" label="Select a reason" required - options={optionsByGroup[group].filter( - (reason) => !optionsByGroup.deprecated.includes(reason) - )} layout="column" disabled={!explanation.reasons.canEdit} - /> + > + {optionsByGroup[group].flatMap((reason) => { + const isDeprecated = + optionsByGroup.deprecated.includes(reason); + if (isDeprecated && reason !== reasons) { + // Don't even show deprecated options if they are not currently selected + return []; + } + return ( + + ); + })} + )}