Skip to content

Commit

Permalink
fix: [DHIS2-18238] incorrect criteria when saving list with follow up…
Browse files Browse the repository at this point in the history
… false (#3868)

* fix: add undefined validation

* chore: missing checks
  • Loading branch information
eirikhaugstulen authored Nov 1, 2024
1 parent 31cb56c commit 53c21f0
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { errorCreator } from 'capture-core-utils';
import { ofType } from 'redux-observable';
import { concatMap, filter, takeUntil } from 'rxjs/operators';
import {
workingListsCommonActionTypes,
addTemplateSuccess,
addTemplateError,
deleteTemplateSuccess,
addTemplateSuccess,
deleteTemplateError,
updateTemplateSuccess,
updateTemplateError,
deleteTemplateSuccess,
updateDefaultTemplate,
updateTemplateError,
updateTemplateSuccess,
workingListsCommonActionTypes,
workingListsCommonActionTypesBatchActionTypes,
} from '../../../WorkingListsCommon';
import { TEI_WORKING_LISTS_TYPE } from '../../constants';
Expand Down Expand Up @@ -63,7 +63,7 @@ export const addProgramStageTemplateEpic = (action$: InputObservable, store: Red
eventStatus: status,
...(assignedUserMode && { assignedUserMode }),
...(assignedUsers?.length > 0 && { assignedUsers }),
...(followUp && { followUp }),
...(followUp !== undefined && { followUp: JSON.stringify(followUp) }),
...(programStatus && { enrollmentStatus: programStatus }),
...(occurredAt && { enrollmentOccurredAt: occurredAt }),
...(eventOccurredAt && { eventOccurredAt }),
Expand Down Expand Up @@ -212,7 +212,7 @@ export const updateProgramStageTemplateEpic = (action$: InputObservable, store:
...(assignedUsers?.length > 0 && { assignedUsers }),
...(programStatus && { enrollmentStatus: programStatus }),
...(occurredAt && { enrollmentOccurredAt: occurredAt }),
...(followUp && { followUp }),
...(followUp !== undefined && { followUp: JSON.stringify(followUp) }),
...(eventOccurredAt && { eventOccurredAt }),
...(scheduledAt && { eventScheduledAt: scheduledAt }),
attributeValueFilters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { errorCreator } from 'capture-core-utils';
import { ofType } from 'redux-observable';
import { concatMap, filter, takeUntil } from 'rxjs/operators';
import {
workingListsCommonActionTypes,
addTemplateSuccess,
addTemplateError,
deleteTemplateSuccess,
addTemplateSuccess,
deleteTemplateError,
updateTemplateSuccess,
updateTemplateError,
deleteTemplateSuccess,
updateDefaultTemplate,
updateTemplateError,
updateTemplateSuccess,
workingListsCommonActionTypes,
workingListsCommonActionTypesBatchActionTypes,
} from '../../../WorkingListsCommon';
import { TEI_WORKING_LISTS_TYPE } from '../../constants';
Expand Down Expand Up @@ -55,7 +55,7 @@ export const addTEITemplateEpic = (action$: InputObservable, store: ReduxStore,
...(assignedUserMode && { assignedUserMode }),
...(assignedUsers?.length > 0 && { assignedUsers }),
...(programStatus && { enrollmentStatus: programStatus }),
...(!!followUp && { followUp }),
...(followUp !== undefined && { followUp: JSON.stringify(followUp) }),
...(enrolledAt && { enrollmentCreatedDate: enrolledAt }),
...(occurredAt && { enrollmentIncidentDate: occurredAt }),
...(attributeValueFilters?.length > 0 && { attributeValueFilters }),
Expand Down Expand Up @@ -173,10 +173,10 @@ export const updateTEITemplateEpic = (action$: InputObservable, store: ReduxStor
order,
...(assignedUserMode && { assignedUserMode }),
...(assignedUsers?.length > 0 && { assignedUsers }),
...(followUp !== undefined && { followUp: JSON.stringify(followUp) }),
...(programStatus && { enrollmentStatus: programStatus }),
...(enrolledAt && { enrollmentCreatedDate: enrolledAt }),
...(occurredAt && { enrollmentIncidentDate: occurredAt }),
...(followUp && { followUp }),
...(attributeValueFilters?.length > 0 && { attributeValueFilters }),
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// @flow
import moment from 'moment';
import {
filterTypesObject,
dateFilterTypes,
type BooleanFilterData,
type TextFilterData,
type NumericFilterData,
type DateFilterData,
dateFilterTypes,
filterTypesObject,
type NumericFilterData,
type TextFilterData,
} from '../../../../WorkingListsBase';
import type { ApiDataFilterBoolean, ApiDataFilterDateContents } from '../../../types';
import { ADDITIONAL_FILTERS } from '../../../helpers';
Expand Down Expand Up @@ -108,7 +108,7 @@ export const convertMainFilters = ({
}

const mainValue = mainFiltersTable[key](filter);
if (mainValue) {
if (mainValue !== undefined) {
if (key === MAIN_FILTERS.ASSIGNEE) {
return { ...acc, ...mainValue };
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
// @flow
import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import i18n from '@dhis2/d2-i18n';
import { Button, Modal, ModalTitle, ModalContent, ModalActions } from '@dhis2/ui';

const getStyles = () => ({
buttonContainer: {
display: 'flex',
justifyContent: 'space-between',
},
});
import { Button, ButtonStrip, Modal, ModalActions, ModalContent, ModalTitle } from '@dhis2/ui';

type Props = {
open: boolean,
onClose: () => void,
onDeleteTemplate: () => void,
templateName: string,
classes: Object,
};

const DeleteConfirmationDialogPlain = (props: Props) => {
export const DeleteConfirmationDialog = (props: Props) => {
const {
open,
onClose,
onDeleteTemplate,
templateName,
classes,
} = props;

if (!open) {
Expand All @@ -41,18 +31,17 @@ const DeleteConfirmationDialogPlain = (props: Props) => {
<ModalContent>
{i18n.t('Do you really want to delete the \'{{templateName}}\' view?', { templateName })}
</ModalContent>
<ModalActions
className={classes.buttonContainer}
>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={onDeleteTemplate} primary>
{i18n.t('Confirm')}
</Button>
<ModalActions>
<ButtonStrip>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={onDeleteTemplate} primary>
{i18n.t('Confirm')}
</Button>
</ButtonStrip>
</ModalActions>
</Modal>
);
};

export const DeleteConfirmationDialog = withStyles(getStyles)(DeleteConfirmationDialogPlain);
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
// @flow
import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import i18n from '@dhis2/d2-i18n';
import { Button, ModalTitle, ModalContent, ModalActions } from '@dhis2/ui';

const getStyles = () => ({
buttonContainer: {
display: 'flex',
justifyContent: 'space-between',
},
});
import { Button, ButtonStrip, ModalActions, ModalContent, ModalTitle } from '@dhis2/ui';

type Props = {
onSaveTemplate: () => void,
onClose: () => void,
classes: Object,
};

const ExistingTemplateContentsPlain = (props: Props) => {
const { onSaveTemplate, onClose, classes } = props;
export const ExistingTemplateContents = (props: Props) => {
const { onSaveTemplate, onClose } = props;
return (
<React.Fragment>
<ModalTitle>{i18n.t('Save')}</ModalTitle>
<ModalContent />
<ModalActions
className={classes.buttonContainer}
>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={onSaveTemplate} primary>
{i18n.t('Save')}
</Button>
<ModalActions>
<ButtonStrip>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={onSaveTemplate} primary>
{i18n.t('Save')}
</Button>
</ButtonStrip>
</ModalActions>
</React.Fragment>
);
};

export const ExistingTemplateContents = withStyles(getStyles)(ExistingTemplateContentsPlain);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from 'react';
import { colors, Button, ModalTitle, ModalContent, ModalActions } from '@dhis2/ui';
import { Button, ButtonStrip, colors, ModalActions, ModalContent, ModalTitle } from '@dhis2/ui';
import { withStyles } from '@material-ui/core/styles';
import i18n from '@dhis2/d2-i18n';
import { NewTemplateTextField } from './NewTemplateTextField.component';
Expand Down Expand Up @@ -64,15 +64,15 @@ const NewTemplateContentsPlain = (props: Props) => {
{error}
</div>
</ModalContent>
<ModalActions
className={classes.buttonContainer}
>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={handleSave} primary>
{i18n.t('Save')}
</Button>
<ModalActions>
<ButtonStrip>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={handleSave} primary>
{i18n.t('Save')}
</Button>
</ButtonStrip>
</ModalActions>
</React.Fragment>
);
Expand Down

0 comments on commit 53c21f0

Please sign in to comment.