Skip to content

Commit

Permalink
Merge pull request #5344 from bcgov/dev-NK-FOIMOD-3189
Browse files Browse the repository at this point in the history
historical records download
  • Loading branch information
nkan-aot2 authored Jul 30, 2024
2 parents e1736cc + 6332694 commit dc8cd3f
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 84 deletions.
1 change: 1 addition & 0 deletions forms-flow-web/src/apiManager/endpoints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const API = {
FOI_HISTORICAL_REQUEST_API: `${FOI_HISTORICAL_API_URL}/api/foihistoricalrequest`,
FOI_HISTORICAL_REQUEST_DESCRIPTION_API: `${FOI_HISTORICAL_API_URL}/api/foihistoricalrequest/descriptionhistory`,
FOI_HISTORICAL_REQUEST_EXTENSIONS_API: `${FOI_HISTORICAL_API_URL}/api/foihistoricalrequest/extensions`,
FOI_HISTORICAL_RECORDS_API: `${FOI_BASE_API_URL}/api/foirecord/historical/<axisrequestid>`,
FOI_HISTORICAL_SEARCH_API: `${FOI_HISTORICAL_API_URL}/api/advancedsearch`,

FOI_GET_PROGRAMAREADIVISIONS: `${FOI_BASE_API_URL}/api/foiadmin/divisions`,
Expand Down
35 changes: 34 additions & 1 deletion forms-flow-web/src/apiManager/services/FOI/foiRecordServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
setFOIPDFStitchStatusForOipcRedlineReview,
setFOIPDFStitchStatusForOipcRedline,
setFOIPDFStitchedRecordForOipcRedline,
setRequestAttachments,
setFOIAttachmentListLoader,
} from "../../../actions/FOI/foiRequestActions";
import { fnDone } from "./foiServicesUtil";
import UserService from "../../../services/UserService";
Expand Down Expand Up @@ -635,4 +637,35 @@ export const fetchPDFStitchedRecordForOIPCRedlineReview = (
done(error);
});
};
}
}

export const fetchHistoricalRecords = (axisRequestId, ...rest) => {
const done = fnDone(rest);
let apiUrl = replaceUrl(API.FOI_HISTORICAL_RECORDS_API, "<axisrequestid>", axisRequestId);
return (dispatch) => {
dispatch(setRecordsLoader("inprogress"));
httpGETRequest(apiUrl, {}, UserService.getToken())
.then((res) => {
if (res.data) {
if (!res.data.records) {
dispatch(setRequestAttachments(res.data));
dispatch(setFOIAttachmentListLoader(false));
} else {
dispatch(setRequestRecords(res.data));
dispatch(setRecordsLoader("completed"));
}
done(null, res.data);
} else {
console.log("Error in fetching historical records", res);
dispatch(serviceActionError(res));
dispatch(setRecordsLoader("error"));
}
})
.catch((error) => {
console.log("Error in fetching historical records", error);
dispatch(serviceActionError(error));
dispatch(setRecordsLoader("error"));
done(error);
});
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ const DataGridAdvancedSearch = ({ userDetail }) => {
)
};

const historicalRenderCell = (params) => {
let link = "./historicalrequest/" + params.row.axisrequestid
return (
<a href={link}>
<div className="MuiDataGrid-cellContent">{params.value}</div>
</a>
)
};



const ProcessingTeamColumns = [
Expand Down Expand Up @@ -371,47 +380,47 @@ const DataGridAdvancedSearch = ({ userDetail }) => {
field: "applicantname",
headerName: "APPLICANT NAME",
headerAlign: "left",
renderCell: hyperlinkRenderCell,
renderCell: historicalRenderCell,
cellClassName: 'foi-advanced-search-result-cell',
width: 180,
},
{
field: "requesttype",
headerName: "REQUEST TYPE",
headerAlign: "left",
renderCell: hyperlinkRenderCell,
renderCell: historicalRenderCell,
cellClassName: 'foi-advanced-search-result-cell',
flex: 1,
},
{
field: "axisrequestid",
headerName: "ID NUMBER",
headerAlign: "left",
renderCell: hyperlinkRenderCell,
renderCell: historicalRenderCell,
cellClassName: 'foi-advanced-search-result-cell',
flex: 1,
},
{
field: "oipcno",
headerName: "OIPC no",
headerAlign: "left",
renderCell: hyperlinkRenderCell,
renderCell: historicalRenderCell,
cellClassName: 'foi-advanced-search-result-cell',
flex: 1,
},
{
field: "assignee",
headerName: "ASSIGNED TO",
headerAlign: "left",
renderCell: hyperlinkRenderCell,
renderCell: historicalRenderCell,
cellClassName: 'foi-advanced-search-result-cell',
flex: 1,
},
{
field: "receiveddate",
headerName: "RECEIVED DATE",
headerAlign: "left",
renderCell: hyperlinkRenderCell,
renderCell: historicalRenderCell,
cellClassName: 'foi-advanced-search-result-cell',
flex: 1,
},
Expand Down Expand Up @@ -578,7 +587,7 @@ const DataGridAdvancedSearch = ({ userDetail }) => {
label={"Historical AXIS Results"}
color="primary"
size="small"
onClick={() => { advancedFilterChange("historicalsearchresults"); console.log(`Value of advanced search filter on historicalsearchresults is ${foiadvsearchfilter}`)}}
onClick={() => { advancedFilterChange("historicalsearchresults"); console.log(`Value of advanced search filter on advancedsearchresults is ${foiadvsearchfilter}`)}}
clicked={foiadvsearchfilter === "historicalsearchresults"}
/>
</Stack>
Expand Down
14 changes: 10 additions & 4 deletions forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
fetchPDFStitchStatusForResponsePackage,
fetchPDFStitchedStatusForOIPCRedlineReview,
fetchPDFStitchedStatusForOIPCRedline,
fetchHistoricalRecords,
} from "../../../apiManager/services/FOI/foiRecordServices";
import { makeStyles } from "@material-ui/core/styles";
import FOI_COMPONENT_CONSTANTS from "../../../constants/FOI/foiComponentConstants";
Expand Down Expand Up @@ -160,7 +161,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
"fee estimate - payment receipt",
"response-onhold",
"fee balance outstanding - payment receipt",
].indexOf(attachment.category.toLowerCase()) === -1
].indexOf(attachment.category?.toLowerCase()) === -1
);
})
);
Expand Down Expand Up @@ -312,6 +313,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
dispatch(fetchHistoricalRequestDetails(requestId));
dispatch(fetchFOIHistoricalRequestDescriptionList(requestId));
dispatch(fetchHistoricalExtensions(requestId));
dispatch(fetchHistoricalRecords(requestId))
} else {
await Promise.all([
dispatch(fetchFOIProgramAreaList()),
Expand Down Expand Up @@ -1008,13 +1010,15 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
);

const showRecordsTab = () => {
if (isHistoricalRequest) {
return requestAttachments.length === 0
}
return (
requestState !== StateEnum.intakeinprogress.name &&
requestState !== StateEnum.unopened.name &&
requestState !== StateEnum.open.name &&
(requestDetails?.divisions?.length > 0 || isMCFPersonal) &&
DISABLE_GATHERINGRECORDS_TAB?.toLowerCase() =='false' &&
!isHistoricalRequest
DISABLE_GATHERINGRECORDS_TAB?.toLowerCase() =='false'
);
};

Expand Down Expand Up @@ -1449,6 +1453,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
iaoassignedToList={iaoassignedToList}
ministryAssignedToList={ministryAssignedToList}
isMinistryCoordinator={false}
isHistoricalRequest={isHistoricalRequest}
/>
</>
) : (
Expand Down Expand Up @@ -1660,12 +1665,13 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
iaoassignedToList={iaoassignedToList}
ministryAssignedToList={ministryAssignedToList}
isMinistryCoordinator={false}
bcgovcode={JSON.parse(bcgovcode)}
bcgovcode={isHistoricalRequest ? "" : JSON.parse(bcgovcode)}
setRecordsUploading={setRecordsUploading}
divisions={requestDetails.divisions}
recordsTabSelect={tabLinksStatuses.Records.active}
requestType={requestDetails?.requestType}
handleSaveRequest={handleSaveRequest}
isHistoricalRequest={isHistoricalRequest}
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export const AttachmentSection = ({
bcgovcode,
iaoassignedToList,
ministryAssignedToList,
isMinistryCoordinator
isMinistryCoordinator,
isHistoricalRequest
}) => {
const classes = useStyles();
const [attachments, setAttachments] = useState(attachmentsArray)
Expand Down Expand Up @@ -103,13 +104,13 @@ export const AttachmentSection = ({

const searchAttachments = (_attachments, _filterValue, _keywordValue) => {
return _attachments.filter( attachment => {
let onecategory = getCategory(attachment.category.toLowerCase());
let onecategory = getCategory(attachment.category?.toLowerCase());
return (
(_filterValue==="ALL"?true:onecategory.tags.includes(_filterValue?.toLowerCase()))
&& ( onecategory.tags.join('-').includes(_keywordValue?.toLowerCase())
|| attachment.category.toLowerCase().includes(_keywordValue?.toLowerCase())
|| attachment.category?.toLowerCase().includes(_keywordValue?.toLowerCase())
|| attachment.filename.toLowerCase().includes(_keywordValue?.toLowerCase())
|| attachment.createdby.toLowerCase().includes(_keywordValue?.toLowerCase()) )
|| attachment.createdby?.toLowerCase().includes(_keywordValue?.toLowerCase()) )
)
});
}
Expand Down Expand Up @@ -243,7 +244,7 @@ export const AttachmentSection = ({
})
});
}
}, 'attachments', bcgovcode);
}, isHistoricalRequest ? 'historical' : 'attachments', bcgovcode);
}

const downloadAllDocuments = async () => {
Expand All @@ -253,7 +254,8 @@ export const AttachmentSection = ({
let failed = 0;
try {
for (let attachment of attachmentsForDisplay) {
const response = await getFOIS3DocumentPreSignedUrl(attachment.documentpath.split('/').slice(4).join('/'), ministryId, dispatch, null, 'attachments', bcgovcode)
const category = isHistoricalRequest ? 'historical' : 'attachments'
const response = await getFOIS3DocumentPreSignedUrl(attachment.documentpath.split('/').slice(4).join('/'), ministryId, dispatch, null, category, bcgovcode)
await getFileFromS3({filepath: response.data}, (_err, res) => {
if (_err) {
failed++
Expand Down Expand Up @@ -395,6 +397,7 @@ export const AttachmentSection = ({
isMinistryCoordinator={isMinistryCoordinator}
ministryId={ministryId}
classes={classes}
isHistoricalRequest={isHistoricalRequest}
/>);
}

Expand Down Expand Up @@ -439,14 +442,14 @@ export const AttachmentSection = ({
</ConditionalComponent>
</Grid>
<Grid item xs={3}>
<button
{!isHistoricalRequest && <button
className={clsx("btn", "addAttachment", classes.createButton)}
variant="contained"
onClick={addAttachments}
color="primary"
>
+ Add Attachment
</button>
</button>}
</Grid>
<Grid
container
Expand Down Expand Up @@ -491,7 +494,7 @@ export const AttachmentSection = ({
}


const Attachment = React.memo(({indexValue, attachment, handlePopupButtonClick, getFullname, isMinistryCoordinator,ministryId}) => {
const Attachment = React.memo(({indexValue, attachment, handlePopupButtonClick, getFullname, isMinistryCoordinator,ministryId, isHistoricalRequest}) => {

const classes = useStyles();

Expand Down Expand Up @@ -591,6 +594,7 @@ const Attachment = React.memo(({indexValue, attachment, handlePopupButtonClick,
disabled={disabled}
reclassifyIsDisabled={reclassifyIsDisabled}
ministryId={ministryId}
isHistoricalRequest={isHistoricalRequest}
/>
</Grid>
</Grid>
Expand Down Expand Up @@ -650,7 +654,7 @@ const opendocumentintab =(attachment,ministryId)=>
window.open(url, '_blank').focus();
}

const AttachmentPopup = React.memo(({indexValue, attachment, handlePopupButtonClick, disabled, reclassifyIsDisabled, ministryId}) => {
const AttachmentPopup = React.memo(({indexValue, attachment, handlePopupButtonClick, disabled, reclassifyIsDisabled, ministryId, isHistoricalRequest}) => {
const ref = React.useRef();
const closeTooltip = () => ref.current && ref ? ref.current.close():{};

Expand Down Expand Up @@ -707,11 +711,11 @@ const AttachmentPopup = React.memo(({indexValue, attachment, handlePopupButtonCl
]

const showReplace = (category) => {
return transitionStates.includes(category.toLowerCase());
return transitionStates.includes(category?.toLowerCase());
}

const showDelete = (category) => {
return !emailCategories.includes(category.toLowerCase());
return !emailCategories.includes(category?.toLowerCase());
}

const [popoverOpen, setPopoverOpen] = useState(false);
Expand Down Expand Up @@ -746,14 +750,15 @@ const AttachmentPopup = React.memo(({indexValue, attachment, handlePopupButtonCl
}

const AddMenuItems = () => {
if (showReplace(attachment.category))
if (showReplace(attachment.category)) {
return (<ReplaceMenu />)
else if (!showDelete(attachment.category))
} else if (!showDelete(attachment.category)) {
return null;
}
return (<DeleteMenu />)
}

const ActionsPopover = ({RestrictViewInBrowser}) => {
const ActionsPopover = ({RestrictViewInBrowser, isHistoricalRequest}) => {

return (
<Popover
Expand Down Expand Up @@ -794,28 +799,31 @@ const AttachmentPopup = React.memo(({indexValue, attachment, handlePopupButtonCl
>
Download
</MenuItem>

<MenuItem
onClick={() => {
handleReclassify();
setPopoverOpen(false);
}}
disabled={reclassifyIsDisabled}
>
Reclassify
</MenuItem>

<MenuItem
onClick={() => {
handleRename();
setPopoverOpen(false);
}}
>
Rename
</MenuItem>
{attachment.category === "personal" ? (
{!isHistoricalRequest &&
<MenuItem
onClick={() => {
handleReclassify();
setPopoverOpen(false);
}}
disabled={reclassifyIsDisabled}
>
Reclassify
</MenuItem>
}
{!isHistoricalRequest &&

<MenuItem
onClick={() => {
handleRename();
setPopoverOpen(false);
}}
>
Rename
</MenuItem>
}
{(attachment.category === "personal" || isHistoricalRequest) ? (
""
) : <AddMenuItems />}
) : <AddMenuItems />}
</MenuList>
</Popover>
);
Expand All @@ -838,7 +846,7 @@ const AttachmentPopup = React.memo(({indexValue, attachment, handlePopupButtonCl
>
<MoreHorizIcon />
</IconButton>
<ActionsPopover RestrictViewInBrowser={attachment.documentpath.toLowerCase().indexOf('.eml') > 0 || attachment.documentpath.toLowerCase().indexOf('.msg') > 0 ? true:false }/>
<ActionsPopover RestrictViewInBrowser={attachment.documentpath.toLowerCase().indexOf('.eml') > 0 || attachment.documentpath.toLowerCase().indexOf('.msg') > 0 ? true:false } isHistoricalRequest={isHistoricalRequest}/>
</>
);
})
Expand Down
Loading

0 comments on commit dc8cd3f

Please sign in to comment.