Skip to content

Commit

Permalink
fix: deleted instance details page and change request not working
Browse files Browse the repository at this point in the history
  • Loading branch information
beygorghor authored Dec 9, 2024
2 parents 24ec655 + 4aa72cb commit 62064c1
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
3 changes: 2 additions & 1 deletion hat/assets/js/apps/Iaso/domains/app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@
"iaso.instance.warningSoftDeleted": "This instance has been soft-deleted and won't appear in instance search or completeness counts.",
"iaso.instance.warningSoftDeletedDerived": "If this form generates other derived instances, they might not be updated either.",
"iaso.instance.warningSoftDeletedExport": "If this instance was exported, this doesn't mean these data has been deleted from dhis2.",
"iaso.instances.disabledReason": "Change request is not available as submission is deleted",
"iaso.instances.editLocationWithInstanceGps": "Push GPS from submission",
"iaso.instances.forceExport": "Force Export",
"iaso.instances.label.created_by__username": "Created by",
Expand Down Expand Up @@ -440,7 +441,7 @@
"iaso.label.cancel": "Cancel",
"iaso.label.catchment": "Catchment",
"iaso.label.changeRequestConfig": "Change Request Configuration",
"iaso.label.changeRequests": "Change requets",
"iaso.label.changeRequests": "Change requests",
"iaso.label.changeStatus": "Change status",
"iaso.label.checkDHIS": "Test settings",
"iaso.label.children": "Children",
Expand Down
1 change: 1 addition & 0 deletions hat/assets/js/apps/Iaso/domains/app/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@
"iaso.instance.warningSoftDeleted": "Cette soumission a été marquée comme effacée, elle n'apparaitra plus dans les recherches ou les tableaux de complétude.",
"iaso.instance.warningSoftDeletedDerived": "Si ce formulaire sert à générer des soumissions dérivées, celle-ci prendra toujours en compte cette soumission, c'est à vous de décider si vous les regénérez.",
"iaso.instance.warningSoftDeletedExport": "Si l'soumission a été exportée précédemment, les données dans dhis2 sont sans doute toujours présentes.",
"iaso.instances.disabledReason": "La demande de changement n'est pas disponible car la soumission a été supprimée",
"iaso.instances.editLocationWithInstanceGps": "Pousser le GPS à partir de la soumission",
"iaso.instances.forceExport": "Forcer l'export des soumissions déjà exportées",
"iaso.instances.label.created_by__username": "Crée par",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import React, { FunctionComponent } from 'react';
import InfoIcon from '@mui/icons-material/Info';
import {
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Tooltip,
useTheme,
} from '@mui/material';
import { IconButton, useSafeIntl } from 'bluesquare-components';
import { Instance } from '../types/instance';
import MESSAGES from '../messages';
import React, { FunctionComponent } from 'react';
import { baseUrls } from '../../../constants/urls';
import { colorCodes } from '../../orgUnits/reviewChanges/Components/ReviewOrgUnitChangesInfos';
import MESSAGES from '../messages';
import { Instance } from '../types/instance';

type Props = {
currentInstance: Instance;
disabled?: boolean;
};
const InstanceDetailsChangeRequests: FunctionComponent<Props> = ({
currentInstance,
disabled = false,
}) => {
const { formatMessage } = useSafeIntl();
const theme = useTheme();
Expand All @@ -42,19 +46,38 @@ const InstanceDetailsChangeRequests: FunctionComponent<Props> = ({
<TableRow key={changeRequest.id}>
<TableCell
sx={{
color: theme.palette[statusColor].main,
color: disabled
? theme.palette.text.disabled
: theme.palette[statusColor].main,
}}
>
{formatMessage(
MESSAGES[changeRequest.status],
)}
</TableCell>
<TableCell>
<IconButton
url={`/${baseUrls.orgUnitsChangeRequestDetail}/changeRequestId/${changeRequest.id}`}
icon="remove-red-eye"
tooltipMessage={MESSAGES.status}
/>
{!disabled && (
<IconButton
url={`/${baseUrls.orgUnitsChangeRequestDetail}/changeRequestId/${changeRequest.id}`}
icon="remove-red-eye"
tooltipMessage={MESSAGES.status}
/>
)}
{disabled && (
<Tooltip
title={formatMessage(
MESSAGES.disabledReason,
)}
arrow
>
<InfoIcon
color="primary"
sx={{
cursor: 'pointer',
}}
/>
</Tooltip>
)}
</TableCell>
</TableRow>
);
Expand Down
5 changes: 3 additions & 2 deletions hat/assets/js/apps/Iaso/domains/instances/details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ import { ClassNames } from '../../types/utils';
import { BeneficiaryBaseInfo } from '../entities/components/BeneficiaryBaseInfo';
import { useGetBeneficiaryFields } from '../entities/hooks/useGetBeneficiaryFields';
import { useGetInstance } from './compare/hooks/useGetInstance';
import InstanceDetailsChangeRequests from './components/InstanceDetailsChangeRequests';
import InstanceDetailsExportRequests from './components/InstanceDetailsExportRequests';
import InstanceDetailsInfos from './components/InstanceDetailsInfos';
import InstanceDetailsLocation from './components/InstanceDetailsLocation';
import InstanceDetailsLocksHistory from './components/InstanceDetailsLocksHistory';
import InstanceFileContent from './components/InstanceFileContent';
import InstancesFilesList from './components/InstancesFilesListComponent';
import SpeedDialInstance from './components/SpeedDialInstance';
import { INSTANCE_METAS_FIELDS } from './constants';
import {
ReassignInstancePayload,
useReassignInstance,
} from './hooks/useReassignInstance';
import MESSAGES from './messages';
import { getInstancesFilesList } from './utils';
import { INSTANCE_METAS_FIELDS } from './constants';
import InstanceDetailsChangeRequests from './components/InstanceDetailsChangeRequests';

const useStyles = makeStyles(theme => ({
...commonStyles(theme),
Expand Down Expand Up @@ -232,6 +232,7 @@ const InstanceDetails: FunctionComponent = () => {
>
<InstanceDetailsChangeRequests
currentInstance={currentInstance}
disabled={currentInstance.deleted}
/>
</WidgetPaper>
)}
Expand Down
5 changes: 5 additions & 0 deletions hat/assets/js/apps/Iaso/domains/instances/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,11 @@ const MESSAGES = defineMessages({
defaultMessage: 'Approved',
id: 'iaso.label.approved',
},
disabledReason: {
defaultMessage:
'Change request is not available as submission is deleted',
id: 'iaso.instances.disabledReason',
},
});

export default MESSAGES;

0 comments on commit 62064c1

Please sign in to comment.