Skip to content

Commit

Permalink
Merge pull request #190 from pepfar-datim/hide-submit
Browse files Browse the repository at this point in the history
submitted by global
  • Loading branch information
jakub-bao authored Apr 15, 2020
2 parents 659c78b + 4001a12 commit 82b9446
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/config/serverConfig.dev.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"baseUrl": "https://dev.datim.org/",
"baseUrl": "https://test.datim.org/",
"sqlViewId": "rQZnEgCAhuI",
"apiVersion": "30"
}
1 change: 1 addition & 0 deletions src/modules/action/components/step/step.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default function Step({workflow, mechanismState, userType}:{workflow: str
const classes = useStyles();
if (!mechanismState) return <Loading message='Loading mechanism state...'/>;;
if (!userType) return null;
if (mechanismState.status === 'submitted by global') return null;
const workflowType = getWorkflowTypeById(workflow);
return(
<Stepper id='cy_actionPage_stepper' activeStep={getStepNr(mechanismState.status, workflowType)} alternativeLabel classes={{root:classes.root}}>
Expand Down
5 changes: 3 additions & 2 deletions src/modules/action/services/mechanism.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ export function getMechanismsInfo(mechanismIds: string[]):Promise<MechanismInfo[
}

function transformCOCToMechanismState(workflow, combo){
let status = getStatus(getWorkflowTypeById(workflow), combo.level.level, combo.accepted);
return {
status: getStatus(getWorkflowTypeById(workflow), combo.level.level, combo.accepted),
actions: getPermittedActions(combo.permissions),
status: status,
actions: getPermittedActions(combo.permissions, status),
view: combo.permissions.mayReadData
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/modules/list/services/mechanisms.service.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import api from "../../shared/services/api.service";
import MechanismModel, {MechanismActions} from "../../shared/models/mechanism.model";
import MechanismModel from "../../shared/models/mechanism.model";
import getStatus from "../../shared/services/status.service";
import Filters from "../models/filters.model";
import {getWorkflowTypeById} from "../../shared/services/workflowService";
Expand Down Expand Up @@ -39,6 +39,7 @@ export function fetchMechanisms(filters:Filters):Promise<MechanismModel[]>{
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,
Expand All @@ -47,8 +48,8 @@ export function fetchMechanisms(filters:Filters):Promise<MechanismModel[]>{
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: {
Expand Down
3 changes: 2 additions & 1 deletion src/modules/shared/services/permittedActions.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/modules/shared/services/status.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}

0 comments on commit 82b9446

Please sign in to comment.