-
Notifications
You must be signed in to change notification settings - Fork 41
feat: [DHIS2-21655] Uncomplete events from view mode #4649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
henrikmv
wants to merge
39
commits into
master
Choose a base branch
from
hv/feat/DHIS2-21655_uncomplete-event-view-mode
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 33 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
1c23af4
feat: add uncomplete event functionality to view event
henrikmv ee06506
feat: add icon to changelog meny item
henrikmv 82231d5
fix: complexity error
henrikmv d43d0d7
feat: implement event completion functionality
henrikmv 9374438
fix: remove added changelog icon
henrikmv 6a87302
feat: add hook to determine event completion status permissions
henrikmv 54e7180
feat: optimize query client usage for event completion updates
henrikmv dc68891
fix: remove unused query client
henrikmv 240810f
Merge branch 'master' into hv/feat/DHIS2-21655_uncomplete-event-view-…
henrikmv 8f4186f
Merge remote-tracking branch 'origin/master' into hv/feat/DHIS2-21655…
henrikmv f0f539f
feat: add onMutate and onError callbacks to EventCompletionMenuItem
henrikmv 0e9aa8e
feat: implement event status management in EventCompletionMenuItem
henrikmv 5f6ac26
feat: allign pr with unify menu items pr
henrikmv 4ed2084
feat: add onMutate and onError props to EventCompletionMenuItem
henrikmv 2abdcd2
fix: remove atomicMode from resource query in EventCompletionMenuItem
henrikmv 8ddf18a
feat: remove feature flag for changelog
henrikmv 43ea9b9
fix: status needs refresh to update
henrikmv 46085b6
feat: integrate updateField action for event completion status mutation
henrikmv 2e7cd12
feat: refactor event status handling and update related actions
henrikmv 0f7443e
feat: add event completion status mutation handling in EventRow compo…
henrikmv 73f1e22
feat: replace useEventEditPermissions with useCanChangeCompletionStat…
henrikmv 42e667d
feat: dispatch changeEventFromUrl action on completion status update
henrikmv 206e43c
feat: rename onUpdated to onSuccess
henrikmv 4c34ad1
fix: roll back and devin review
henrikmv ad09c52
Merge branch 'master' into hv/feat/DHIS2-21655_uncomplete-event-view-…
henrikmv dfe3c2e
fix: replace EventStatuses with eventStatuses constant in EventRow an…
henrikmv 1c7b39b
feat: add index file and manu item folder
henrikmv c1d4aad
Merge remote-tracking branch 'origin/master' into hv/feat/DHIS2-21655…
henrikmv 1be294d
Merge remote-tracking branch 'origin/master' into hv/feat/DHIS2-21655…
henrikmv 06daabf
fix: clean up
henrikmv a702df4
feat: refactor event status handling to use centralised statusTypes
henrikmv 88bae47
feat: centralise event status handling
henrikmv ae2f15b
feat: enhance event row loading state with circular loader
henrikmv 687ed3b
Merge remote-tracking branch 'origin/master' into hv/feat/DHIS2-21655…
henrikmv a9d409e
feat: refactor event edit permissions
henrikmv da15a0c
feat: refactor event edit permissions and authority management
henrikmv 7d27954
feat: consolidate authority imports across components and hooks
henrikmv 25ff87e
feat: refactor event edit permissions to use isEventReadOnly flag
henrikmv 573c6ff
feat: enhance event edit permissions and streamline delete action han…
henrikmv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/core_modules/capture-core/components/EventOverflowMenu/MenuItems/CompletionMenuItem.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import React from 'react'; | ||
| import i18n from '@dhis2/d2-i18n'; | ||
| import log from 'loglevel'; | ||
| import { MenuItem, IconCheckmark16, IconUndo16 } from '@dhis2/ui'; | ||
| import { useMutation } from '@tanstack/react-query'; | ||
| import { useAlert, useDataEngine } from '@dhis2/app-runtime'; | ||
| import { errorCreator } from 'capture-core-utils'; | ||
| import { statusTypes as eventStatuses } from 'capture-core/events/statusTypes'; | ||
|
|
||
| type Props = { | ||
| eventId: string; | ||
| eventStatus?: string; | ||
| onMutate?: (newStatus: string) => void; | ||
| onSuccess?: (newStatus: string) => void; | ||
| onError?: () => void; | ||
| onClose: () => void; | ||
| }; | ||
|
|
||
| export const CompletionMenuItem = ({ | ||
| eventId, | ||
| eventStatus, | ||
| onMutate, | ||
| onSuccess, | ||
| onError, | ||
| onClose, | ||
| }: Props) => { | ||
| const dataEngine = useDataEngine(); | ||
| const { show: showError } = useAlert( | ||
| ({ message }) => message, | ||
| { critical: true }, | ||
| ); | ||
|
|
||
| const isCompleted = eventStatus === eventStatuses.COMPLETED; | ||
| const newStatus = isCompleted ? eventStatuses.ACTIVE : eventStatuses.COMPLETED; | ||
|
|
||
| const { mutate: updateCompletionStatus } = useMutation( | ||
| async () => { | ||
| const { event: apiEvent } = await dataEngine.query({ | ||
| event: { | ||
| resource: 'tracker/events', | ||
| id: eventId, | ||
| params: { | ||
| fields: '*,!completedAt,!completedBy,!dataValues,!relationships', | ||
| }, | ||
| }, | ||
| }) as any; | ||
| return dataEngine.mutate({ | ||
| resource: 'tracker?async=false&importStrategy=UPDATE', | ||
| type: 'create', | ||
| data: { | ||
| events: [{ | ||
| ...apiEvent, | ||
| status: newStatus, | ||
| }], | ||
| }, | ||
| }); | ||
| }, | ||
| { | ||
| onMutate: () => { | ||
| onMutate?.(newStatus); | ||
| }, | ||
| onError: (error: unknown) => { | ||
| showError({ message: i18n.t('An error occurred when updating event status') }); | ||
| log.error(errorCreator('An error occurred when updating event status')({ error, eventId, newStatus })); | ||
| onError?.(); | ||
| }, | ||
| onSuccess: () => { | ||
| onSuccess?.(newStatus); | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| return ( | ||
| <MenuItem | ||
| dense | ||
| dataTest={isCompleted ? 'uncomplete-event-menu-item' : 'complete-event-menu-item'} | ||
| icon={isCompleted ? <IconUndo16 /> : <IconCheckmark16 />} | ||
| label={isCompleted ? i18n.t('Mark incomplete') : i18n.t('Mark complete')} | ||
| suffix="" | ||
| onClick={() => { | ||
| onClose(); | ||
| updateCompletionStatus(); | ||
| }} | ||
| /> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/core_modules/capture-core/components/EventOverflowMenu/MenuItems/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export { DeleteActionButton } from './DeleteMenuItem'; | ||
| export { DeleteActionModal } from './DeleteEventModal'; | ||
| export { CompletionMenuItem } from './CompletionMenuItem'; |
1 change: 1 addition & 0 deletions
1
src/core_modules/capture-core/components/EventOverflowMenu/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { DeleteActionButton, DeleteActionModal, CompletionMenuItem } from './MenuItems'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
..._modules/capture-core/components/WidgetEnrollment/Actions/Complete/Complete.component.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...re/components/WidgetEnrollment/Actions/Complete/CompleteModal/CompleteModal.container.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.