diff --git a/i18n/en.pot b/i18n/en.pot index 465ea8aed0..f114c47fb4 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -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: 2024-08-26T17:35:42.543Z\n" -"PO-Revision-Date: 2024-08-26T17:35:42.543Z\n" +"POT-Creation-Date: 2024-08-28T06:51:14.983Z\n" +"PO-Revision-Date: 2024-08-28T06:51:14.983Z\n" msgid "Choose one or more dates..." msgstr "Choose one or more dates..." @@ -1685,24 +1685,30 @@ msgstr "No active enrollments to complete" msgid "An error occurred while completing the enrollments" msgstr "An error occurred while completing the enrollments" -msgid "You do not have the required authority to delete enrollments" -msgstr "You do not have the required authority to delete enrollments" - msgid "Delete enrollments" msgstr "Delete enrollments" msgid "Are you sure you want to delete all enrollments in the selected program?" msgstr "Are you sure you want to delete all enrollments in the selected program?" -msgid "Total enrollments to be deleted" -msgstr "Total enrollments to be deleted" +msgid "Total" +msgstr "Total" + +msgid "No active enrollments to delete" +msgstr "No active enrollments to delete" + +msgid "Delete active enrollments" +msgstr "Delete active enrollments" + +msgid "No enrollments to delete" +msgstr "No enrollments to delete" + +msgid "Delete all enrollments" +msgstr "Delete all enrollments" msgid "An error occurred when deleting enrollments" msgstr "An error occurred when deleting enrollments" -msgid "You do not have the required authority to delete tracked entities" -msgstr "You do not have the required authority to delete tracked entities" - msgid "Delete {{ trackedEntityName }} with all enrollments" msgstr "Delete {{ trackedEntityName }} with all enrollments" diff --git a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteEnrollmentsAction/DeleteEnrollmentsAction.js b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteEnrollmentsAction/DeleteEnrollmentsAction.js index 3e941c80be..a7e7bd4057 100644 --- a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteEnrollmentsAction/DeleteEnrollmentsAction.js +++ b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteEnrollmentsAction/DeleteEnrollmentsAction.js @@ -5,7 +5,6 @@ import { Button, } from '@dhis2/ui'; import { useAuthority } from '../../../../../../utils/userInfo/useAuthority'; -import { ConditionalTooltip } from '../../../../../Tooltips/ConditionalTooltip'; import { EnrollmentDeleteModal } from './EnrollmentDeleteModal'; type Props = { @@ -24,20 +23,18 @@ export const DeleteEnrollmentsAction = ({ const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false); const { hasAuthority } = useAuthority({ authority: CASCADE_DELETE_TEI_AUTHORITY }); + if (!hasAuthority) { + return null; + } + return ( <> - setIsDeleteDialogOpen(true)} > - - + {i18n.t('Delete enrollments')} + {isDeleteDialogOpen && ( setIsDeleteDialogOpen(false)} > @@ -52,9 +52,9 @@ export const EnrollmentDeleteModal = ({ {i18n.t('Are you sure you want to delete all enrollments in the selected program?')} @@ -84,13 +84,34 @@ export const EnrollmentDeleteModal = ({ > {i18n.t('Cancel')} - + + + + + + diff --git a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteEnrollmentsAction/hooks/useDeleteEnrollments.js b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteEnrollmentsAction/hooks/useDeleteEnrollments.js index f3500572b4..f011728af9 100644 --- a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteEnrollmentsAction/hooks/useDeleteEnrollments.js +++ b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteEnrollmentsAction/hooks/useDeleteEnrollments.js @@ -52,12 +52,14 @@ export const useDeleteEnrollments = ({ ); const { mutate: deleteEnrollments, isLoading: isDeletingEnrollments } = useMutation( - () => dataEngine.mutate({ + ({ activeOnly }: any) => dataEngine.mutate({ resource: 'tracker?async=false&importStrategy=DELETE', type: 'create', data: { - // $FlowFixMe - business logic dictates that enrollments is not undefined at this point - enrollments: enrollments.map(({ enrollment }) => ({ enrollment })), + enrollments: enrollments + // $FlowFixMe - business logic dictates that enrollments is not undefined at this point + .filter(({ status }) => !activeOnly || status === 'ACTIVE') + .map(({ enrollment }) => ({ enrollment })), }, }), { diff --git a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteTeiAction/DeleteTeiAction.js b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteTeiAction/DeleteTeiAction.js index 645ca7b9eb..97d273c04f 100644 --- a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteTeiAction/DeleteTeiAction.js +++ b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/TrackedEntityBulkActions/Actions/DeleteTeiAction/DeleteTeiAction.js @@ -3,7 +3,6 @@ import React, { useState } from 'react'; import i18n from '@dhis2/d2-i18n'; import { Button, ButtonStrip, Modal, ModalActions, ModalContent, ModalTitle } from '@dhis2/ui'; import { useAuthority } from '../../../../../../utils/userInfo/useAuthority'; -import { ConditionalTooltip } from '../../../../../Tooltips/ConditionalTooltip'; import { useCascadeDeleteTei } from './hooks/useCascadeDeleteTei'; type Props = { @@ -27,22 +26,20 @@ export const DeleteTeiAction = ({ onUpdateList, }); + if (!hasAuthority) { + return null; + } + return ( <> - setIsDeleteDialogOpen(true)} > - - + {i18n.t('Delete {{ trackedEntityName }} with all enrollments', { + trackedEntityName: 'Person'.toLowerCase(), + })} + {isDeleteDialogOpen && ( - + {/* */} ); }; diff --git a/src/core_modules/capture-core/components/WorkingLists/WorkingListsBase/BulkActionBar/BulkActionCountTable/BulkActionCountTable.js b/src/core_modules/capture-core/components/WorkingLists/WorkingListsBase/BulkActionBar/BulkActionCountTable/BulkActionCountTable.js index b5a1e9dbb2..847e63dac9 100644 --- a/src/core_modules/capture-core/components/WorkingLists/WorkingListsBase/BulkActionBar/BulkActionCountTable/BulkActionCountTable.js +++ b/src/core_modules/capture-core/components/WorkingLists/WorkingListsBase/BulkActionBar/BulkActionCountTable/BulkActionCountTable.js @@ -14,7 +14,7 @@ import i18n from '@dhis2/d2-i18n'; import { withStyles } from '@material-ui/core/'; type Props = { - total: ?number, + total?: ?number, isLoading: boolean, totalLabel?: string, children: React$Node,