-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from adhocteam/js-285-prevent-updating-of-rep…
…orts Prevent updating of reports
- Loading branch information
Showing
23 changed files
with
506 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
put: | ||
tags: | ||
- activity-reports | ||
summary: Reset activity report to draft | ||
description: > | ||
Activity reports are not editable when submitted for approval. This | ||
endpoint allows a user to reset a report back to draft mode so that | ||
the report can be edited. | ||
parameters: | ||
- in: path | ||
name: activityReportId | ||
required: true | ||
schema: | ||
type: number | ||
responses: | ||
200: | ||
description: The report that now has a status of "draft" | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '../../index.yaml#/components/schemas/activityReport' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 61 additions & 15 deletions
76
frontend/src/pages/ActivityReport/Pages/Review/Approver/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,97 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Alert } from '@trussworks/react-uswds'; | ||
|
||
import Review from './Review'; | ||
import Approved from './Approved'; | ||
import { REPORT_STATUSES } from '../../../../../Constants'; | ||
import Container from '../../../../../components/Container'; | ||
|
||
const Approver = ({ | ||
onFormReview, | ||
reviewed, | ||
formData, | ||
children, | ||
error, | ||
}) => { | ||
const { managerNotes, additionalNotes, status } = formData; | ||
const review = status === REPORT_STATUSES.SUBMITTED || status === REPORT_STATUSES.NEEDS_ACTION; | ||
const approved = status === REPORT_STATUSES.APPROVED; | ||
const { author } = formData; | ||
|
||
return ( | ||
<> | ||
{review | ||
&& ( | ||
<Review | ||
reviewed={reviewed} | ||
additionalNotes={additionalNotes} | ||
onFormReview={onFormReview} | ||
/> | ||
const renderTopAlert = () => ( | ||
<Alert type="info" noIcon slim className="margin-bottom-1 no-print"> | ||
{review && ( | ||
<> | ||
<span className="text-bold"> | ||
{ author.name } | ||
{' '} | ||
has requested approval for this activity report. | ||
</span> | ||
<br /> | ||
Please review all information in each section before submitting for approval. | ||
</> | ||
)} | ||
{approved | ||
&& ( | ||
<Approved | ||
additionalNotes={additionalNotes} | ||
managerNotes={managerNotes} | ||
/> | ||
{approved && ( | ||
<> | ||
This report has been approved and is no longer editable | ||
</> | ||
)} | ||
</Alert> | ||
); | ||
|
||
return ( | ||
<> | ||
{renderTopAlert()} | ||
{children} | ||
<Container skipTopPadding className="margin-top-2 padding-top-2"> | ||
{error && ( | ||
<Alert noIcon className="margin-y-4" type="error"> | ||
<b>Error</b> | ||
<br /> | ||
{error} | ||
</Alert> | ||
)} | ||
{review | ||
&& ( | ||
<Review | ||
reviewed={reviewed} | ||
additionalNotes={additionalNotes} | ||
onFormReview={onFormReview} | ||
/> | ||
)} | ||
{approved | ||
&& ( | ||
<Approved | ||
additionalNotes={additionalNotes} | ||
managerNotes={managerNotes} | ||
/> | ||
)} | ||
</Container> | ||
</> | ||
); | ||
}; | ||
|
||
Approver.propTypes = { | ||
onFormReview: PropTypes.func.isRequired, | ||
reviewed: PropTypes.bool.isRequired, | ||
children: PropTypes.node.isRequired, | ||
error: PropTypes.string, | ||
formData: PropTypes.shape({ | ||
approvingManager: PropTypes.shape({ | ||
name: PropTypes.string, | ||
}), | ||
managerNotes: PropTypes.string, | ||
additionalNotes: PropTypes.string, | ||
status: PropTypes.string, | ||
author: PropTypes.shape({ | ||
name: PropTypes.string, | ||
}), | ||
}).isRequired, | ||
}; | ||
|
||
Approver.defaultProps = { | ||
error: '', | ||
}; | ||
|
||
export default Approver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.