Skip to content

Commit

Permalink
Merge pull request #5357 from bcgov/test-marshal-AH-FOIMOD-3385-testrook
Browse files Browse the repository at this point in the history
Test-Rook <> Test-Marshal Merge August 12 2024
  • Loading branch information
Aman-Hundal authored Aug 13, 2024
2 parents 2e2011f + 927f910 commit addc651
Show file tree
Hide file tree
Showing 40 changed files with 2,347 additions and 320 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
2 changes: 1 addition & 1 deletion forms-flow-web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ARG REACT_APP_RECORD_DOWNLOAD_LIMIT
ARG REACT_APP_RECORD_DOWNLOAD_SIZE_LIMIT

ENV NODE_ENV ${NODE_ENV}
ENV GENERATE_SOURCEMAP false
ENV GENERATE_SOURCEMAP ${GENERATE_SOURCEMAP}
ENV REACT_APP_API_SERVER_URL ${REACT_APP_API_SERVER_URL}
ENV REACT_APP_API_PROJECT_URL ${REACT_APP_API_PROJECT_URL}
ENV REACT_APP_KEYCLOAK_CLIENT ${REACT_APP_KEYCLOAK_CLIENT}
Expand Down
2 changes: 1 addition & 1 deletion forms-flow-web/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
dockerfile: Dockerfile
args:
- NODE_ENV=${NODE_ENV:-development}
- GENERATE_SOURCEMAP=false
- GENERATE_SOURCEMAP=${GENERATE_SOURCEMAP}
- REACT_APP_CLIENT_ROLE=${CLIENT_ROLE:-formsflow-client}
- REACT_APP_STAFF_REVIEWER_ROLE=${REVIEWER_ROLE:-formsflow-reviewer}
- REACT_APP_STAFF_DESIGNER_ROLE=${DESIGNER_ROLE:-formsflow-designer}
Expand Down
3 changes: 3 additions & 0 deletions forms-flow-web/src/actions/FOI/foiActionConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const FOI_ACTION_CONSTANTS = {
FOI_MINISTRY_DIVISIONALSTAGES: "FOI_MINISTRY_DIVISIONALSTAGES",
FOI_PERSONAL_DIVISIONS_SECTIONS: "FOI_PERSONAL_DIVISIONS_SECTIONS",
FOI_PERSONAL_SECTIONS: "FOI_PERSONAL_SECTIONS",
FOI_PERSONAL_PEOPLE: "FOI_PERSONAL_PEOPLE",
FOI_PERSONAL_FILETYPES: "FOI_PERSONAL_FILETYPES",
FOI_PERSONAL_VOLUMES: "FOI_PERSONAL_VOLUMES",

FOI_WATCHER_LIST: "FOI_WATCHER_LIST",

Expand Down
18 changes: 18 additions & 0 deletions forms-flow-web/src/actions/FOI/foiRequestActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,24 @@ export const setFOIPersonalSections = (data) => dispatch => {
payload:data
})
}
export const setFOIPersonalPeople = (data) => dispatch => {
dispatch({
type:FOI_ACTION_CONSTANTS.FOI_PERSONAL_PEOPLE,
payload:data
})
}
export const setFOIPersonalFiletypes = (data) => dispatch => {
dispatch({
type:FOI_ACTION_CONSTANTS.FOI_PERSONAL_FILETYPES,
payload:data
})
}
export const setFOIPersonalVolumes = (data) => dispatch => {
dispatch({
type:FOI_ACTION_CONSTANTS.FOI_PERSONAL_VOLUMES,
payload:data
})
}
export const setFOIWatcherList = (data) => (dispatch) => {
dispatch({
type: FOI_ACTION_CONSTANTS.FOI_WATCHER_LIST,
Expand Down
4 changes: 4 additions & 0 deletions forms-flow-web/src/apiManager/endpoints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const API = {
FOI_PERSONAL_DIVISIONS_SECTIONS: `${FOI_BASE_API_URL}/api/foiflow/divisions/<bcgovcode>/true/divisionsandsections`,
FOI_PERSONAL_SECTIONS: `${FOI_BASE_API_URL}/api/foiflow/divisions/<bcgovcode>/true/sections`,
FOI_PERSONAL_DIVISIONS: `${FOI_BASE_API_URL}/api/foiflow/divisions/<bcgovcode>/true/divisions`,
FOI_PERSONAL_PEOPLE: `${FOI_BASE_API_URL}/api/foiflow/divisions/<bcgovcode>/true/people`,
FOI_PERSONAL_FILETYPES: `${FOI_BASE_API_URL}/api/foiflow/divisions/<bcgovcode>/true/filetypes`,
FOI_PERSONAL_VOLUMES: `${FOI_BASE_API_URL}/api/foiflow/divisions/<bcgovcode>/true/volumes`,
FOI_POST_RAW_REQUEST_WATCHERS: `${FOI_BASE_API_URL}/api/foiwatcher/rawrequest`,
FOI_GET_RAW_REQUEST_WATCHERS: `${FOI_BASE_API_URL}/api/foiwatcher/rawrequest/<requestid>`,
FOI_POST_MINISTRY_REQUEST_WATCHERS: `${FOI_BASE_API_URL}/api/foiwatcher/ministryrequest`,
Expand Down Expand Up @@ -115,6 +118,7 @@ const API = {
FOI_REPLACE_RECORDS: `${FOI_BASE_API_URL}/api/foirecord/<requestid>/ministryrequest/<ministryrequestid>/record/<recordid>/replace`,
FOI_POST_RECORDS: `${FOI_BASE_API_URL}/api/foirecord/<requestid>/ministryrequest/<ministryrequestid>`,
FOI_UPDATE_RECORDS: `${FOI_BASE_API_URL}/api/foirecord/<requestid>/ministryrequest/<ministryrequestid>/update`,
FOI_UPDATE_PERSONAL_ATTRIBUTES: `${FOI_BASE_API_URL}/api/foirecord/<requestid>/ministryrequest/<ministryrequestid>/updatepersonalattributes`,
DOC_REVIEWER_DELETE_RECORDS: `${DOC_REVIEWER_BASE_API_URL}/api/document/delete`,
DOC_REVIEWER_REDACTED_SECTIONS: `${DOC_REVIEWER_BASE_API_URL}/api/redactedsections/ministryrequest/<ministryrequestid>`,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {
setFOIReceivedModeList,
setFOIMinistryDivisionalStages,
setFOIPersonalDivisionsAndSections,
setFOIPersonalPeople,
setFOIPersonalFiletypes,
setFOIPersonalVolumes,
setFOIPersonalSections,
setClosingReasons,
setFOISubjectCodeList,
Expand Down Expand Up @@ -418,6 +421,93 @@ import {
}
};

export const fetchFOIPersonalPeople = (bcgovcode) => {
switch(bcgovcode) {
case "MCF":
const apiUrlMCF = replaceUrl(API.FOI_PERSONAL_PEOPLE, "<bcgovcode>", bcgovcode);
return (dispatch) => {
httpGETRequest(apiUrlMCF, {}, UserService.getToken())
.then((res) => {
if (res.data) {
const foiPersonalSections = res.data;
dispatch(setFOIPersonalPeople({}));
dispatch(setFOIPersonalPeople(foiPersonalSections));
dispatch(setFOILoader(false));
} else {
console.log(`Error while fetching (${bcgovcode}) FOI records people`, res);
dispatch(serviceActionError(res));
dispatch(setFOILoader(false));
}
})
.catch((error) => {
console.log(`Error while fetching (${bcgovcode}) FOI records people`, error);
dispatch(serviceActionError(error));
dispatch(setFOILoader(false));
});
};
default:
break;
}
};

export const fetchFOIPersonalFiletypes = (bcgovcode) => {
switch(bcgovcode) {
case "MCF":
const apiUrlMCF = replaceUrl(API.FOI_PERSONAL_FILETYPES, "<bcgovcode>", bcgovcode);
return (dispatch) => {
httpGETRequest(apiUrlMCF, {}, UserService.getToken())
.then((res) => {
if (res.data) {
const foiPersonalSections = res.data;
dispatch(setFOIPersonalFiletypes({}));
dispatch(setFOIPersonalFiletypes(foiPersonalSections));
dispatch(setFOILoader(false));
} else {
console.log(`Error while fetching (${bcgovcode}) FOI records people`, res);
dispatch(serviceActionError(res));
dispatch(setFOILoader(false));
}
})
.catch((error) => {
console.log(`Error while fetching (${bcgovcode}) FOI records people`, error);
dispatch(serviceActionError(error));
dispatch(setFOILoader(false));
});
};
default:
break;
}
};

export const fetchFOIPersonalVolumes = (bcgovcode) => {
switch(bcgovcode) {
case "MCF":
const apiUrlMCF = replaceUrl(API.FOI_PERSONAL_VOLUMES, "<bcgovcode>", bcgovcode);
return (dispatch) => {
httpGETRequest(apiUrlMCF, {}, UserService.getToken())
.then((res) => {
if (res.data) {
const foiPersonalSections = res.data;
dispatch(setFOIPersonalVolumes({}));
dispatch(setFOIPersonalVolumes(foiPersonalSections));
dispatch(setFOILoader(false));
} else {
console.log(`Error while fetching (${bcgovcode}) FOI records people`, res);
dispatch(serviceActionError(res));
dispatch(setFOILoader(false));
}
})
.catch((error) => {
console.log(`Error while fetching (${bcgovcode}) FOI records people`, error);
dispatch(serviceActionError(error));
dispatch(setFOILoader(false));
});
};
default:
break;
}
};

export const fetchFOIPersonalDivisions = (bcgovcode) => {
const apiUrl = replaceUrl(API.FOI_PERSONAL_DIVISIONS, "<bcgovcode>", bcgovcode);
return (dispatch) => {
Expand Down
39 changes: 39 additions & 0 deletions forms-flow-web/src/apiManager/services/FOI/foiRecordServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,21 @@ export const updateFOIRecords = (requestId, ministryId, data, ...rest) => {
};
};

export const editPersonalAttributes = (requestId, ministryId, data, ...rest) => {
if (!ministryId) {
return () => {};
}
const done = fnDone(rest);
let apiUrl = replaceUrl(
replaceUrl(API.FOI_UPDATE_PERSONAL_ATTRIBUTES, "<ministryrequestid>", ministryId),
"<requestid>",
requestId
);
return (dispatch) => {
postRecord(dispatch, apiUrl, data, "Error in updating records", rest);
};
};

export const deleteReviewerRecords = (filepaths, ...rest) => {
const done = fnDone(rest);
let apiUrl = API.DOC_REVIEWER_DELETE_RECORDS;
Expand Down Expand Up @@ -690,4 +705,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
47 changes: 44 additions & 3 deletions forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import {
fetchFOIMinistryAssignedToList,
fetchFOISubjectCodeList,
fetchFOIPersonalDivisionsAndSections,
fetchFOIPersonalPeople,
fetchFOIPersonalFiletypes,
fetchFOIPersonalVolumes,
fetchOIPCOutcomes,
fetchOIPCStatuses,
fetchOIPCReviewtypes,
Expand Down Expand Up @@ -273,7 +276,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 +327,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
dispatch(
fetchRedactedSections(ministryId, (_err, res) => {
if (!_err) {
setRedactedSections(res.sections);
setRedactedSections(res);
}
})
);
Expand All @@ -343,6 +347,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 All @@ -367,9 +385,16 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
setIsIAORestricted(isRequestRestricted(requestDetails, ministryId));
}

if(MinistryNeedsScanning.includes(bcgovcode.replaceAll('"', '')) && requestDetails.requestType == FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL) {
if(
MinistryNeedsScanning.includes(bcgovcode.replaceAll('"', '')) &&
requestDetails.requestType ==
FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL
) {
dispatch(fetchFOIPersonalDivisionsAndSections(bcgovcode.replaceAll('"', '')));
if(bcgovcode.replaceAll('"', '') == "MCF") {
dispatch(fetchFOIPersonalPeople(bcgovcode.replaceAll('"', '')));
dispatch(fetchFOIPersonalFiletypes(bcgovcode.replaceAll('"', '')));
dispatch(fetchFOIPersonalVolumes(bcgovcode.replaceAll('"', '')));
setIsMCFPersonal(true);
}
}
Expand All @@ -378,6 +403,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 +1432,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
axisMessage={axisMessage}
attachmentsArray={requestAttachments}
oipcData={oipcData}
validLockRecordsState={validLockRecordsState}
/>
</>
</ConditionalComponent>
Expand Down Expand Up @@ -1641,6 +1677,11 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
divisions={requestDetails.divisions}
recordsTabSelect={tabLinksStatuses.Records.active}
requestType={requestDetails?.requestType}
lockRecords={lockRecordsTab}
setLockRecordsTab={setLockRecordsTab}
validLockRecordsState={validLockRecordsState}
setSaveRequestObject={setSaveRequestObject}
handleSaveRequest={handleSaveRequest}
/>
</>
)}
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
Loading

0 comments on commit addc651

Please sign in to comment.