Skip to content

Commit

Permalink
merged main to test-marshal
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman-Hundal committed Aug 6, 2024
2 parents 2e2011f + 463c123 commit 3f02297
Show file tree
Hide file tree
Showing 15 changed files with 266 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private DataTable GetAxisRequestData(string request)
onbehalf.vcLastName as onbehalfLastName,
onbehalf.vcMiddleName as onbehalfMiddleName,
(SELECT terminology.vcTerminology from tblTerminologyLookup terminology WHERE terminology.iLabelID = requestTypes.iLabelID and terminology.tiLocaleID = 1) as requestType,
sum(distinct case when requests.IREQUESTID = reviewlog.IREQUESTID and reviewlog.IDOCID = documents.IDOCID then documents.SIPAGECOUNT
sum(case when requests.IREQUESTID = reviewlog.IREQUESTID and reviewlog.IDOCID = documents.IDOCID then documents.SIPAGECOUNT
when requests.IREQUESTID = redaction.IREQUESTID and redaction.IDOCID = ldocuments.IDOCID then ldocuments.SIPAGECOUNT
else 0 end) as requestPageCount,
(case when requestfields.CustomField91 > 0 then requestfields.CustomField91 else 0 end ) as lanPageCount,
Expand Down Expand Up @@ -353,7 +353,7 @@ private DataTable GetAxisRequestsPageCount(string[] arrayOfRequestId)
ConnectionString = SettingsManager.ConnectionString;
var inClauseValues = RequestsHelper.GetInClause(arrayOfRequestId);

string query = $@"Select vcVisibleRequestID as axisRequestId, sum(distinct case when requests.IREQUESTID = reviewlog.IREQUESTID and reviewlog.IDOCID = documents.IDOCID then documents.SIPAGECOUNT
string query = $@"Select vcVisibleRequestID as axisRequestId, sum(case when requests.IREQUESTID = reviewlog.IREQUESTID and reviewlog.IDOCID = documents.IDOCID then documents.SIPAGECOUNT
when requests.IREQUESTID = redaction.IREQUESTID and redaction.IDOCID = ldocuments.IDOCID then ldocuments.SIPAGECOUNT
else 0 end) as requestPageCount,
(case when requestfields.CustomField91 > 0 then requestfields.CustomField91 else 0 end ) as lanPageCount
Expand Down Expand Up @@ -394,7 +394,7 @@ private DataTable GetAxisRequestsPageCount()
{
ConnectionString = SettingsManager.ConnectionString;

string query = @"Select vcVisibleRequestID as axisRequestId, sum(distinct case when requests.IREQUESTID = reviewlog.IREQUESTID and reviewlog.IDOCID = documents.IDOCID then documents.SIPAGECOUNT
string query = @"Select vcVisibleRequestID as axisRequestId, sum(case when requests.IREQUESTID = reviewlog.IREQUESTID and reviewlog.IDOCID = documents.IDOCID then documents.SIPAGECOUNT
when requests.IREQUESTID = redaction.IREQUESTID and redaction.IDOCID = ldocuments.IDOCID then ldocuments.SIPAGECOUNT
else 0 end) as requestPageCount,
(case when requestfields.CustomField91 > 0 then requestfields.CustomField91 else 0 end ) as lanPageCount
Expand Down
24 changes: 24 additions & 0 deletions forms-flow-web/src/apiManager/services/FOI/foiRecordServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,4 +690,28 @@ export const fetchPDFStitchedRecordForConsults = (
done(error);
});
};
}

export const updateUserLockedRecords = (data, requestId, ministryId, ...rest) => {
const done = fnDone(rest);
let apiUrl= replaceUrl(replaceUrl(
API.FOI_REQUEST_SECTION_API,
"<ministryid>",
ministryId),"<requestid>",requestId
);
return (dispatch) => {
httpPOSTRequest(`${apiUrl}/userrecordslockstatus`, data)
.then((res) => {
if (res.data) {
done(null, res.data);
} else {
dispatch(serviceActionError(res));
throw new Error(`Error while updating records lock status for the (request# ${requestId}, ministry# ${ministryId})`);
}
})
.catch((error) => {
dispatch(serviceActionError(error));
done(error);
});
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const BottomButtonGroup = React.memo(
axisMessage,
attachmentsArray,
oipcData,
validLockRecordsState,
}) => {
/**
* Bottom Button Group of Review request Page
Expand Down Expand Up @@ -120,6 +121,11 @@ const BottomButtonGroup = React.memo(
setIsAddRequest(false);
}

//Logic to reset user lock records status to null (and have FE useEffect in FOIRequest.js/MinistryView.js logic takeover) if request is in unlocked request states
if (!validLockRecordsState(currentSelectedStatus)) {
saveRequestObject.userrecordslockstatus = null;
}

//add oipc Data to save request object and sync/validate isoipcreview attribute
if (requestState.toLowerCase() !== StateEnum.intakeinprogress.name.toLowerCase() && requestState.toLowerCase() !== StateEnum.unopened.name.toLowerCase()) {
saveRequestObject.oipcdetails = oipcData ? oipcData : [];
Expand Down
34 changes: 32 additions & 2 deletions forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
const [isMCFPersonal, setIsMCFPersonal] = useState(bcgovcode.replaceAll('"', '') == "MCF" && requestDetails.requestType == FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL);
const {oipcData, addOIPC, removeOIPC, updateOIPC, isOIPCReview, setIsOIPCReview, removeAllOIPCs} = useOIPCHook();
const [oipcDataInitial, setOipcDataInitial] = useState(oipcData);

const [lockRecordsTab, setLockRecordsTab] = useState(false);

//Update disableInput when requestState changes
useEffect(() => {
setDisableInput(requestState?.toLowerCase() === StateEnum.closed.name.toLowerCase() && !isOIPCReview);
Expand Down Expand Up @@ -323,7 +324,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
dispatch(
fetchRedactedSections(ministryId, (_err, res) => {
if (!_err) {
setRedactedSections(res.sections);
setRedactedSections(res);
}
})
);
Expand All @@ -343,6 +344,20 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
if (bcgovcode) dispatch(fetchFOIMinistryAssignedToList(bcgovcode));
}, [requestId, ministryId, comment, attachments]);

const validLockRecordsState = (currentState=requestDetails.currentState) => {
return (
currentState === StateEnum.harms.name ||
currentState === StateEnum.onhold.name ||
currentState === StateEnum.recordsreadyforreview.name ||
currentState === StateEnum.review.name ||
currentState === StateEnum.consult.name ||
currentState === StateEnum.peerreview.name ||
currentState === StateEnum.signoff.name ||
currentState === StateEnum.response.name ||
currentState === StateEnum.closed.name
);
}

useEffect(() => {
const requestDetailsValue = requestDetails;
setSaveRequestObject(requestDetailsValue);
Expand Down Expand Up @@ -378,6 +393,16 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
} else {
setIsOIPCReview(false);
}

//Adjust lockRecords value based on requestState if there is no manual user lockedrecords value present in requestDetails from DB
const updateRecordsTabAccess = () => {
if(requestDetails.userrecordslockstatus === null) {
return validLockRecordsState(requestDetails.currentState);
} else {
return requestDetails.userrecordslockstatus;
}
}
setLockRecordsTab(updateRecordsTabAccess());
}, [requestDetails]);

//useEffect to manage isoipcreview attribute for requestdetails state
Expand Down Expand Up @@ -1397,6 +1422,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
axisMessage={axisMessage}
attachmentsArray={requestAttachments}
oipcData={oipcData}
validLockRecordsState={validLockRecordsState}
/>
</>
</ConditionalComponent>
Expand Down Expand Up @@ -1641,6 +1667,10 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
divisions={requestDetails.divisions}
recordsTabSelect={tabLinksStatuses.Records.active}
requestType={requestDetails?.requestType}
lockRecords={lockRecordsTab}
setLockRecordsTab={setLockRecordsTab}
validLockRecordsState={validLockRecordsState}
setSaveRequestObject={setSaveRequestObject}
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const BottomButtonGroup = React.memo(
hasStatusRequestSaved,
attachmentsArray,
stateChanged,
validLockRecordsState,
}) => {
/**
* Bottom Button Group of Review request Page
Expand Down Expand Up @@ -109,6 +110,10 @@ const BottomButtonGroup = React.memo(
};

const saveMinistryRequest = async () => {
//Logic to reset user lock records status to null (and have FE useEffect in FOIRequest.js/MinistryView.js logic takeover) if request is in unlocked request states
if (!validLockRecordsState(currentSelectedStatus)) {
saveMinistryRequestObject.userrecordslockstatus = null;
}
dispatch(
saveMinistryRequestDetails(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,20 @@ const MinistryReview = React.memo(({ userDetail }) => {

const userGroups = userDetail?.groups?.map(group => group.slice(1));
const isMinistry = isMinistryLogin(userGroups);

const validLockRecordsState = (currentState=requestDetails.currentState) => {
return (
currentState === StateEnum.harms.name ||
currentState === StateEnum.onhold.name ||
currentState === StateEnum.recordsreadyforreview.name ||
currentState === StateEnum.review.name ||
currentState === StateEnum.consult.name ||
currentState === StateEnum.peerreview.name ||
currentState === StateEnum.signoff.name ||
currentState === StateEnum.response.name ||
currentState === StateEnum.closed.name
);
}

useEffect(() => {
const requestDetailsValue = requestDetails;
Expand Down Expand Up @@ -276,6 +290,16 @@ const MinistryReview = React.memo(({ userDetail }) => {
setIsMCFPersonal(true);
}
}

//Adjust lockRecords value based on requestState if there is no manual user lockedrecords value present in requestDetails from DB
const updateRecordsTabAccess = () => {
if(requestDetails.userrecordslockstatus === null) {
return validLockRecordsState(requestDetails.currentState);
} else {
return requestDetails.userrecordslockstatus;
}
}
setLockRecordsTab(updateRecordsTabAccess());
}, [requestDetails, unSavedRequest]);

useEffect(() => {
Expand All @@ -291,6 +315,7 @@ const MinistryReview = React.memo(({ userDetail }) => {
}, [isMinistryRestricted, requestWatchers]);

const [recordsUploading, setRecordsUploading] = React.useState(false);
const [lockRecordsTab, setLockRecordsTab] = useState(false);
const [CFRUnsaved, setCFRUnsaved] = React.useState(false);
const hideBottomText = [
StateEnum.onhold.name.toLowerCase(),
Expand Down Expand Up @@ -802,6 +827,7 @@ const MinistryReview = React.memo(({ userDetail }) => {
handleSaveRequest={handleSaveRequest}
currentSelectedStatus={_currentrequestStatus}
hasStatusRequestSaved={hasStatusRequestSaved}
validLockRecordsState={validLockRecordsState}
/>
</>
)}
Expand Down Expand Up @@ -1050,6 +1076,8 @@ const MinistryReview = React.memo(({ userDetail }) => {
setRecordsUploading={setRecordsUploading}
recordsTabSelect={tabLinksStatuses.Records.active}
requestType={requestDetails?.requestType}
lockRecords={lockRecordsTab}
validLockRecordsState={validLockRecordsState}
/>
</>
) : (
Expand Down
Loading

0 comments on commit 3f02297

Please sign in to comment.