From b5ffb3934c554ab679c6897dd91c1c523bbe4ca2 Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Mon, 8 Jul 2024 16:02:32 -0700 Subject: [PATCH 01/15] Added F/E work and state for IAO users. WIP IAO User restrictions + Ministry User changes --- .../src/components/FOI/FOIRequest/FOIRequest.js | 16 +++++++++++++++- .../FOI/customComponents/Records/index.js | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js index c472636c0..c9e29a68b 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js @@ -272,10 +272,23 @@ 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 + //Update disableInput + lockRecords when requestState changes useEffect(() => { + const updateRecordsTabAccess = () => { + return ( + requestState === StateEnum.recordsreadyforreview || + requestState === StateEnum.review || + requestState === StateEnum.consult || + requestState === StateEnum.peerreview || + requestState === StateEnum.signoff || + requestState === StateEnum.response || + requestState === StateEnum.closed + ); + } setDisableInput(requestState?.toLowerCase() === StateEnum.closed.name.toLowerCase() && !isOIPCReview); + setLockRecordsTab(updateRecordsTabAccess()); }, [requestState, isOIPCReview]) useEffect(() => { @@ -1639,6 +1652,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { divisions={requestDetails.divisions} recordsTabSelect={tabLinksStatuses.Records.active} requestType={requestDetails?.requestType} + lockRecords={lockRecordsTab} /> )} 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 c43fac76a..67a4095a6 100644 --- a/forms-flow-web/src/components/FOI/customComponents/Records/index.js +++ b/forms-flow-web/src/components/FOI/customComponents/Records/index.js @@ -219,6 +219,7 @@ export const RecordsLog = ({ setRecordsUploading, recordsTabSelect, requestType, + lockRecords, }) => { const user = useSelector((state) => state.user.userDetail); const userGroups = user?.groups?.map((group) => group.slice(1)); @@ -1761,6 +1762,22 @@ export const RecordsLog = ({ {getRequestNumber()} + {isMinistryCoordinator === false ? + + + : null + } {(isMinistryCoordinator == false && records?.length > 0 && From e5c4f00dd07660dbfeba50c31d4d9fe4cca49895 Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Tue, 9 Jul 2024 14:45:22 -0700 Subject: [PATCH 02/15] Added migration script, and adjust FE code to follow new logic. WIP IAO Users --- .../components/FOI/FOIRequest/FOIRequest.js | 36 +++++++++++-------- .../migrations/versions/5fdd5df3d642_.py | 24 +++++++++++++ .../request_api/models/FOIMinistryRequests.py | 1 + 3 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 request-management-api/migrations/versions/5fdd5df3d642_.py diff --git a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js index c9e29a68b..95f3ac238 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js @@ -273,22 +273,10 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { const {oipcData, addOIPC, removeOIPC, updateOIPC, isOIPCReview, setIsOIPCReview, removeAllOIPCs} = useOIPCHook(); const [oipcDataInitial, setOipcDataInitial] = useState(oipcData); const [lockRecordsTab, setLockRecordsTab] = useState(false); - - //Update disableInput + lockRecords when requestState changes + + //Update disableInput when requestState changes useEffect(() => { - const updateRecordsTabAccess = () => { - return ( - requestState === StateEnum.recordsreadyforreview || - requestState === StateEnum.review || - requestState === StateEnum.consult || - requestState === StateEnum.peerreview || - requestState === StateEnum.signoff || - requestState === StateEnum.response || - requestState === StateEnum.closed - ); - } setDisableInput(requestState?.toLowerCase() === StateEnum.closed.name.toLowerCase() && !isOIPCReview); - setLockRecordsTab(updateRecordsTabAccess()); }, [requestState, isOIPCReview]) useEffect(() => { @@ -1045,6 +1033,25 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { requestDetails?.requestType === FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_GENERAL) } + const updateRecordsTabAccess = () => { + if(requestDetails.lockRecords === null) { + return ( + requestState === StateEnum.recordsreadyforreview.name || + requestState === StateEnum.review.name || + requestState === StateEnum.consult.name || + requestState === StateEnum.peerreview.name || + requestState === StateEnum.signoff.name || + requestState === StateEnum.response.name || + requestState === StateEnum.closed.name + ); + } + } + + const handleLockRecords = () => { + setLockRecordsTab(!lockRecordsTab); + console.log("API CALL TO LOCK RECORDS ENDPOINT") // OR JUST REUQEST UPDATE END POINT AND NO NEED FOR NEW ONE? + } + return (!isLoading && requestDetails && Object.keys(requestDetails).length !== 0) || @@ -1653,6 +1660,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { recordsTabSelect={tabLinksStatuses.Records.active} requestType={requestDetails?.requestType} lockRecords={lockRecordsTab} + handleLockRecords={handleLockRecords} /> )} diff --git a/request-management-api/migrations/versions/5fdd5df3d642_.py b/request-management-api/migrations/versions/5fdd5df3d642_.py new file mode 100644 index 000000000..e943559dc --- /dev/null +++ b/request-management-api/migrations/versions/5fdd5df3d642_.py @@ -0,0 +1,24 @@ +"""ADD LOCKRECORDS Column to FOIMinistryRequest + +Revision ID: 5fdd5df3d642 +Revises: e698b39da6bd +Create Date: 2024-07-09 13:18:22.022002 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '5fdd5df3d642' +down_revision = 'e698b39da6bd' +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column('FOIMinistryRequests', sa.Column('lockrecords', sa.Boolean(), nullable=True)) + + +def downgrade(): + op.drop_column('FOIMinistryRequests', 'lockrecords') diff --git a/request-management-api/request_api/models/FOIMinistryRequests.py b/request-management-api/request_api/models/FOIMinistryRequests.py index b31d1fc23..9697668a2 100644 --- a/request-management-api/request_api/models/FOIMinistryRequests.py +++ b/request-management-api/request_api/models/FOIMinistryRequests.py @@ -72,6 +72,7 @@ class FOIMinistryRequest(db.Model): identityverified = db.Column(JSON, unique=False, nullable=True) ministrysignoffapproval = db.Column(JSON, unique=False, nullable=True) requeststatuslabel = db.Column(db.String(50), nullable=False) + lockrecords = db.Column(db.Boolean, nullable=True) #ForeignKey References From 8a5a087e4cd488938cd4dd1abedf87c457678637 Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Tue, 9 Jul 2024 15:29:13 -0700 Subject: [PATCH 03/15] Backend work completed to get lockrecords value from DB --- .../request_api/models/FOIMinistryRequests.py | 2 +- .../request_api/services/foirequest/requestservicegetter.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/request-management-api/request_api/models/FOIMinistryRequests.py b/request-management-api/request_api/models/FOIMinistryRequests.py index 9697668a2..bae906e4a 100644 --- a/request-management-api/request_api/models/FOIMinistryRequests.py +++ b/request-management-api/request_api/models/FOIMinistryRequests.py @@ -1588,5 +1588,5 @@ class Meta: 'foirequest.receivedmodeid','requeststatus.requeststatusid','requeststatuslabel','requeststatus.name','programarea.bcgovcode', 'programarea.name','foirequest_id','foirequestversion_id','created_at','updated_at','createdby','assignedministryperson', 'assignedministrygroup','cfrduedate','closedate','closereasonid','closereason.name', - 'assignee.firstname','assignee.lastname','ministryassignee.firstname','ministryassignee.lastname', 'axisrequestid', 'axissyncdate', 'axispagecount', 'axislanpagecount', 'linkedrequests', 'ministrysignoffapproval', 'identityverified','originalldd','isoipcreview', 'recordspagecount') + 'assignee.firstname','assignee.lastname','ministryassignee.firstname','ministryassignee.lastname', 'axisrequestid', 'axissyncdate', 'axispagecount', 'axislanpagecount', 'linkedrequests', 'ministrysignoffapproval', 'identityverified','originalldd','isoipcreview', 'recordspagecount', 'lockrecords') diff --git a/request-management-api/request_api/services/foirequest/requestservicegetter.py b/request-management-api/request_api/services/foirequest/requestservicegetter.py index acfaa297f..5e934572e 100644 --- a/request-management-api/request_api/services/foirequest/requestservicegetter.py +++ b/request-management-api/request_api/services/foirequest/requestservicegetter.py @@ -191,6 +191,7 @@ def __preparebaseinfo(self,request,foiministryrequestid,requestministry,requestm 'isofflinepayment': FOIMinistryRequest.getofflinepaymentflag(foiministryrequestid), 'linkedRequests' : linkedministryrequests, 'identityVerified':requestministry['identityverified'], + 'lockrecords': requestministry['lockrecords'], } if requestministry['cfrduedate'] is not None: From 669c6a01c4941e36f87a270dbc0c76d26838bf5c Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Tue, 9 Jul 2024 16:22:38 -0700 Subject: [PATCH 04/15] adjusted section end point to consume lock records + adjusted FE initial state load to handle lock records --- .../components/FOI/FOIRequest/FOIRequest.js | 29 ++++++++++--------- .../request_api/schemas/foirequestwrapper.py | 1 + 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js index 95f3ac238..875934042 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js @@ -296,6 +296,21 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { } else if (window.location.href.indexOf("records") > -1) { tabclick("Records"); } + //Adjust lockRecords tab state if there is no BE/DB data recorded + const updateRecordsTabAccess = () => { + if(requestDetails.lockrecords === null) { + return ( + requestState === StateEnum.recordsreadyforreview.name || + requestState === StateEnum.review.name || + requestState === StateEnum.consult.name || + requestState === StateEnum.peerreview.name || + requestState === StateEnum.signoff.name || + requestState === StateEnum.response.name || + requestState === StateEnum.closed.name + ); + } + } + setLockRecordsTab(updateRecordsTabAccess()) }, []); useEffect(async () => { @@ -1033,20 +1048,6 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { requestDetails?.requestType === FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_GENERAL) } - const updateRecordsTabAccess = () => { - if(requestDetails.lockRecords === null) { - return ( - requestState === StateEnum.recordsreadyforreview.name || - requestState === StateEnum.review.name || - requestState === StateEnum.consult.name || - requestState === StateEnum.peerreview.name || - requestState === StateEnum.signoff.name || - requestState === StateEnum.response.name || - requestState === StateEnum.closed.name - ); - } - } - const handleLockRecords = () => { setLockRecordsTab(!lockRecordsTab); console.log("API CALL TO LOCK RECORDS ENDPOINT") // OR JUST REUQEST UPDATE END POINT AND NO NEED FOR NEW ONE? diff --git a/request-management-api/request_api/schemas/foirequestwrapper.py b/request-management-api/request_api/schemas/foirequestwrapper.py index a5d528bde..7ebc88f32 100644 --- a/request-management-api/request_api/schemas/foirequestwrapper.py +++ b/request-management-api/request_api/schemas/foirequestwrapper.py @@ -155,6 +155,7 @@ class Meta: # pylint: disable=too-few-public-methods identityVerified = fields.Str(data_key="identityVerified",allow_none=True) oipcdetails = fields.Nested(FOIMinistryRequestOIPCSchema, many=True,allow_none=True) + lockrecords = fields.Bool(data_key="isofflinepayment") recordspagecount = fields.Int(data_key="recordspagecount",allow_none=True) axislanpagecount = fields.Int(data_key="axislanpagecount",allow_none=True) From ea57ee383b696653b5060a3886d8e919e283a2bc Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Wed, 10 Jul 2024 17:13:03 -0700 Subject: [PATCH 05/15] FE and backend logic for state changing for IAO users connected. WIP Debugging + button / manual lock feautre + ministry user work --- .../FOI/FOIRequest/BottomButtonGroup/index.js | 11 ++++++ .../components/FOI/FOIRequest/FOIRequest.js | 38 +++++++++++-------- .../request_api/schemas/foirequestwrapper.py | 2 +- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js b/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js index dd2344981..38221aab5 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js @@ -77,6 +77,7 @@ const BottomButtonGroup = React.memo( axisMessage, attachmentsArray, oipcData, + validLockRecordsState, }) => { /** * Bottom Button Group of Review request Page @@ -120,6 +121,14 @@ const BottomButtonGroup = React.memo( setIsAddRequest(false); } + //Logic to change lock records to null (and have FE useEffect in FOIRequest.js/MinistryView.js logic takeover) if request goes back to open, cfr, harms, fee estimate, dedup + if (!validLockRecordsState(currentSelectedStatus)) { + console.log("GOT YA") + saveRequestObject.lockrecords = true; + } + + console.log("SAVE PBJ", saveRequestObject) + //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 : []; @@ -253,6 +262,7 @@ const BottomButtonGroup = React.memo( }; const handleModal = (value) => { + console.log("LIQUIDD") setOpenModal(false); if (!value) { handleOpenRequest("", "", true); @@ -389,6 +399,7 @@ const BottomButtonGroup = React.memo( const handleSaveModal = (value, fileInfoList, files) => { setsaveModal(false); setFileCount(files?.length); + console.log("SNAKEE") if (!value) { handleSaveRequest(requestState, true, ""); diff --git a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js index 875934042..a241fc4b5 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js @@ -296,21 +296,6 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { } else if (window.location.href.indexOf("records") > -1) { tabclick("Records"); } - //Adjust lockRecords tab state if there is no BE/DB data recorded - const updateRecordsTabAccess = () => { - if(requestDetails.lockrecords === null) { - return ( - requestState === StateEnum.recordsreadyforreview.name || - requestState === StateEnum.review.name || - requestState === StateEnum.consult.name || - requestState === StateEnum.peerreview.name || - requestState === StateEnum.signoff.name || - requestState === StateEnum.response.name || - requestState === StateEnum.closed.name - ); - } - } - setLockRecordsTab(updateRecordsTabAccess()) }, []); useEffect(async () => { @@ -357,6 +342,20 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { if (bcgovcode) dispatch(fetchFOIMinistryAssignedToList(bcgovcode)); }, [requestId, ministryId, comment, attachments]); + const validLockRecordsState = (currentState) => { + console.log("MIQU", requestDetails) + console.log("BOOM", currentState) + return ( + 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); @@ -392,6 +391,14 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { } else { setIsOIPCReview(false); } + + //Adjust lockRecords value based on requestState if there is no manual user lockrecords value present in requestDetails from DB + const updateRecordsTabAccess = () => { + if(requestDetails.lockrecords === null) { + return validLockRecordsState(requestDetails.currentState) + } + } + setLockRecordsTab(updateRecordsTabAccess()); }, [requestDetails]); //useEffect to manage isoipcreview attribute for requestdetails state @@ -1416,6 +1423,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { axisMessage={axisMessage} attachmentsArray={requestAttachments} oipcData={oipcData} + validLockRecordsState={validLockRecordsState} /> diff --git a/request-management-api/request_api/schemas/foirequestwrapper.py b/request-management-api/request_api/schemas/foirequestwrapper.py index 7ebc88f32..0d8925d1a 100644 --- a/request-management-api/request_api/schemas/foirequestwrapper.py +++ b/request-management-api/request_api/schemas/foirequestwrapper.py @@ -155,7 +155,7 @@ class Meta: # pylint: disable=too-few-public-methods identityVerified = fields.Str(data_key="identityVerified",allow_none=True) oipcdetails = fields.Nested(FOIMinistryRequestOIPCSchema, many=True,allow_none=True) - lockrecords = fields.Bool(data_key="isofflinepayment") + lockrecords = fields.Bool(data_key="lockrecords", allow_none=True) recordspagecount = fields.Int(data_key="recordspagecount",allow_none=True) axislanpagecount = fields.Int(data_key="axislanpagecount",allow_none=True) From 94a9b0130cb05aa6407e9f0010ce37e2edc2d95e Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Thu, 11 Jul 2024 14:16:28 -0700 Subject: [PATCH 06/15] IAO Workflow for state lock records completed. WIP manual lock records for IAO --- .../src/components/FOI/FOIRequest/BottomButtonGroup/index.js | 5 +---- forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js | 4 +++- .../request_api/services/foirequest/requestservicebuilder.py | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js b/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js index 38221aab5..5d1f0d991 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js @@ -123,12 +123,9 @@ const BottomButtonGroup = React.memo( //Logic to change lock records to null (and have FE useEffect in FOIRequest.js/MinistryView.js logic takeover) if request goes back to open, cfr, harms, fee estimate, dedup if (!validLockRecordsState(currentSelectedStatus)) { - console.log("GOT YA") - saveRequestObject.lockrecords = true; + saveRequestObject.lockrecords = null; } - console.log("SAVE PBJ", saveRequestObject) - //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 : []; diff --git a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js index a241fc4b5..4c41534f8 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js @@ -395,7 +395,9 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { //Adjust lockRecords value based on requestState if there is no manual user lockrecords value present in requestDetails from DB const updateRecordsTabAccess = () => { if(requestDetails.lockrecords === null) { - return validLockRecordsState(requestDetails.currentState) + return validLockRecordsState(requestDetails.currentState); + } else { + return requestDetails.lockrecords; } } setLockRecordsTab(updateRecordsTabAccess()); diff --git a/request-management-api/request_api/services/foirequest/requestservicebuilder.py b/request-management-api/request_api/services/foirequest/requestservicebuilder.py index 31dca5387..2da57d7bd 100644 --- a/request-management-api/request_api/services/foirequest/requestservicebuilder.py +++ b/request-management-api/request_api/services/foirequest/requestservicebuilder.py @@ -54,6 +54,7 @@ def createministry(self, requestschema, ministry, activeversion, userid, filenum foiministryrequest.startdate = startdate foiministryrequest.createdby = userid requeststatuslabel = self.getpropertyvaluefromschema(requestschema, 'requeststatuslabel') + foiministryrequest.lockrecords = requestschema.get("lockrecords") if requeststatuslabel is not None: status = self.getstatusname(requeststatuslabel) if self.isNotBlankorNone(requestschema,"fromDate","main") == True: From 25ef0c80c6d44b6d61dc2e9a1697d8cccd8470b3 Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Thu, 11 Jul 2024 14:34:11 -0700 Subject: [PATCH 07/15] renamed lockrecords to userlockedrecords for DB/models --- .../components/FOI/FOIRequest/BottomButtonGroup/index.js | 2 +- forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js | 6 +++--- request-management-api/migrations/versions/5fdd5df3d642_.py | 6 +++--- .../request_api/models/FOIMinistryRequests.py | 4 ++-- .../request_api/schemas/foirequestwrapper.py | 2 +- .../services/foirequest/requestservicebuilder.py | 2 +- .../request_api/services/foirequest/requestservicegetter.py | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js b/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js index 5d1f0d991..edcd53002 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js @@ -123,7 +123,7 @@ const BottomButtonGroup = React.memo( //Logic to change lock records to null (and have FE useEffect in FOIRequest.js/MinistryView.js logic takeover) if request goes back to open, cfr, harms, fee estimate, dedup if (!validLockRecordsState(currentSelectedStatus)) { - saveRequestObject.lockrecords = null; + saveRequestObject.userlockedrecords = null; } //add oipc Data to save request object and sync/validate isoipcreview attribute diff --git a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js index 4c41534f8..562ad749e 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js @@ -392,12 +392,12 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { setIsOIPCReview(false); } - //Adjust lockRecords value based on requestState if there is no manual user lockrecords value present in requestDetails from DB + //Adjust lockRecords value based on requestState if there is no manual user lockedrecords value present in requestDetails from DB const updateRecordsTabAccess = () => { - if(requestDetails.lockrecords === null) { + if(requestDetails.userlockedrecords === null) { return validLockRecordsState(requestDetails.currentState); } else { - return requestDetails.lockrecords; + return requestDetails.userlockedrecords; } } setLockRecordsTab(updateRecordsTabAccess()); diff --git a/request-management-api/migrations/versions/5fdd5df3d642_.py b/request-management-api/migrations/versions/5fdd5df3d642_.py index e943559dc..86b517d77 100644 --- a/request-management-api/migrations/versions/5fdd5df3d642_.py +++ b/request-management-api/migrations/versions/5fdd5df3d642_.py @@ -1,4 +1,4 @@ -"""ADD LOCKRECORDS Column to FOIMinistryRequest +"""ADD userlockedrecords Column to FOIMinistryRequest Revision ID: 5fdd5df3d642 Revises: e698b39da6bd @@ -17,8 +17,8 @@ def upgrade(): - op.add_column('FOIMinistryRequests', sa.Column('lockrecords', sa.Boolean(), nullable=True)) + op.add_column('FOIMinistryRequests', sa.Column('userlockedrecords', sa.Boolean(), nullable=True)) def downgrade(): - op.drop_column('FOIMinistryRequests', 'lockrecords') + op.drop_column('FOIMinistryRequests', 'userlockedrecords') diff --git a/request-management-api/request_api/models/FOIMinistryRequests.py b/request-management-api/request_api/models/FOIMinistryRequests.py index bae906e4a..df9514bba 100644 --- a/request-management-api/request_api/models/FOIMinistryRequests.py +++ b/request-management-api/request_api/models/FOIMinistryRequests.py @@ -72,7 +72,7 @@ class FOIMinistryRequest(db.Model): identityverified = db.Column(JSON, unique=False, nullable=True) ministrysignoffapproval = db.Column(JSON, unique=False, nullable=True) requeststatuslabel = db.Column(db.String(50), nullable=False) - lockrecords = db.Column(db.Boolean, nullable=True) + userlockedrecords = db.Column(db.Boolean, nullable=True) #ForeignKey References @@ -1588,5 +1588,5 @@ class Meta: 'foirequest.receivedmodeid','requeststatus.requeststatusid','requeststatuslabel','requeststatus.name','programarea.bcgovcode', 'programarea.name','foirequest_id','foirequestversion_id','created_at','updated_at','createdby','assignedministryperson', 'assignedministrygroup','cfrduedate','closedate','closereasonid','closereason.name', - 'assignee.firstname','assignee.lastname','ministryassignee.firstname','ministryassignee.lastname', 'axisrequestid', 'axissyncdate', 'axispagecount', 'axislanpagecount', 'linkedrequests', 'ministrysignoffapproval', 'identityverified','originalldd','isoipcreview', 'recordspagecount', 'lockrecords') + 'assignee.firstname','assignee.lastname','ministryassignee.firstname','ministryassignee.lastname', 'axisrequestid', 'axissyncdate', 'axispagecount', 'axislanpagecount', 'linkedrequests', 'ministrysignoffapproval', 'identityverified','originalldd','isoipcreview', 'recordspagecount', 'userlockedrecords') diff --git a/request-management-api/request_api/schemas/foirequestwrapper.py b/request-management-api/request_api/schemas/foirequestwrapper.py index 0d8925d1a..71f23f005 100644 --- a/request-management-api/request_api/schemas/foirequestwrapper.py +++ b/request-management-api/request_api/schemas/foirequestwrapper.py @@ -155,7 +155,7 @@ class Meta: # pylint: disable=too-few-public-methods identityVerified = fields.Str(data_key="identityVerified",allow_none=True) oipcdetails = fields.Nested(FOIMinistryRequestOIPCSchema, many=True,allow_none=True) - lockrecords = fields.Bool(data_key="lockrecords", allow_none=True) + userlockedrecords = fields.Bool(data_key="userlockedrecords", allow_none=True) recordspagecount = fields.Int(data_key="recordspagecount",allow_none=True) axislanpagecount = fields.Int(data_key="axislanpagecount",allow_none=True) diff --git a/request-management-api/request_api/services/foirequest/requestservicebuilder.py b/request-management-api/request_api/services/foirequest/requestservicebuilder.py index 2da57d7bd..879f6ea61 100644 --- a/request-management-api/request_api/services/foirequest/requestservicebuilder.py +++ b/request-management-api/request_api/services/foirequest/requestservicebuilder.py @@ -54,7 +54,7 @@ def createministry(self, requestschema, ministry, activeversion, userid, filenum foiministryrequest.startdate = startdate foiministryrequest.createdby = userid requeststatuslabel = self.getpropertyvaluefromschema(requestschema, 'requeststatuslabel') - foiministryrequest.lockrecords = requestschema.get("lockrecords") + foiministryrequest.userlockedrecords = requestschema.get("userlockedrecords") if requeststatuslabel is not None: status = self.getstatusname(requeststatuslabel) if self.isNotBlankorNone(requestschema,"fromDate","main") == True: diff --git a/request-management-api/request_api/services/foirequest/requestservicegetter.py b/request-management-api/request_api/services/foirequest/requestservicegetter.py index 5e934572e..46cc84c9c 100644 --- a/request-management-api/request_api/services/foirequest/requestservicegetter.py +++ b/request-management-api/request_api/services/foirequest/requestservicegetter.py @@ -191,7 +191,7 @@ def __preparebaseinfo(self,request,foiministryrequestid,requestministry,requestm 'isofflinepayment': FOIMinistryRequest.getofflinepaymentflag(foiministryrequestid), 'linkedRequests' : linkedministryrequests, 'identityVerified':requestministry['identityverified'], - 'lockrecords': requestministry['lockrecords'], + 'userlockedrecords': requestministry['userlockedrecords'], } if requestministry['cfrduedate'] is not None: From 793f77c6eaa7ec5d01380801463296b21bc5189f Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Thu, 11 Jul 2024 16:12:27 -0700 Subject: [PATCH 08/15] controlling of lock records for IAO user completed. WIP ministry user --- .../services/FOI/foiRecordServices.js | 26 ++++++++++- .../components/FOI/FOIRequest/FOIRequest.js | 7 +-- .../FOI/customComponents/Records/index.js | 45 +++++++++++++++++++ .../request_api/resources/foirequest.py | 11 ++++- 4 files changed, 80 insertions(+), 9 deletions(-) diff --git a/forms-flow-web/src/apiManager/services/FOI/foiRecordServices.js b/forms-flow-web/src/apiManager/services/FOI/foiRecordServices.js index 8c2d48a61..1cdf61f42 100644 --- a/forms-flow-web/src/apiManager/services/FOI/foiRecordServices.js +++ b/forms-flow-web/src/apiManager/services/FOI/foiRecordServices.js @@ -620,4 +620,28 @@ export const fetchPDFStitchedRecordForOIPCRedlineReview = ( done(error); }); }; - } \ No newline at end of file + } + +export const updateUserLockedRecords = (data, requestId, ministryId, ...rest) => { + const done = fnDone(rest); + let apiUrl= replaceUrl(replaceUrl( + API.FOI_REQUEST_SECTION_API, + "", + ministryId),"",requestId + ); + return (dispatch) => { + httpPOSTRequest(`${apiUrl}/userlockedrecords`, 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); + }); + }; +} \ No newline at end of file diff --git a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js index 562ad749e..19dda3ec4 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js @@ -1057,11 +1057,6 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { requestDetails?.requestType === FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_GENERAL) } - const handleLockRecords = () => { - setLockRecordsTab(!lockRecordsTab); - console.log("API CALL TO LOCK RECORDS ENDPOINT") // OR JUST REUQEST UPDATE END POINT AND NO NEED FOR NEW ONE? - } - return (!isLoading && requestDetails && Object.keys(requestDetails).length !== 0) || @@ -1671,7 +1666,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { recordsTabSelect={tabLinksStatuses.Records.active} requestType={requestDetails?.requestType} lockRecords={lockRecordsTab} - handleLockRecords={handleLockRecords} + setLockRecordsTab={setLockRecordsTab} /> )} 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 67a4095a6..46b40bc65 100644 --- a/forms-flow-web/src/components/FOI/customComponents/Records/index.js +++ b/forms-flow-web/src/components/FOI/customComponents/Records/index.js @@ -33,6 +33,7 @@ import { fetchPDFStitchedRecordForOIPCRedline, fetchPDFStitchedRecordForOIPCRedlineReview, checkForRecordsChange, + updateUserLockedRecords, } from "../../../../apiManager/services/FOI/foiRecordServices"; import { StateTransitionCategories, @@ -220,6 +221,7 @@ export const RecordsLog = ({ recordsTabSelect, requestType, lockRecords, + setLockRecordsTab, }) => { const user = useSelector((state) => state.user.userDetail); const userGroups = user?.groups?.map((group) => group.slice(1)); @@ -577,6 +579,7 @@ export const RecordsLog = ({ saveDocument(value, fileInfoList, files); } }; + console.log("LOCK", lockRecords) const saveDocument = (value, fileInfoList, files) => { if (value) { @@ -1742,6 +1745,47 @@ export const RecordsLog = ({ ); }; + const handleLockRecords = () => { + setLockRecordsTab(!lockRecords); + const toastID = toast.loading("Updating records lock status for request..."); + const data = {userlockedrecords: !lockRecords}; + dispatch( + updateUserLockedRecords( + data, + requestId, + ministryId, + (err, _res) => { + if(!err) { + toast.update(toastID, { + type: "success", + render: "Request details have been saved successfully.", + position: "top-right", + isLoading: false, + autoClose: 3000, + hideProgressBar: true, + closeOnClick: true, + pauseOnHover: true, + draggable: true, + progress: undefined, + }); + } else { + toast.error( + "Temporarily unable to update records lock status for request. Please try again in a few minutes.", + { + position: "top-right", + autoClose: 3000, + hideProgressBar: true, + closeOnClick: true, + pauseOnHover: true, + draggable: true, + progress: undefined, + } + ); + } + }) + ) + } + return (
{isAttachmentLoading ? ( @@ -1766,6 +1810,7 @@ export const RecordsLog = ({ + + + + : null } @@ -2157,7 +2164,7 @@ export const RecordsLog = ({ } style={ records.filter((record) => record.attachments?.length > 0) - .length === 0 + .length === 0 || lockRecords ? { pointerEvents: "none" } : {} } @@ -2176,6 +2183,7 @@ export const RecordsLog = ({
To update divisions:{" "}
    +
  • Records log must be unlocked
  • at least one record must be selected
  • all records selected must be tagged to the same @@ -2229,7 +2237,7 @@ export const RecordsLog = ({ // title="Delete" disabled={lockRecords || !checkIsAnySelected()} style={ - !checkIsAnySelected() ? { pointerEvents: "none" } : {} + lockRecords || !checkIsAnySelected() ? { pointerEvents: "none" } : {} } > @@ -2974,6 +2982,7 @@ const AttachmentPopup = React.memo( const DeleteMenu = () => { return ( { handleDelete(); From 300faf77486fe68354afc05f0ac85a0edf56a69e Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Fri, 12 Jul 2024 16:52:59 -0700 Subject: [PATCH 14/15] renamed column for manual records lock in BE + adjusted styling for ministry view records tab --- .../services/FOI/foiRecordServices.js | 2 +- .../FOI/FOIRequest/BottomButtonGroup/index.js | 4 +- .../components/FOI/FOIRequest/FOIRequest.js | 4 +- .../MinistryReview/BottomButtonGroup.js | 4 +- .../MinistryReview/MinistryReview.js | 4 +- .../FOI/customComponents/Records/index.js | 65 ++++++++++--------- .../migrations/versions/5fdd5df3d642_.py | 6 +- .../request_api/models/FOIMinistryRequests.py | 4 +- .../request_api/resources/foirequest.py | 7 +- .../request_api/schemas/foirequestwrapper.py | 2 +- .../foirequest/requestservicebuilder.py | 2 +- .../foirequest/requestservicegetter.py | 2 +- 12 files changed, 54 insertions(+), 52 deletions(-) diff --git a/forms-flow-web/src/apiManager/services/FOI/foiRecordServices.js b/forms-flow-web/src/apiManager/services/FOI/foiRecordServices.js index 1cdf61f42..47e7f50d3 100644 --- a/forms-flow-web/src/apiManager/services/FOI/foiRecordServices.js +++ b/forms-flow-web/src/apiManager/services/FOI/foiRecordServices.js @@ -630,7 +630,7 @@ export const updateUserLockedRecords = (data, requestId, ministryId, ...rest) => ministryId),"",requestId ); return (dispatch) => { - httpPOSTRequest(`${apiUrl}/userlockedrecords`, data) + httpPOSTRequest(`${apiUrl}/userrecordslockstatus`, data) .then((res) => { if (res.data) { done(null, res.data); diff --git a/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js b/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js index cfc472f3e..a66d4b21d 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js @@ -122,8 +122,8 @@ const BottomButtonGroup = React.memo( } //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 (saveRequestObject.userlockedrecords !== null && !validLockRecordsState(currentSelectedStatus)) { - saveRequestObject.userlockedrecords = null; + if (saveRequestObject.userrecordslockstatus !== null && !validLockRecordsState(currentSelectedStatus)) { + saveRequestObject.userrecordslockstatus = null; } //add oipc Data to save request object and sync/validate isoipcreview attribute diff --git a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js index a9ee8b437..947dcdcaa 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js @@ -394,10 +394,10 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { //Adjust lockRecords value based on requestState if there is no manual user lockedrecords value present in requestDetails from DB const updateRecordsTabAccess = () => { - if(requestDetails.userlockedrecords === null) { + if(requestDetails.userrecordslockstatus === null) { return validLockRecordsState(requestDetails.currentState); } else { - return requestDetails.userlockedrecords; + return requestDetails.userrecordslockstatus; } } setLockRecordsTab(updateRecordsTabAccess()); diff --git a/forms-flow-web/src/components/FOI/FOIRequest/MinistryReview/BottomButtonGroup.js b/forms-flow-web/src/components/FOI/FOIRequest/MinistryReview/BottomButtonGroup.js index c215565a0..362945cb0 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/MinistryReview/BottomButtonGroup.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/MinistryReview/BottomButtonGroup.js @@ -111,8 +111,8 @@ 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 (saveMinistryRequestObject.userlockedrecords !== null && !validLockRecordsState(currentSelectedStatus)) { - saveMinistryRequestObject.userlockedrecords = null; + if (saveMinistryRequestObject.userrecordslockstatus !== null && !validLockRecordsState(currentSelectedStatus)) { + saveMinistryRequestObject.userrecordslockstatus = null; } dispatch( saveMinistryRequestDetails( 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 cb22cc392..0e3f867d8 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/MinistryReview/MinistryReview.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/MinistryReview/MinistryReview.js @@ -293,10 +293,10 @@ const MinistryReview = React.memo(({ userDetail }) => { //Adjust lockRecords value based on requestState if there is no manual user lockedrecords value present in requestDetails from DB const updateRecordsTabAccess = () => { - if(requestDetails.userlockedrecords === null) { + if(requestDetails.userrecordslockstatus === null) { return validLockRecordsState(requestDetails.currentState); } else { - return requestDetails.userlockedrecords; + return requestDetails.userrecordslockstatus; } } setLockRecordsTab(updateRecordsTabAccess()); 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 cc4ee1133..9c50344a7 100644 --- a/forms-flow-web/src/components/FOI/customComponents/Records/index.js +++ b/forms-flow-web/src/components/FOI/customComponents/Records/index.js @@ -580,7 +580,6 @@ export const RecordsLog = ({ saveDocument(value, fileInfoList, files); } }; - console.log("LOCK", lockRecords) const saveDocument = (value, fileInfoList, files) => { if (value) { @@ -1749,7 +1748,7 @@ export const RecordsLog = ({ const handleLockRecords = () => { setLockRecordsTab(!lockRecords); const toastID = toast.loading("Updating records lock status for request..."); - const data = {userlockedrecords: !lockRecords}; + const data = {userrecordslockstatus: !lockRecords}; dispatch( updateUserLockedRecords( data, @@ -1808,15 +1807,20 @@ export const RecordsLog = ({ {validLockRecordsState() ? - + - + {isMinistryCoordinator ? +

    + {lockRecords ? "Records Locked" : "Records Unlocked"} +

    + : - - ) - )} -
    + Redact Records + + +
    + ) + )} {hasDocumentsToDownload && ( Date: Fri, 12 Jul 2024 17:03:26 -0700 Subject: [PATCH 15/15] styling of records header grid --- .../src/components/FOI/customComponents/Records/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9c50344a7..015e7e634 100644 --- a/forms-flow-web/src/components/FOI/customComponents/Records/index.js +++ b/forms-flow-web/src/components/FOI/customComponents/Records/index.js @@ -1834,7 +1834,7 @@ export const RecordsLog = ({ } - : null + : } {(isMinistryCoordinator == false && records?.length > 0 &&