Skip to content
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

feat: [DHIS2-13237] Enrollment coordinates in enrollment widget #3141

Merged
merged 61 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
7f8ab42
feat: [DHIS2-13237] add coordinate with map
jasminenguyennn Dec 6, 2022
c9e22f4
chore: minor fix
jasminenguyennn Dec 6, 2022
29b5ee9
feat: [DHIS2-13237] handle polygon in the map
jasminenguyennn Dec 7, 2022
02b7e6d
chore: fix flow
jasminenguyennn Dec 7, 2022
6e392c7
chore: [DHIS2-13237] convert coordinates
jasminenguyennn Dec 12, 2022
10c0237
feat: [DHIS2-13237] open on click and add new location
jasminenguyennn Dec 13, 2022
d610ef6
feat: [DHIS2-13237] handle add geometry
jasminenguyennn Dec 14, 2022
562e73c
feat: [DHIS2-13237] update locations
jasminenguyennn Dec 14, 2022
6e1ea40
chore: [DHIS2-13237] minor fix
jasminenguyennn Dec 14, 2022
c3d2cc0
Merge branch 'master' into DHIS2-13237
jasminenguyennn Dec 14, 2022
2d7f6f8
chore: [DHIS2-13237] minor fix
jasminenguyennn Dec 14, 2022
261dd92
Merge branch 'master' into DHIS2-13237
jasminenguyennn Jan 5, 2023
bab56da
Merge branch 'master' into DHIS2-13237
jasminenguyennn Jan 10, 2023
89f91b0
fix: minor fix
jasminenguyennn Jan 10, 2023
58cf3cf
Merge branch 'master' into DHIS2-13237
jasminenguyennn Jan 19, 2023
7c58207
chore: [DHIS2-13237] update review feedbacks
jasminenguyennn Jan 19, 2023
d94835e
chore: [DHIS2-13237] move folder
jasminenguyennn Jan 19, 2023
1054a57
Merge branch 'master' into DHIS2-13237
jasminenguyennn Jan 20, 2023
d6586c9
chore: [DHIS2-13237] minor add default value
jasminenguyennn Jan 25, 2023
ddb709d
chore: [DHIS2-13237] update edit polygon
jasminenguyennn Jan 25, 2023
aee5480
fix: [DHIS2-13237] minor fix
jasminenguyennn Jan 26, 2023
1321d38
Merge branch 'master' into DHIS2-13237
jasminenguyennn Jan 26, 2023
a31ec08
chore: [DHIS2-13237] fit bounds
jasminenguyennn Jan 27, 2023
8b7c0fa
fix: [DHIS2-13237] fix flow
jasminenguyennn Jan 27, 2023
d9a9f2e
fix: minor fix
jasminenguyennn Jan 27, 2023
a24b951
Merge branch 'master' into DHIS2-13237
jasminenguyennn Mar 21, 2023
64e5577
feat: [DHIS2-13237] add search feature
jasminenguyennn Mar 21, 2023
67da33c
feat: [DHIS2-13237] add input fields
jasminenguyennn Mar 21, 2023
1f29f52
fix: [DHIS2-13237] fix flow
jasminenguyennn Mar 22, 2023
a3a9dac
feat: [DHIS2-13237] update view/edit state
jasminenguyennn Mar 24, 2023
7341568
fix: minor update
jasminenguyennn Mar 27, 2023
0306946
Merge branch 'master' into DHIS2-13237
jasminenguyennn Mar 31, 2023
a84c8f9
Pressing enter should trigger search unique identifier returns results
jasminenguyennn Apr 18, 2023
9ae9423
fix: [DHIS2-13237] fix onChange
jasminenguyennn Apr 18, 2023
70628a1
fix: fix flow
jasminenguyennn Apr 18, 2023
1461509
fix: [DHIS2-13237] reset
jasminenguyennn Apr 20, 2023
280f130
fix: minor fix
jasminenguyennn Apr 20, 2023
fb90cbc
Merge branch 'master' into DHIS2-13237
simonadomnisoru Jun 2, 2023
4328c72
fix: validate coordinates
simonadomnisoru Jun 8, 2023
eb276a9
fix: delete polygon error
simonadomnisoru Jun 8, 2023
12e14fc
Merge branch 'master' into DHIS2-13237
simonadomnisoru Jun 9, 2023
4f5a328
Merge branch 'master' into DHIS2-13237
simonadomnisoru Jun 9, 2023
169e2cc
fix: close enrollment actions dropdown
simonadomnisoru Jul 4, 2023
d8582d9
fix: resetToDefaultValues and adjust height
simonadomnisoru Jul 4, 2023
c44f4a3
Merge branch 'master' into DHIS2-13237
simonadomnisoru Jul 4, 2023
9940b39
Merge branch 'master' into DHIS2-13237
simonadomnisoru Jul 24, 2023
e9d829b
chore: fix typo
simonadomnisoru Aug 8, 2023
4d23376
refactor: split MapCoordinatesModalComponent
simonadomnisoru Aug 10, 2023
120fa4e
Merge branch 'master' into DHIS2-13237
simonadomnisoru Aug 10, 2023
575bca7
chore: handle numbers with comma
simonadomnisoru Aug 16, 2023
0ebc464
fix: the map buttons are still displayed after closing the modal
simonadomnisoru Aug 17, 2023
941a9dd
chore: restructure MapModal folder
simonadomnisoru Aug 17, 2023
af48be5
chore: clean reactFGref
simonadomnisoru Aug 17, 2023
ffa39ae
Merge branch 'master' into DHIS2-13237
simonadomnisoru Sep 7, 2023
e5e9f38
Merge branch 'master' into DHIS2-13237
simonadomnisoru Sep 18, 2023
5aa0fcf
Merge branch 'master' into DHIS2-13237
simonadomnisoru Oct 18, 2023
cb72b5c
chore: disable the option to edit the polygon
simonadomnisoru Oct 19, 2023
f74091b
chore: improve the logic for Close without saving and Set Area buttons
simonadomnisoru Oct 23, 2023
da911ba
feat: return to previous state when canceling
simonadomnisoru Oct 23, 2023
c50adbf
Merge branch 'master' into DHIS2-13237
simonadomnisoru Nov 13, 2023
cd99514
fix: update enrollment mutation callback
simonadomnisoru Nov 13, 2023
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
42 changes: 33 additions & 9 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,33 @@ msgstr "Mark for follow-up"
msgid "Existing dates for auto-generated events will not be updated."
msgstr "Existing dates for auto-generated events will not be updated."

msgid "Latitude"
msgstr "Latitude"

msgid "Longitude"
msgstr "Longitude"

msgid "Edit"
msgstr "Edit"

msgid "Set coordinates"
msgstr "Set coordinates"

msgid "Coordinates"
msgstr "Coordinates"

msgid "Delete polygon"
msgstr "Delete polygon"

msgid "Close without saving"
msgstr "Close without saving"

msgid "Finish drawing before saving"
msgstr "Finish drawing before saving"

msgid "Set area"
msgstr "Set area"

msgid "Enrollment date"
msgstr "Enrollment date"

Expand All @@ -1200,6 +1227,12 @@ msgstr "Last updated {{date}}"
msgid "Cancelled"
msgstr "Cancelled"

msgid "Add coordinates"
msgstr "Add coordinates"

msgid "Add area"
msgstr "Add area"

msgid "Comments about this enrollment"
msgstr "Comments about this enrollment"

Expand Down Expand Up @@ -1323,9 +1356,6 @@ msgstr "Profile widget could not be loaded. Please try again later"
msgid "{{TETName}} profile"
msgstr "{{TETName}} profile"

msgid "Edit"
msgstr "Edit"

msgid "tracked entity instance"
msgstr "tracked entity instance"

Expand Down Expand Up @@ -1572,12 +1602,6 @@ msgstr "To time"
msgid "Page {{currentPage}}"
msgstr "Page {{currentPage}}"

msgid "Delete polygon"
msgstr "Delete polygon"

msgid "Set area"
msgstr "Set area"

msgid "Area on map saved"
msgstr "Area on map saved"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type EnrollmentData = {|
scheduledAt: string,
trackedEntity: string,
trackedEntityType: string,
geometry?: ?{ type: string, coordinates: [number, number] | Array<[number, number]>}
|};

export type AttributeValue = {|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { Complete } from './Complete';
import { Delete } from './Delete';
import { Followup } from './Followup';
import { AddNew } from './AddNew';
import { AddLocation } from './AddLocation';
import type { PlainProps } from './actions.types';
import { LoadingMaskForButton } from '../../LoadingMasks';
import { MapModal } from '../MapModal';

const styles = {
actions: {
Expand All @@ -35,13 +37,14 @@ export const ActionsPlain = ({
onlyEnrollOnce,
classes,
}: PlainProps) => {
const [open, setOpen] = useState(false);
const [isOpenActions, setOpenActions] = useState(false);
const [isOpenMap, setOpenMap] = useState(false);
const handleOnUpdate = (arg) => {
setOpen(prev => !prev);
setOpenActions(false);
onUpdate(arg);
};
const handleOnDelete = (arg) => {
setOpen(prev => !prev);
setOpenActions(false);
onDelete(arg);
};

Expand All @@ -53,8 +56,8 @@ export const ActionsPlain = ({
small
disabled={loading}
className={classes.actions}
open={open}
onClick={() => setOpen(prev => !prev)}
open={isOpenActions}
onClick={() => setOpenActions(prev => !prev)}
component={
loading ? null : (
<FlyoutMenu dense maxWidth="250px">
Expand All @@ -72,6 +75,13 @@ export const ActionsPlain = ({
enrollment={enrollment}
onUpdate={handleOnUpdate}
/>
<AddLocation
enrollment={enrollment}
setOpenMap={() => {
setOpenMap(true);
setOpenActions(false);
}}
/>
<MenuDivider />
<Cancel
enrollment={enrollment}
Expand All @@ -81,6 +91,7 @@ export const ActionsPlain = ({
enrollment={enrollment}
onDelete={handleOnDelete}
/>

</FlyoutMenu>
)
}
Expand All @@ -94,6 +105,11 @@ export const ActionsPlain = ({
{i18n.t('We are processing your request.')}
</div>
)}
{isOpenMap && <MapModal
enrollment={enrollment}
onUpdate={handleOnUpdate}
setOpenMap={setOpenMap}
/>}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
// @flow
import { useDataMutation } from '@dhis2/app-runtime';
import React from 'react';
import { ActionsComponent } from './Actions.component';
import type { Props } from './actions.types';
import { processErrorReports } from '../processErrorReports';

const enrollmentUpdate = {
resource: 'tracker?async=false&importStrategy=UPDATE',
type: 'create',
data: enrollment => ({
enrollments: [enrollment],
}),
};
const enrollmentDelete = {
resource: 'tracker?async=false&importStrategy=DELETE',
type: 'create',
data: enrollment => ({
enrollments: [enrollment],
}),
};
import { useUpdateEnrollment, useDeleteEnrollment } from '../dataMutation/dataMutation';

export const Actions = ({
enrollment = {},
Expand All @@ -29,31 +13,8 @@ export const Actions = ({
onSuccess,
...passOnProps
}: Props) => {
const [updateMutation, { loading: updateLoading }] = useDataMutation(
enrollmentUpdate,
{
onComplete: () => {
refetchEnrollment();
refetchTEI();
onSuccess && onSuccess();
},
onError: (e) => {
onError && onError(processErrorReports(e));
},
},
);
const [deleteMutation, { loading: deleteLoading }] = useDataMutation(
enrollmentDelete,
{
onComplete: () => {
onDelete();
onSuccess && onSuccess();
},
onError: (e) => {
onError && onError(processErrorReports(e));
},
},
);
const { updateMutation, updateLoading } = useUpdateEnrollment(refetchEnrollment, refetchTEI, onError);
const { deleteMutation, deleteLoading } = useDeleteEnrollment(onDelete, onError);

return (
<ActionsComponent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @flow
import { IconLocation16, MenuItem } from '@dhis2/ui';
import React from 'react';
import { useGeometryLabel } from '../../hooks/useGeometry';
import type { Props } from './addLocation.types';

export const AddLocation = ({ enrollment, setOpenMap }: Props) => {
const label = useGeometryLabel(enrollment);

if (!label) {
return null;
}

return (
<MenuItem
dense
dataTest="widget-enrollment-actions-add-location"
icon={<IconLocation16 />}
label={label}
onClick={() => setOpenMap(true)}
/>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @flow

export type Props = {|
enrollment: Object,
setOpenMap: (toogle: boolean) => void,
|};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @flow
export { AddLocation } from './AddLocation.component';
Loading
Loading