-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MDS-5947] Added ability to link a CRR to a HSRC code in core (#3106)
* MDS-5947 Added support for linking CRRs to code sections * Updated snasphost * MDS-5947 Fixed error when not including linked reports
- Loading branch information
1 parent
d5ef5fd
commit cb0f9fc
Showing
16 changed files
with
567 additions
and
182 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
services/common/src/components/reports/ReportDefinitionFieldSelect.tsx
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,60 @@ | ||
import { formatComplianceCodeReportName } from "@mds/common/redux/utils/helpers"; | ||
import React, { useEffect, useState } from "react"; | ||
import { useSelector } from "react-redux"; | ||
import { Field } from "redux-form"; | ||
|
||
import { getMineReportDefinitionOptions } from "@mds/common/redux/selectors/staticContentSelectors"; | ||
|
||
import RenderSelect from "../forms/RenderSelect"; | ||
import { uniqBy } from "lodash"; | ||
import moment from "moment"; | ||
|
||
export interface ReportDefinitionFieldSelectProps { | ||
id: string; | ||
name: string; | ||
label?: string; | ||
disabled?: boolean; | ||
required?: boolean; | ||
placeholder?: string; | ||
validate?: any[]; | ||
} | ||
|
||
export const ReportDefinitionFieldSelect = (props: ReportDefinitionFieldSelectProps) => { | ||
const mineReportDefinitionOptions = useSelector(getMineReportDefinitionOptions); | ||
|
||
const [formattedMineReportDefinitionOptions, setFormatMineReportDefinitionOptions] = useState([]); | ||
|
||
useEffect(() => { | ||
// Format the mine report definition options for the search bar | ||
const newFormattedMineReportDefinitionOptions = mineReportDefinitionOptions | ||
.filter((m) => { | ||
// Only include reports that are linked to a compliance code that have expired | ||
// Reason: A report definition can only be linked to a single compliance code as it currently stands | ||
return !m.compliance_articles.find((c) => moment().isBefore(moment(c.expiry_date))); | ||
}) | ||
.map((report) => { | ||
return { | ||
label: formatComplianceCodeReportName(report), | ||
value: report.mine_report_definition_guid, | ||
}; | ||
}) | ||
.sort((a, b) => a.label.localeCompare(b.label)); | ||
setFormatMineReportDefinitionOptions(uniqBy(newFormattedMineReportDefinitionOptions, "value")); | ||
}, [mineReportDefinitionOptions]); | ||
|
||
return ( | ||
<Field | ||
component={RenderSelect} | ||
id={props.id} | ||
name={props.name} | ||
label={props.label || "Report Name"} | ||
disabled={props.disabled || false} | ||
props={{ | ||
data: formattedMineReportDefinitionOptions, | ||
}} | ||
required={props.required || false} | ||
placeholder={props.placeholder || "Select a report type"} | ||
validate={props.validate || undefined} | ||
/> | ||
); | ||
}; |
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
Empty file.
6 changes: 6 additions & 0 deletions
6
services/core-api/app/api/exports/static_content/cache_service.py
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,6 @@ | ||
|
||
from app.extensions import cache | ||
from app.api.constants import STATIC_CONTENT_KEY | ||
|
||
def reset_static_content_cache(): | ||
cache.delete(STATIC_CONTENT_KEY) |
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
Oops, something went wrong.