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

fix: [DHIS2-18238] incorrect criteria when saving list with follow up false #3868

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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) }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the same solution should be applied when updating a trackedEntity WL and when creating and updating a programStage WL. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very glad you know this logic better than me! Good catch 😄

...(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
Loading