From 45b03bb350b3601fae579199aaa500c0cd2789cc Mon Sep 17 00:00:00 2001 From: divyav-aot Date: Fri, 10 Nov 2023 13:27:20 -0500 Subject: [PATCH 1/2] hot fix for harms download attachment not included issue --- .../FOI/customComponents/Records/index.js | 314 ++++++++++++------ 1 file changed, 204 insertions(+), 110 deletions(-) diff --git a/forms-flow-web/src/components/FOI/customComponents/Records/index.js b/forms-flow-web/src/components/FOI/customComponents/Records/index.js index 825ce3d26..764b4ec1f 100644 --- a/forms-flow-web/src/components/FOI/customComponents/Records/index.js +++ b/forms-flow-web/src/components/FOI/customComponents/Records/index.js @@ -122,8 +122,8 @@ import { isScanningTeam } from "../../../../helper/FOI/helper"; import { MinistryNeedsScanning } from "../../../../constants/FOI/enum"; //import {convertBytesToMB} from "../../../../components/FOI/customComponents/FileUpload/util"; import FOI_COMPONENT_CONSTANTS from "../../../../constants/FOI/foiComponentConstants"; -import MCFPersonal from './MCFPersonal'; -import MSDPersonal from './MSDPersonal'; +import MCFPersonal from "./MCFPersonal"; +import MSDPersonal from "./MSDPersonal"; const useStyles = makeStyles((_theme) => ({ createButton: { @@ -224,14 +224,12 @@ export const RecordsLog = ({ isMinistryCoordinator, setRecordsUploading, recordsTabSelect, - requestType + requestType, }) => { const user = useSelector((state) => state.user.userDetail); - const userGroups = user?.groups?.map(group => group.slice(1)); - - let recordsObj = useSelector( - (state) => state.foiRequests.foiRequestRecords - ); + const userGroups = user?.groups?.map((group) => group.slice(1)); + + let recordsObj = useSelector((state) => state.foiRequests.foiRequestRecords); let pdfStitchStatus = useSelector( (state) => state.foiRequests.foiPDFStitchStatusForHarms @@ -257,26 +255,40 @@ export const RecordsLog = ({ (state) => state.foiRequests.isRecordsLoading ); - const tagList = divisions.filter(d => d.divisionname.toLowerCase() !== 'communications').map(division => { - return { - name: division.divisionid, - display: division.divisionname, - } - }); + const tagList = divisions + .filter((d) => d.divisionname.toLowerCase() !== "communications") + .map((division) => { + return { + name: division.divisionid, + display: division.divisionname, + }; + }); const classes = useStyles(); const [records, setRecords] = useState(recordsObj?.records); const [totalUploadedRecordSize, setTotalUploadedRecordSize] = useState(0); - const [isScanningTeamMember, setIsScanningTeamMember] = useState(isScanningTeam(userGroups)); - const [ministryCode, setMinistryCode] = useState(bcgovcode.replaceAll('"', '').toUpperCase()); - const [isMCFPersonal, setIsMCFPersonal] = useState(ministryCode == "MCF" && requestType === FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL); + const [isScanningTeamMember, setIsScanningTeamMember] = useState( + isScanningTeam(userGroups) + ); + const [ministryCode, setMinistryCode] = useState( + bcgovcode.replaceAll('"', "").toUpperCase() + ); + const [isMCFPersonal, setIsMCFPersonal] = useState( + ministryCode == "MCF" && + requestType === FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL + ); - const MCFSections = useSelector((state) => state.foiRequests.foiPersonalSections); + const MCFSections = useSelector( + (state) => state.foiRequests.foiPersonalSections + ); - useEffect(() => { - setRecords(recordsObj?.records) - let nonDuplicateRecords = recordsObj?.records?.filter(record => !record.isduplicate) - let totalUploadedSize= (calculateTotalUploadedFileSizeInKB(nonDuplicateRecords)/ (1024 * 1024)) + useEffect(() => { + setRecords(recordsObj?.records); + let nonDuplicateRecords = recordsObj?.records?.filter( + (record) => !record.isduplicate + ); + let totalUploadedSize = + calculateTotalUploadedFileSizeInKB(nonDuplicateRecords) / (1024 * 1024); setTotalUploadedRecordSize(parseFloat(totalUploadedSize.toFixed(4))); dispatch(checkForRecordsChange(requestId, ministryId)); //To manage enabling and disabling of download for harms package @@ -928,17 +940,12 @@ export const RecordsLog = ({ bcgovcode: bcgovcode, attributes: [], }; - //remove duplicate records(except duplicate attachments) const deduplicatedRecords = removeDuplicateFiles(recordList); //get only relevent fields - const updatedrecords = getUpdatedRecords( - deduplicatedRecords, - conversionFormats - ); + const updatedrecords = getUpdatedRecords(deduplicatedRecords); //sort records and attachments based on lastmodified asc let sortedRecords = sortByLastModified(updatedrecords); - //get all the divisions in the records const divisionObj = {}; for (const _record of sortedRecords) { @@ -946,7 +953,6 @@ export const RecordsLog = ({ divisionObj[_division.divisionid] = _division.divisionname; } } - // arrange the records and its attachments. const recordsArray = []; for (const _record of sortedRecords) { @@ -1479,11 +1485,11 @@ export const RecordsLog = ({ } // setDivisionToUpdate() - if(isMCFPersonal && selectedDivision.size > 0) { - if(divisions.find(d => selectedDivision.has(d.divisionid))) { - return(!isMinistryCoordinator); + if (isMCFPersonal && selectedDivision.size > 0) { + if (divisions.find((d) => selectedDivision.has(d.divisionid))) { + return !isMinistryCoordinator; } else { - return(isMinistryCoordinator); + return isMinistryCoordinator; } } return count === 0; @@ -1663,7 +1669,11 @@ export const RecordsLog = ({ )} - {isMinistryCoordinator || (isScanningTeamMember && MinistryNeedsScanning.includes(bcgovcode.replaceAll('"', '')) && requestType === FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL) ? + {isMinistryCoordinator || + (isScanningTeamMember && + MinistryNeedsScanning.includes(bcgovcode.replaceAll('"', "")) && + requestType === + FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL) ? ( - : ( + ) : ( records?.length > 0 && - DISABLE_REDACT_WEBLINK?.toLowerCase() == "false" && + DISABLE_REDACT_WEBLINK?.toLowerCase() == "false" && ( ) - } + )} - {isMCFPersonal && (<> -
  • - all records selected must be uploaded by your own team -
  • - )} + {isMCFPersonal && ( + <> +
  • + all records selected must be uploaded by your own + team +
  • + + )} ) : ( @@ -2124,97 +2137,178 @@ export const RecordsLog = ({ // id="state-change-dialog" > -

    Update Divisions

    - setDivisionsModalOpen(false)}> - Close - - +

    Update Divisions

    + setDivisionsModalOpen(false)} + > + Close + +
    - - - {(records.filter(r=>(r.isselected && r.attributes.divisions.length > 1)).length > 0 && filterValue < 0) ? -
    - You have selected a record that was provided by more than one division.

    - To change the division you must first filter the Records Log by the division that you want to no longer be associated with the selected records. + + + {records.filter( + (r) => r.isselected && r.attributes.divisions.length > 1 + ).length > 0 && filterValue < 0 ? ( +
    + + You have selected a record that was provided by more + than one division.

    + To change the division you must first filter the Records + Log by the division that you want to no longer be + associated with the selected records.
    - : + ) : ( <> -
    - Select the divisions that corresponds to the records you have selected.

    - This will update the divisions on all records you have selected both in the gathering records log and the redaction app. -
    - - {(requestType == FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL) ? - (bcgovcode == "MCF") ? +
    + + Select the divisions that corresponds to the records + you have selected.

    + This will update the divisions on all records you have + selected both in the gathering records log and the + redaction app. +
    +
    + + {requestType == + FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL ? ( + bcgovcode == "MCF" ? ( r.isselected)[0]?.attributes.divisions[0].divisionid} + tagValue={ + records.filter((r) => r.isselected)[0]?.attributes + .divisions[0].divisionid + } divisionModalTagValue={divisionModalTagValue} divisions={divisions} isMinistryCoordinator={isMinistryCoordinator} /> - : - (bcgovcode == "MSD") ? - r.isselected)[0]?.attributes.divisions[0].divisionid} - divisionModalTagValue={divisionModalTagValue} - divisions={tagList} - /> - : -
    - {divisions.filter(division => { - if (division.divisionname.toLowerCase() === 'communications') { + ) : bcgovcode == "MSD" ? ( + r.isselected)[0]?.attributes + .divisions[0].divisionid + } + divisionModalTagValue={divisionModalTagValue} + divisions={tagList} + /> + ) : ( +
    + {divisions + .filter((division) => { + if ( + division.divisionname.toLowerCase() === + "communications" + ) { return false; - } else if (filterValue > -1 && filterValue !== division.divisionid) { + } else if ( + filterValue > -1 && + filterValue !== division.divisionid + ) { return true; - } else if (records.filter(r => r.isselected)[0]?.attributes.divisions[0].divisionid !== division.divisionid) { + } else if ( + records.filter((r) => r.isselected)[0] + ?.attributes.divisions[0].divisionid !== + division.divisionid + ) { return true; } else { return false; } - }).map(division => + }) + .map((division) => ( {setDivisionModalTagValue(division.divisionid)}} - clicked={divisionModalTagValue === division.divisionid} + onClick={(e) => { + setDivisionModalTagValue( + division.divisionid + ); + }} + clicked={ + divisionModalTagValue === + division.divisionid + } /> - )} -
    - : -
    - {divisions.filter(division => { - if (division.divisionname.toLowerCase() === 'communications') { - return false; - } else if (filterValue > -1 && filterValue !== division.divisionid) { - return true; - } else if (records.filter(r => r.isselected)[0]?.attributes.divisions[0].divisionid !== division.divisionid) { - return true; - } else { - return false; - } - }).map(division => - {setDivisionModalTagValue(division.divisionid)}} - clicked={divisionModalTagValue === division.divisionid} - /> - )} -
    } - } + ))} +
    + ) + ) : ( +
    + {divisions + .filter((division) => { + if ( + division.divisionname.toLowerCase() === + "communications" + ) { + return false; + } else if ( + filterValue > -1 && + filterValue !== division.divisionid + ) { + return true; + } else if ( + records.filter((r) => r.isselected)[0] + ?.attributes.divisions[0].divisionid !== + division.divisionid + ) { + return true; + } else { + return false; + } + }) + .map((division) => ( + { + setDivisionModalTagValue(division.divisionid); + }} + clicked={ + divisionModalTagValue === division.divisionid + } + /> + ))} +
    + )} + + )}
    From 9b8770beb815d7e68f82b49f218e233d12de1d7f Mon Sep 17 00:00:00 2001 From: divyav-aot Date: Fri, 10 Nov 2023 13:54:22 -0500 Subject: [PATCH 2/2] moved unSavedRequest state declaration to the top --- .../MinistryReview/MinistryReview.js | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/forms-flow-web/src/components/FOI/FOIRequest/MinistryReview/MinistryReview.js b/forms-flow-web/src/components/FOI/FOIRequest/MinistryReview/MinistryReview.js index 0b387c410..6b779db48 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/MinistryReview/MinistryReview.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/MinistryReview/MinistryReview.js @@ -17,7 +17,7 @@ import { import { fetchFOIMinistryAssignedToList, - fetchFOIPersonalDivisionsAndSections + fetchFOIPersonalDivisionsAndSections, } from "../../../../apiManager/services/FOI/foiMasterDataServices"; import { fetchFOIRequestAttachmentsList } from "../../../../apiManager/services/FOI/foiAttachmentServices"; @@ -227,8 +227,12 @@ const MinistryReview = React.memo(({ userDetail }) => { const [originalDivisions, setOriginalDivisions] = React.useState([]); const [hasReceivedDate, setHasReceivedDate] = React.useState(true); const [isMinistryRestricted, setIsMinistryRestricted] = useState(false); - const [isMCFPersonal, setIsMCFPersonal] = useState(bcgovcode.replaceAll('"', '') == "MCF" && requestDetails.requestType == FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL); - + const [isMCFPersonal, setIsMCFPersonal] = useState( + bcgovcode.replaceAll('"', "") == "MCF" && + requestDetails.requestType == + FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL + ); + const [unSavedRequest, setUnSavedRequest] = React.useState(false); let ministryassignedtousername = "Unassigned"; useEffect(() => { const requestDetailsValue = requestDetails; @@ -249,9 +253,15 @@ const MinistryReview = React.memo(({ userDetail }) => { ); } - if(MinistryNeedsScanning.includes(bcgovcode.replaceAll('"', '')) && requestDetails.requestType == FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL) { - dispatch(fetchFOIPersonalDivisionsAndSections(bcgovcode.replaceAll('"', ''))); - if(bcgovcode.replaceAll('"', '') == "MCF") { + if ( + MinistryNeedsScanning.includes(bcgovcode.replaceAll('"', "")) && + requestDetails.requestType == + FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL + ) { + dispatch( + fetchFOIPersonalDivisionsAndSections(bcgovcode.replaceAll('"', "")) + ); + if (bcgovcode.replaceAll('"', "") == "MCF") { setIsMCFPersonal(true); } } @@ -269,7 +279,6 @@ const MinistryReview = React.memo(({ userDetail }) => { } }, [isMinistryRestricted, requestWatchers]); - const [unSavedRequest, setUnSavedRequest] = React.useState(false); const [recordsUploading, setRecordsUploading] = React.useState(false); const [CFRUnsaved, setCFRUnsaved] = React.useState(false); const hideBottomText = [ @@ -426,11 +435,11 @@ const MinistryReview = React.memo(({ userDetail }) => { foitabheaderBG = "foitabheadercollection foitabheaderPeerreviewBG"; break; case StateEnum.tagging.name: - foitabheaderBG = "foitabheadercollection foitabheaderTaggingBG"; - break; + foitabheaderBG = "foitabheadercollection foitabheaderTaggingBG"; + break; case StateEnum.readytoscan.name: - foitabheaderBG = "foitabheadercollection foitabheaderReadytoScanBG"; - break; + foitabheaderBG = "foitabheadercollection foitabheaderReadytoScanBG"; + break; default: foitabheaderBG = "foitabheadercollection foitabheaderdefaultBG"; break; @@ -632,15 +641,18 @@ const MinistryReview = React.memo(({ userDetail }) => { ? `(${requestNotes.length})` : ""}
    - {(originalDivisions?.length > 0 || isMCFPersonal) && DISABLE_GATHERINGRECORDS_TAB?.toLowerCase() =='false' &&
    tabclick("Records")} - > - Records -
    } + {(originalDivisions?.length > 0 || isMCFPersonal) && + DISABLE_GATHERINGRECORDS_TAB?.toLowerCase() == "false" && ( +
    tabclick("Records")} + > + Records +
    + )}
    @@ -938,7 +950,8 @@ const MinistryReview = React.memo(({ userDetail }) => { [classes.hidden]: !tabLinksStatuses.Records.display, })} > - {!isAttachmentListLoading && (originalDivisions?.length > 0 || isMCFPersonal) ? ( + {!isAttachmentListLoading && + (originalDivisions?.length > 0 || isMCFPersonal) ? ( <> {url.indexOf("records") > -1 ? (