diff --git a/services/core-api/app/api/projects/major_mine_application/models/major_mine_application.py b/services/core-api/app/api/projects/major_mine_application/models/major_mine_application.py index cca50dfefd..939a438e3d 100644 --- a/services/core-api/app/api/projects/major_mine_application/models/major_mine_application.py +++ b/services/core-api/app/api/projects/major_mine_application/models/major_mine_application.py @@ -4,6 +4,8 @@ from sqlalchemy.schema import FetchedValue from werkzeug.exceptions import BadRequest, NotFound + +from app.api.mines.documents.models.mine_document_bundle import MineDocumentBundle from app.extensions import db from app.config import Config @@ -114,21 +116,30 @@ def generate_list_element(element): def create(cls, project, status_code, - documents=[], + documents=None, add_to_session=True): major_mine_application = cls( project_guid=project.project_guid, status_code=status_code) + documents = documents or [] if add_to_session: major_mine_application.save(commit=False) if documents: + spatial_docs = [doc for doc in documents if doc['major_mine_application_document_type_code'] == 'SPT'] + updated_spatial_docs = MineDocumentBundle.update_spatial_mine_document_with_bundle_id(spatial_docs) + + # update the original documents array with the updated spatial documents + documents = [doc for doc in documents if doc['major_mine_application_document_type_code'] != 'SPT'] + documents.extend(updated_spatial_docs) + for doc in documents: mine_doc = MineDocument( mine_guid=project.mine_guid, document_name=doc.get('document_name'), - document_manager_guid=doc.get('document_manager_guid')) + document_manager_guid=doc.get('document_manager_guid'), + mine_document_bundle_id=doc['mine_document_bundle_id'] if doc.get('mine_document_bundle_id') else None) major_mine_application_doc = MajorMineApplicationDocumentXref( mine_document_guid=mine_doc.mine_document_guid, major_mine_application_id=major_mine_application.major_mine_application_id, diff --git a/services/core-api/app/api/projects/major_mine_application/models/major_mine_application_document_xref.py b/services/core-api/app/api/projects/major_mine_application/models/major_mine_application_document_xref.py index 9bd7d922f9..10a3fa1ac6 100644 --- a/services/core-api/app/api/projects/major_mine_application/models/major_mine_application_document_xref.py +++ b/services/core-api/app/api/projects/major_mine_application/models/major_mine_application_document_xref.py @@ -35,6 +35,7 @@ class MajorMineApplicationDocumentXref(Base): create_user = association_proxy('mine_document', 'create_user') versions = association_proxy('mine_document', 'versions') update_timestamp = association_proxy('mine_document', 'update_timestamp') + mine_document_bundle_id = association_proxy('mine_document', 'mine_document_bundle_id') def __repr__(self): return f'{self.__class__.__name__} {self.major_mine_application_document_xref_guid}' diff --git a/services/minespace-web/src/components/Forms/projects/majorMineApplication/MajorMineApplicationForm.tsx b/services/minespace-web/src/components/Forms/projects/majorMineApplication/MajorMineApplicationForm.tsx index d7758234f6..05145473ef 100644 --- a/services/minespace-web/src/components/Forms/projects/majorMineApplication/MajorMineApplicationForm.tsx +++ b/services/minespace-web/src/components/Forms/projects/majorMineApplication/MajorMineApplicationForm.tsx @@ -136,6 +136,7 @@ const MajorMineApplicationForm: React.FC = ({ ...fileData, major_mine_application_document_type_code: MAJOR_MINES_APPLICATION_DOCUMENT_TYPE_CODE.SPATIAL, + mine_guid: project?.mine_guid, }), }, content: AddSpatialDocumentsModal, @@ -245,8 +246,14 @@ const MajorMineApplicationForm: React.FC = ({ Please upload spatial files to support your application. You must upload at least one KML, KMZ, or Shapefile at a time. Visit{" "} - GIS Shapefile Standards to - learn more about shapefile requirements and standards. + + GIS Shapefile Standards + {" "} + to learn more about shapefile requirements and standards. {isFeatureEnabled(Feature.SPATIAL_BUNDLE) ? ( <> @@ -258,9 +265,9 @@ const MajorMineApplicationForm: React.FC = ({ > Upload Spatial Data - {spatialDocument.length > 0 && ( + {spatial_documents?.length > 0 && ( diff --git a/services/minespace-web/src/tests/components/Forms/projects/majorMineApplication/MajorMineApplicationForm.spec.tsx b/services/minespace-web/src/tests/components/Forms/projects/majorMineApplication/MajorMineApplicationForm.spec.tsx index 352d35bc40..4f28681b2c 100644 --- a/services/minespace-web/src/tests/components/Forms/projects/majorMineApplication/MajorMineApplicationForm.spec.tsx +++ b/services/minespace-web/src/tests/components/Forms/projects/majorMineApplication/MajorMineApplicationForm.spec.tsx @@ -50,6 +50,12 @@ jest.mock( ) ); +jest.mock("@mds/common/components/documents/DocumentTable", () => (props: any) => ( +
+ +
+)); + const initialState = { form: { ADD_MINE_MAJOR_APPLICATION: { @@ -114,4 +120,11 @@ describe("MajorMineApplicationForm", () => { fireEvent.click(fileInput); expect(mockDispatch).toHaveBeenCalled(); }); + + it("should call refreshData when documents are archived", () => { + const { getAllByText } = render(); + const archiveButtons = getAllByText("Archive Documents"); + fireEvent.click(archiveButtons[0]); + expect(props.refreshData).toHaveBeenCalled(); + }); }); diff --git a/services/minespace-web/src/tests/components/Forms/projects/majorMineApplication/__snapshots__/MajorMineApplicationForm.spec.tsx.snap b/services/minespace-web/src/tests/components/Forms/projects/majorMineApplication/__snapshots__/MajorMineApplicationForm.spec.tsx.snap index 61b5738bf7..a4536301dd 100644 --- a/services/minespace-web/src/tests/components/Forms/projects/majorMineApplication/__snapshots__/MajorMineApplicationForm.spec.tsx.snap +++ b/services/minespace-web/src/tests/components/Forms/projects/majorMineApplication/__snapshots__/MajorMineApplicationForm.spec.tsx.snap @@ -157,397 +157,9 @@ exports[`MajorMineApplicationForm renders properly 1`] = ` />
-
-
- -
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - File Name - - - - - - - - - - - -
-
-
- - Category - - - - - - - - - - - -
-
-
- - Uploaded - - - - - - - - - - - -
-
-
- - - - -
- N/A -
-
-
- N/A -
-
-
- -
-
-
-
-
-
-
-
+

GIS Shapefile Standards - to learn more about shapefile requirements and standards. + + to learn more about shapefile requirements and standards.
-
-
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - -
-
- - File Name - - - - - - - - - - - -
-
-
- - Last Modified - - - - - - - - - - - -
-
-
- - Created By - - - - - - - - - - - -
-
-
- -
-
- test.kmz -
-
-
-
- N/A -
-
-
- N/A -
-
-
- -
-
-
-
-
-
-
-
-

-
-
- -
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - File Name - - - - - - - - - - - -
-
-
- - Category - - - - - - - - - - - -
-
-
- - Uploaded - - - - - - - - - - - -
-
-
- - - - -
- N/A -
-
-
- N/A -
-
-
- -
-
-
-
-
-
-
-
+

-
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
-
- - - File Name - - - - - - - - - - - - -
-
- Category - -
- - File Type - - - - - - - - - - - -
-
-
- - Last Modified - - - - - - - - - - - -
-
-
- - Created By - - - - - - - - - - - -
-
-
- - - -
- N/A -
-
-
- .pdf -
-
-
- N/A -
-
-
- create-user@bceid -
-
-
- -
-
-
-
-
-
-
-
+