From 4001a12770272ed6004e7fcd159a873d660ec90f Mon Sep 17 00:00:00 2001 From: Jakub Date: Tue, 31 Mar 2020 14:02:23 -0400 Subject: [PATCH] submitted by global --- src/config/serverConfig.dev.json | 2 +- src/modules/action/components/step/step.component.tsx | 1 + src/modules/action/services/mechanism.service.tsx | 5 +++-- src/modules/list/services/mechanisms.service.tsx | 7 ++++--- src/modules/shared/services/permittedActions.service.tsx | 3 ++- src/modules/shared/services/status.service.tsx | 1 + 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/config/serverConfig.dev.json b/src/config/serverConfig.dev.json index e563184..fc45a91 100644 --- a/src/config/serverConfig.dev.json +++ b/src/config/serverConfig.dev.json @@ -1,5 +1,5 @@ { - "baseUrl": "https://dev.datim.org/", + "baseUrl": "https://test.datim.org/", "sqlViewId": "rQZnEgCAhuI", "apiVersion": "30" } \ No newline at end of file diff --git a/src/modules/action/components/step/step.component.tsx b/src/modules/action/components/step/step.component.tsx index 12bc1af..2df25cc 100644 --- a/src/modules/action/components/step/step.component.tsx +++ b/src/modules/action/components/step/step.component.tsx @@ -67,6 +67,7 @@ export default function Step({workflow, mechanismState, userType}:{workflow: str const classes = useStyles(); if (!mechanismState) return ;; if (!userType) return null; + if (mechanismState.status === 'submitted by global') return null; const workflowType = getWorkflowTypeById(workflow); return( diff --git a/src/modules/action/services/mechanism.service.tsx b/src/modules/action/services/mechanism.service.tsx index d0686f9..a0d5656 100644 --- a/src/modules/action/services/mechanism.service.tsx +++ b/src/modules/action/services/mechanism.service.tsx @@ -108,9 +108,10 @@ export function getMechanismsInfo(mechanismIds: string[]):Promise{ if (infoResp.categoryOptions.filter(i=>i.id===mech.id).length>1) console.log(`Two info records per mechanism ${mech.id} ${mechInfo.name}`); if (!mechInfo.organisationUnits[0]) return console.log(`No OU info for Mechanism ${mech.id} ${mechInfo.name}. Mechanism filtered out.`, mech, mechInfo); if (mechInfo.organisationUnits[0].id!==filters.ou && filters.ou!=='ybg3MO3hcf4') return console.log(`OU info not matching for Mechanism ${mech.id} ${mechInfo.name}. Mechanism filtered out.`, mech, mechInfo); + let status = getStatus(getWorkflowTypeById(filters.workflow), mech.level.level, mech.accepted); return { info: { name: mechInfo.name, @@ -47,8 +48,8 @@ export function fetchMechanisms(filters:Filters):Promise{ agency: getInfoByGroupSet(mechInfo, agencyGroupSet), }, state: { - status: getStatus(getWorkflowTypeById(filters.workflow), mech.level.level, mech.accepted), - actions: getPermittedActions(mech.permissions), + status: status, + actions: getPermittedActions(mech.permissions, status), view: mech.permissions.mayReadData }, meta: { diff --git a/src/modules/shared/services/permittedActions.service.tsx b/src/modules/shared/services/permittedActions.service.tsx index 2ce7316..48f903d 100644 --- a/src/modules/shared/services/permittedActions.service.tsx +++ b/src/modules/shared/services/permittedActions.service.tsx @@ -18,8 +18,9 @@ function canReturn(dhis2Permissions:Dhis2Permissions):boolean{ return false; } -export default function getPermittedActions(dhis2permissions:Dhis2Permissions):MechanismActions { +export default function getPermittedActions(dhis2permissions:Dhis2Permissions, currentStatus:string):MechanismActions { if (!dhis2permissions) return {}; + if (currentStatus==='accepted by global') dhis2permissions.mayApprove = false; return { submit: dhis2permissions.mayApprove, accept: dhis2permissions.mayAccept, diff --git a/src/modules/shared/services/status.service.tsx b/src/modules/shared/services/status.service.tsx index 8903279..6687c6c 100644 --- a/src/modules/shared/services/status.service.tsx +++ b/src/modules/shared/services/status.service.tsx @@ -9,5 +9,6 @@ export default function getStatus(workflowType:string, level:string, accepted:b if (level==='2' && !accepted && workflowType==='ER') return 'submitted by agency hq'; if (level==='2' && accepted && workflowType==='ER') return 'accepted by global'; if (level==='3' && accepted) return 'accepted by global'; + if (level==='1' && !accepted) return 'submitted by global'; return `${level} / ${accepted}`; } \ No newline at end of file