Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0ddf2cf
Initial commit
chauthutran Jan 5, 2025
78f3560
Add Attribute Category Option Combo for this app
chauthutran Jan 6, 2025
891c740
Fixed exception related to "ProgramRuleActions"
chauthutran Jan 7, 2025
479934d
Minor fix
chauthutran Jan 8, 2025
51656e9
Updated
chauthutran Jan 10, 2025
54c5029
Accept and unaccept buttons
chauthutran Jan 10, 2025
fbf89e1
Minor fix
chauthutran Jan 10, 2025
8a92221
rename categoryOptionCombo to attributeOptionCombo
chauthutran Jan 10, 2025
411d1ea
Fixed bug - The data sets are not shown when the selected workflow ha…
chauthutran Jan 11, 2025
e883ae3
Improve attribute-combo-select component
chauthutran Jan 11, 2025
deff69e
small changes in css
chauthutran Jan 11, 2025
e431a67
Init cateOptionCombo doesn't render properly to the component
chauthutran Jan 12, 2025
5d3e4f9
Add requiredValuesMessage for categoryCombo component; clean up codes
chauthutran Jan 15, 2025
832c716
Fixed bug when the selected workflow does not have any data set
chauthutran Jan 15, 2025
befc338
Minor fix
chauthutran Jan 15, 2025
a35a1fc
Keep dataSetReport API with filter params for retrieving data values
chauthutran Jan 15, 2025
71baeb2
Work on unit test
chauthutran Jan 16, 2025
6ef5c26
Build and fixed some Unit test
chauthutran Jan 17, 2025
798d298
Updated
chauthutran Jan 17, 2025
f98ac3e
Improve codes and fixed issue of API dataSetReports for default CatOp…
chauthutran Jan 17, 2025
c3e9687
Minor fix
chauthutran Jan 18, 2025
229e6c1
Fix unit tests
chauthutran Jan 18, 2025
995c265
Minor fixed for unit test
chauthutran Jan 20, 2025
b18c601
Update attribute-combo-select.test.js
chauthutran Jan 20, 2025
f9fb2d9
Fixed exception when we move between workflow
chauthutran Jan 21, 2025
2f113eb
Add filter inpur field for searching category options by display name…
chauthutran Jan 22, 2025
72ae117
Filter data set by the selected orgunit
chauthutran Jan 22, 2025
e73800f
DEV - Filter data set by the selected orgunit DEV - Fix bug - The mes…
chauthutran Jan 22, 2025
fa692ce
Minor changes
chauthutran Jan 23, 2025
354014e
Add period checking for category options
chauthutran Feb 3, 2025
787a90f
Improve the function relate to period and category options
chauthutran Feb 4, 2025
6d5132f
Add search field for Orgunti and Workflow dropdown
chauthutran Feb 12, 2025
d732b3f
Minor fixes.
chauthutran Feb 12, 2025
c726ff6
Filter data sets and categpry options with the selected orgunit and i…
chauthutran Mar 5, 2025
993293a
Merge github.com:psi-mis/approval-app into catcombo-approvals
Birkbjo Apr 3, 2025
a1cb94b
Fixed for orgunit and catOption relationship.
chauthutran Apr 4, 2025
e6f25ca
cleanup codes and added docs for some methods
chauthutran Apr 12, 2025
90b6cbf
Add filter for category options for multiple cases
chauthutran May 7, 2025
b6fdca6
Add the search input within the dropdown for category options for mul…
chauthutran May 7, 2025
a8d68ac
clean up
chauthutran May 7, 2025
6f3e78b
Remove unnecessary getTime() in OrgUnitSelect to prevent tree state r…
chauthutran May 14, 2025
06fdc65
Remove unused useEffect and clean up multiple-category-select component
chauthutran May 14, 2025
1f57a50
Group workflow, orgUnit, period, and calendar into a single config ob…
chauthutran May 14, 2025
0843750
Re-add timestamp to OrgUnitTree key to ensure fresh data fetch on roo…
chauthutran May 15, 2025
60611fd
Fix: correct typo in file name from 'caterogy-combo-utils' to 'catego…
chauthutran May 15, 2025
0321e74
Add logic to display category options assigned to descendant organisa…
chauthutran Jun 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added approval-app-tran.zip
Binary file not shown.
84 changes: 75 additions & 9 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2021-10-07T11:59:16.763Z\n"
"PO-Revision-Date: 2021-10-07T11:59:16.763Z\n"
"POT-Creation-Date: 2025-02-28T07:19:16.560Z\n"
"PO-Revision-Date: 2025-02-28T07:19:16.560Z\n"

msgid "Not authorized"
msgstr "Not authorized"
Expand Down Expand Up @@ -68,8 +68,14 @@ msgstr "Unapproval failed: {{error}}"
msgid "Unapprove"
msgstr "Unapprove"

msgid "This workflow does not contain any data sets."
msgstr "This workflow does not contain any data sets."
msgid ""
"Workflow \"{{ workflowName }}\", organisation unit \"{{ orgunitName }}\" "
"and attribute option combo \"{{ attrOptionComboName }}\" does not contain "
"any data sets."
msgstr ""
"Workflow \"{{ workflowName }}\", organisation unit \"{{ orgunitName }}\" "
"and attribute option combo \"{{ attrOptionComboName }}\" does not contain "
"any data sets."

msgid "Choose a data set to review"
msgstr "Choose a data set to review"
Expand All @@ -81,6 +87,23 @@ msgstr ""
"{{- workflowName}} has multiple data sets. Choose a data set from the tabs "
"above."

msgid "Could not load approval data"
msgstr "Could not load approval data"

msgid ""
"The selected workflow \"{{workflowName}}\" does not have any associated "
"data sets."
msgstr ""
"The selected workflow \"{{workflowName}}\" does not have any associated "
"data sets."

msgid ""
"Please verify the workflow configuration or select a different workflow "
"that includes data sets."
msgstr ""
"Please verify the workflow configuration or select a different workflow "
"that includes data sets."

msgid "Loading data set"
msgstr "Loading data set"

Expand Down Expand Up @@ -229,6 +252,49 @@ msgstr "Financial year (Start July)"
msgid "Financial year (Start April)"
msgstr "Financial year (Start April)"

msgid "Choose a period first"
msgstr "Choose a period first"

msgid "Choose an organisation unit first"
msgstr "Choose an organisation unit first"

msgid "1 selection"
msgstr "1 selection"

msgid "0 selections"
msgstr "0 selections"

msgid "{{amount}} selections"
msgstr "{{amount}} selections"

msgid "Category Option Combo"
msgstr "Category Option Combo"

msgid "Choose a category option combo"
msgstr "Choose a category option combo"

msgid "Choose a combination"
msgstr "Choose a combination"

msgid "Hide menu"
msgstr "Hide menu"

msgid "No available options"
msgstr "No available options"

msgid ""
"There are no options for {{categoryName}} for the selected period or "
"organisation unit."
msgstr ""
"There are no options for {{categoryName}} for the selected period or "
"organisation unit."

msgid "Search for {{categoryName}}"
msgstr "Search for {{categoryName}}"

msgid "No results found for {{searchQuery}}"
msgstr "No results found for {{searchQuery}}"

msgid "Clear selections"
msgstr "Clear selections"

Expand All @@ -241,9 +307,6 @@ msgstr "Approved"
msgid "Failed to load approval state"
msgstr "Failed to load approval state"

msgid "Choose a period first"
msgstr "Choose a period first"

msgid "Choose a workflow and period first"
msgstr "Choose a workflow and period first"

Expand All @@ -253,6 +316,9 @@ msgstr "Organisation Unit"
msgid "Choose an organisation unit"
msgstr "Choose an organisation unit"

msgid "Search by name"
msgstr "Search by name"

msgid "Period"
msgstr "Period"

Expand All @@ -271,8 +337,8 @@ msgstr "Choose a workflow"
msgid "No workflows found. None may exist, or you may not have access to any."
msgstr "No workflows found. None may exist, or you may not have access to any."

msgid "Could not load approval data"
msgstr "Could not load approval data"
msgid "Search"
msgstr "Search"

msgid "Retry loading approval data"
msgstr "Retry loading approval data"
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "approval-app",
"name": "approval-app-tran-dev",
"version": "100.0.16",
"description": "",
"license": "BSD-3-Clause",
Expand Down Expand Up @@ -43,12 +43,15 @@
},
"dependencies": {
"@dhis2/app-runtime": "^3.2.1",
"@dhis2/multi-calendar-dates": "^2.0.0",
"@dhis2/prop-types": "^1.6.4",
"@dhis2/ui": "^7.2.7",
"dompurify": "^3.1.6",
"history": "^5.0.1",
"prop-types": "^15.7.2",
"query-string": "^7.0.1",
"react-scripts": "^5.0.1",
"react-select": "^1.2.1",
"use-debounce": "^7.0.0"
}
}
1 change: 1 addition & 0 deletions src/app-context/app-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const AppContext = createContext({
authorities: [],
organisationUnits: [],
dataApprovalWorkflows: [],
metadata: {},
})

export { AppContext }
17 changes: 16 additions & 1 deletion src/app-context/app-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,23 @@ const query = {
'displayName',
'dataApprovalLevels',
'periodType',
'dataSets[id,displayName,periodType,formType]',
'dataSets[id,displayName,periodType,formType,categoryCombo[id],organisationUnits[id,path]]'
],
},
},
metadata: {
resource: 'categoryCombos',
params: {
paging: false,
fields: [
'id',
'displayName',
'isDefault',
'categories[displayName,name,id,categoryOptions[id,displayName,name,startDate,endDate,organisationUnits[id,path]]]',
'categoryOptionCombos[id,displayName,categoryOptions[id,displayName,name,startDate,endDate,organisationUnits[id,path]]]',
],
},
}
}

const AppProvider = ({ children }) => {
Expand All @@ -51,10 +64,12 @@ const AppProvider = ({ children }) => {

const { authorities, organisationUnits } = data.me
const { dataApprovalWorkflows } = data.dataApprovalWorkflows
const { metadata } = data
const providerValue = {
authorities,
organisationUnits,
dataApprovalWorkflows,
metadata
}

return (
Expand Down
32 changes: 21 additions & 11 deletions src/bottom-bar/accept-button/accept-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { useWorkflowContext } from '../../workflow-context/index.js'
import { useAcceptData } from './use-accept-data.js'

const AcceptButton = () => {
const [acceptData, { loading, error }] = useAcceptData()
const [acceptData, { loading, error }] = useAcceptData({
onComplete: () => {
refresh()
},
onError: (e) => console.log(e.message),
})

const { params, refresh } = useWorkflowContext()
const { show } = useAlert(
i18n.t('Acceptance failed: {{error}}', {
Expand All @@ -16,20 +22,24 @@ const AcceptButton = () => {
)

useEffect(() => {
if (error?.message) {
show()
}
}, [error?.message])

if (error?.message) {
show()
}
}, [error?.message])

const onAccept =() => {
const { wf, pe, ou, aoc } = params

const acceptances = [{"ou": ou, "aoc": aoc}]
acceptData({ wf:[wf], pe:[pe], approvals: acceptances })
}


return (
<Button
small
disabled={loading}
onClick={async () => {
const { wf, pe, ou } = params
await acceptData({ wf, pe, ou })
refresh()
}}
onClick={onAccept}
>
{i18n.t('Accept')}
</Button>
Expand Down
7 changes: 4 additions & 3 deletions src/bottom-bar/accept-button/use-accept-data.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useDataMutation } from '@dhis2/app-runtime'

export const ACCEPT_DATA_MUTATION = {
resource: 'dataAcceptances',
resource: 'dataAcceptances/acceptances',
type: 'create',
params: ({ wf, pe, ou }) => ({ wf, pe, ou }),
data: ({ wf, pe, approvals }) => ({ wf, pe, approvals }),
}

export const useAcceptData = () => useDataMutation(ACCEPT_DATA_MUTATION)
export const useAcceptData = ({ onComplete, onError }) =>
useDataMutation(ACCEPT_DATA_MUTATION, { onComplete, onError })
8 changes: 5 additions & 3 deletions src/bottom-bar/approve-button/approve-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ const ApproveButton = ({ disabled }) => {
const showApprovalDialog = () => setShowApproveModal(true)
const hideApprovalDialog = () => setShowApproveModal(false)
const onApprove = () => {
const { wf, pe, ou } = params
approveData({ wf, pe, ou })
const { wf, pe, ou, aoc } = params;

const approvals = [{"ou": ou, "aoc": aoc}];
approveData({ wf:[wf], pe:[pe], approvals })
}

// api
Expand All @@ -36,7 +38,7 @@ const ApproveButton = ({ disabled }) => {

// derived state
const error = approveError || unexpectedError

return (
<>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import {
import PropTypes from 'prop-types'
import React from 'react'
import { useSelectionContext } from '../../../selection-context/index.js'
import { filterDataSetsByAttributeOptionComboAndOrgUnit } from '../../../utils/category-combo-utils.js'
import styles from './approve-modal.module.css'
import { useAppContext } from '../../../app-context/use-app-context.js'

const ApproveModal = ({ onApprove, onCancel, error }) => {
const { workflow } = useSelectionContext()
const { dataSets } = workflow
const { metadata } = useAppContext()
const { workflow, orgUnit, attributeOptionCombo} = useSelectionContext()
const dataSets = filterDataSetsByAttributeOptionComboAndOrgUnit(metadata, workflow, orgUnit, attributeOptionCombo)
const count = dataSets.length

return (
Expand Down
4 changes: 2 additions & 2 deletions src/bottom-bar/approve-button/use-approve-data.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useDataMutation } from '@dhis2/app-runtime'

export const APPROVE_DATA_MUTATION = {
resource: 'dataApprovals',
resource: 'dataApprovals/approvals',
type: 'create',
params: ({ wf, pe, ou }) => ({ wf, pe, ou }),
data: ({ wf, pe, approvals }) => ({ wf, pe, approvals }),
}

export const useApproveData = ({ onComplete, onError }) =>
Expand Down
2 changes: 1 addition & 1 deletion src/bottom-bar/bottom-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ const BottomBar = () => {
)
}

export { BottomBar }
export { BottomBar }
21 changes: 15 additions & 6 deletions src/bottom-bar/unaccept-button/unaccept-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { useWorkflowContext } from '../../workflow-context/index.js'
import { useUnacceptData } from './use-unaccept-data.js'

const UnacceptButton = () => {
const [unacceptData, { loading, error }] = useUnacceptData()
const [unacceptData, { loading, error }] = useUnacceptData({
onComplete: () => {
refresh()
},
onError: (e) => console.log(e.message),
})
const { params, refresh } = useWorkflowContext()
const { show } = useAlert(
i18n.t('Unacceptance failed: {{error}}', {
Expand All @@ -21,15 +26,19 @@ const UnacceptButton = () => {
}
}, [error?.message])

const onUnaccept =() => {
const { wf, pe, ou, aoc } = params

const unapprovals = [{"ou": ou, "aoc": aoc}]
unacceptData({ wf:[wf], pe:[pe], approvals: unapprovals })
// refresh()
}

return (
<Button
small
disabled={loading}
onClick={async () => {
const { wf, pe, ou } = params
await unacceptData({ wf, pe, ou })
refresh()
}}
onClick={onUnaccept}
>
{i18n.t('Unaccept')}
</Button>
Expand Down
9 changes: 5 additions & 4 deletions src/bottom-bar/unaccept-button/use-unaccept-data.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useDataMutation } from '@dhis2/app-runtime'

export const UNACCEPT_DATA_MUTATION = {
resource: 'dataAcceptances',
type: 'delete',
params: ({ wf, pe, ou }) => ({ wf, pe, ou }),
resource: 'dataAcceptances/unacceptances',
type: 'create',
data: ({ wf, pe, approvals }) => ({ wf, pe, approvals }),
}

export const useUnacceptData = () => useDataMutation(UNACCEPT_DATA_MUTATION)
export const useUnacceptData = ({ onComplete, onError }) =>
useDataMutation(UNACCEPT_DATA_MUTATION, { onComplete, onError })
Loading