Skip to content

Commit

Permalink
[MDS-5912]adjusting major projects summary document section to have t…
Browse files Browse the repository at this point in the history
…wo file up… (#3099)

* adjusting major projects summary document section to have two file upload buckets

* fixing failing minespace test
  • Loading branch information
asinn134 authored May 14, 2024
1 parent 5cf0c03 commit a72b747
Show file tree
Hide file tree
Showing 14 changed files with 307 additions and 108 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
INSERT INTO
project_summary_document_type(project_summary_document_type_code, description, display_order, active_ind, create_user, update_user)
VALUES
('SPT', 'Spatial Documents', 35, TRUE, 'system-mds', 'system-mds');
41 changes: 39 additions & 2 deletions services/common/src/components/forms/RenderFileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
UploadResult,
} from "@mds/common/utils/fileUploadHelper.interface";
import { BaseInputProps } from "./BaseInput";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCircleQuestion } from "@fortawesome/pro-light-svg-icons";

registerPlugin(FilePondPluginFileValidateSize, FilePondPluginFileValidateType);

Expand Down Expand Up @@ -65,6 +67,8 @@ interface FileUploadProps extends BaseInputProps {
listedFileTypes?: string[];
// true for "We accept most common ${listedFileTypes.join()} files" language + popover
abbrevLabel?: boolean;
// I left abbrevLabel prop alone for the time being as it seems for certain areas we may want to still display the accepted file types below the filepond
newAbbrevLabel?: boolean;
maxFiles?: number;
labelHref: string;

Expand Down Expand Up @@ -92,6 +96,7 @@ const defaultProps = {
labelInstruction:
'<strong>Drag & Drop your files or <span class="filepond--label-action">Browse</span></strong>',
abbrevLabel: false,
newAbbrevLabel: false,
beforeAddFile: () => {},
beforeDropFile: () => {},
file: null,
Expand Down Expand Up @@ -449,7 +454,34 @@ export const FileUpload = (props: FileUploadProps) => {
{props.label}
</a>
);
else return <>{props.label}</>;

if (props.newAbbrevLabel && Object.values(props.acceptedFileTypesMap).length > 0) {
return (
<span>
{props.label}{" "}
<span>
<Popover
content={
<>
<strong>Accepted File Types:</strong>
<p>{Object.keys(props.acceptedFileTypesMap).join(", ")}</p>
</>
}
placement="topLeft"
color="white"
overlayClassName="filepond-filetypes-popover"
>
<span className="form-dashed-underline">
Accepted file types{" "}
<FontAwesomeIcon icon={faCircleQuestion} style={{ width: "15px" }} />
</span>
</Popover>
</span>
</span>
);
}

return <>{props.label}</>;
};

return (
Expand Down Expand Up @@ -479,7 +511,12 @@ export const FileUpload = (props: FileUploadProps) => {
<Form.Item
name={props.input?.name}
required={props.required}
label={getLabel({ label: props.label, labelHref: props.labelHref })}
label={getLabel({
label: props.label,
labelHref: props.labelHref,
newAbbrevLabel: props.newAbbrevLabel,
acceptedFileTypesMap: props.acceptedFileTypesMap,
})}
validateStatus={
props.meta?.touched
? (props.meta?.error && "error") || (props.meta?.warning && "warning")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getDropdownProvinceOptions } from "@mds/common/redux/selectors/staticCo
import RenderRadioButtons from "../forms/RenderRadioButtons";
import RenderAutoSizeField from "../forms/RenderAutoSizeField";
import CoreMap from "../common/Map";
import { normalizePhone } from "@mds/common/redux/utils/helpers";

export const FacilityOperator: FC = () => {
const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY));
Expand Down Expand Up @@ -233,8 +234,9 @@ export const FacilityOperator: FC = () => {
name="facility_operator.phone_no"
label="Facility Operator Contact Number"
required
validate={[required, phoneNumber]}
validate={[phoneNumber, maxLength(12), required]}
component={RenderField}
normalize={normalizePhone}
/>
</Col>
<Col md={4} sm={5}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import {
phoneNumber,
required,
requiredRadioButton,
maxLength,
} from "@mds/common/redux/utils/Validate";
import { useSelector } from "react-redux";
import { FORM } from "@mds/common/constants";
import RenderField from "../forms/RenderField";
import { getDropdownMunicipalities } from "@mds/common/redux/selectors/staticContentSelectors";
import RenderSelect from "@mds/common/components/forms/RenderSelect";
import { normalizePhone } from "@mds/common/redux/utils/helpers";

export const LegalLandOwnerInformation: FC = () => {
const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY));
Expand Down Expand Up @@ -89,7 +91,8 @@ export const LegalLandOwnerInformation: FC = () => {
label="Legal Land Owner Contact Number"
component={RenderField}
required={!is_legal_land_owner}
validate={!is_legal_land_owner ? [required, phoneNumber] : []}
validate={!is_legal_land_owner ? [phoneNumber, maxLength(12), required] : []}
normalize={normalizePhone}
/>
</Col>
<Col md={12} sm={24}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ exports[`ReportDetailsForm renders edit mode properly 1`] = `
class="filepond--wrapper"
>
<input
accept="application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/rtf,application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.text-template,application/vnd.oasis.opendocument.text-web,application/vnd.oasis.opendocument.text-master,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,image/jpg,image/jpeg,image/png,image/jp2,image/tiff,image/heic,image/heif,application/dbf,application/vnd.geo+json,application/gml+xml,application/vnd.google-earth.kml+xml,application/vnd.google-earth.kmz,application/octet-stream,text/csv,application/xml,text/xml"
accept="application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/rtf,application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.text-template,application/vnd.oasis.opendocument.text-web,application/vnd.oasis.opendocument.text-master,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,image/jpg,image/jpeg,image/png,image/jp2,image/tiff,image/heic,image/heif,application/vnd.geo+json,application/gml+xml,application/dbf,application/vnd.google-earth.kml+xml,application/vnd.google-earth.kmz,application/octet-stream,text/csv,application/xml,text/xml"
multiple=""
name="file"
type="file"
Expand Down
32 changes: 22 additions & 10 deletions services/common/src/constants/fileTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ export const DOC = {
".rtf": "application/rtf",
};

export const XML = {
".xml": "application/xml",
};

export const CSV = {
".csv": "text/csv",
};

export const OPEN_DOC = {
".odt": "application/vnd.oasis.opendocument.text",
".ott": "application/vnd.oasis.opendocument.text-template",
Expand All @@ -43,12 +51,21 @@ export const MESSAGE = {

export const APPLICATION_OCTET_STREAM = "application/octet-stream";

export const UNIQUELY_SPATIAL = {
export const OTHER_SPATIAL = {
".dbf": "application/dbf",
".geojson": "application/vnd.geo+json",
".gml": "application/gml+xml",
".kml": "application/vnd.google-earth.kml+xml",
".kmz": "application/vnd.google-earth.kmz",
".prj": APPLICATION_OCTET_STREAM,
".sbn": APPLICATION_OCTET_STREAM,
".sbx": APPLICATION_OCTET_STREAM,
".shp": APPLICATION_OCTET_STREAM,
".shx": APPLICATION_OCTET_STREAM,
};

export const UNIQUELY_SPATIAL = {
".geojson": "application/vnd.geo+json",
".gml": "application/gml+xml",
...OTHER_SPATIAL,
".ain": APPLICATION_OCTET_STREAM,
".aih": APPLICATION_OCTET_STREAM,
".atx": APPLICATION_OCTET_STREAM,
Expand All @@ -57,18 +74,13 @@ export const UNIQUELY_SPATIAL = {
".fbx": APPLICATION_OCTET_STREAM,
".ixs": APPLICATION_OCTET_STREAM,
".mxs": APPLICATION_OCTET_STREAM,
".prj": APPLICATION_OCTET_STREAM,
".sbn": APPLICATION_OCTET_STREAM,
".sbx": APPLICATION_OCTET_STREAM,
".shp": APPLICATION_OCTET_STREAM,
".shpz": APPLICATION_OCTET_STREAM,
".shx": APPLICATION_OCTET_STREAM,
".wkt": APPLICATION_OCTET_STREAM,
};

export const SPATIAL = {
...UNIQUELY_SPATIAL,
".csv": "text/csv",
".xml": "application/xml",
...CSV,
...XML,
".shp.xml": "text/xml",
};
1 change: 1 addition & 0 deletions services/common/src/constants/strings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export const PROJECT_SUMMARY_DOCUMENT_TYPE_CODE = {
LOCATION_MAP: "MAP",
DISCHARGE_FACTOR_AMENDMENT: "DFA",
SUPPORTING: "SPR",
SPATIAL: "SPT",
};

export const PROJECT_SUMMARY_DOCUMENT_TYPE_CODE_LOCATION = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,10 +1002,11 @@ def update(self,
# Create or update existing documents.
for doc in documents:
mine_document_guid = doc.get('mine_document_guid')
project_summary_document_type_code = doc.get('project_summary_document_type_code', 'GEN')
if mine_document_guid:
project_summary_doc = ProjectSummaryDocumentXref.find_by_mine_document_guid(
mine_document_guid)
project_summary_doc.project_summary_document_type_code = 'GEN'
project_summary_doc.project_summary_document_type_code = project_summary_document_type_code
else:
mine_doc = MineDocument(
mine_guid=self.mine_guid,
Expand All @@ -1014,7 +1015,7 @@ def update(self,
project_summary_doc = ProjectSummaryDocumentXref(
mine_document_guid=mine_doc.mine_document_guid,
project_summary_id=self.project_summary_id,
project_summary_document_type_code='GEN')
project_summary_document_type_code=project_summary_document_type_code)
project_summary_doc.mine_document = mine_doc
self.documents.append(project_summary_doc)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ exports[`ReplaceDocumentModal renders properly 1`] = `
class="filepond--wrapper"
>
<input
accept="application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/rtf,application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.text-template,application/vnd.oasis.opendocument.text-web,application/vnd.oasis.opendocument.text-master,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,image/jpg,image/jpeg,image/png,image/jp2,image/tiff,image/heic,image/heif,application/dbf,application/vnd.geo+json,application/gml+xml,application/vnd.google-earth.kml+xml,application/vnd.google-earth.kmz,application/octet-stream,text/csv,application/xml,text/xml"
accept="application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/rtf,application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.text-template,application/vnd.oasis.opendocument.text-web,application/vnd.oasis.opendocument.text-master,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,image/jpg,image/jpeg,image/png,image/jp2,image/tiff,image/heic,image/heif,application/vnd.geo+json,application/gml+xml,application/dbf,application/vnd.google-earth.kml+xml,application/vnd.google-earth.kmz,application/octet-stream,text/csv,application/xml,text/xml"
multiple=""
name="file"
type="file"
Expand Down
Loading

0 comments on commit a72b747

Please sign in to comment.