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-15827] remove effects of 'Prevent adding new events to stage' action from the form #3418

Merged
merged 3 commits into from
Oct 12, 2023
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 @@ -3,5 +3,4 @@ Feature: Hidden program stage
Scenario: The user cannot add an event in a hidden program stage
Given you add an enrollment event that will result in a rule effect to hide a program stage
Then the New Postpartum care visit event button is disabled in the stages and events widget
And and an error is show in the Postpartum care visit stage
And the Postpartum care visit button is disabled in the enrollmentEventNew page
12 changes: 0 additions & 12 deletions cypress/integration/EnrollmentPage/HiddenProgramStage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@ Then('the New Postpartum care visit event button is disabled in the stages and e
.should('be.disabled');
});

Then('and an error is show in the Postpartum care visit stage', () => {
cy.visit(
'/#/enrollmentEventNew?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&teiId=uW8Y7AIcRKA&stageId=bbKtnxRZKEP',
);
cy.contains('[data-test="dhis2-uicore-button"]', 'Complete')
.should('be.disabled');
cy.contains('[data-test="dhis2-uicore-button"]', 'Save without completing')
.should('be.disabled');
cy.contains('[data-test="dhis2-uicore-noticebox-content"]', 'You can\'t add any more Postpartum care visit events')
.should('exist');
});

Then('the Postpartum care visit button is disabled in the enrollmentEventNew page', () => {
cy.visit(
'/#/enrollmentEventNew?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&teiId=uW8Y7AIcRKA',
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { type ComponentType } from 'react';
import i18n from '@dhis2/d2-i18n';
import { withStyles } from '@material-ui/core';
import { Button, spacersNum } from '@dhis2/ui';
import { ConditionalTooltip } from 'capture-core/components/ConditionalTooltip';
import { withCancelButton } from '../../DataEntry/withCancelButton';
import { addEventSaveTypes } from '../DataEntry/addEventSaveTypes';
import type { InputProps, Props } from './finishButtons.types';
Expand All @@ -18,40 +17,17 @@ const styles = {
},
};

const FinishButtonsPlain = ({ onSave, cancelButton, hiddenProgramStage, stageName, classes }: Props) => (
const FinishButtonsPlain = ({ onSave, cancelButton, classes }: Props) => (
<div className={classes.container}>
<div className={classes.button}>
<ConditionalTooltip
content={i18n.t("You can't add any more {{ programStageName }} events", {
programStageName: stageName,
interpolation: { escapeValue: false },
})}
enabled={hiddenProgramStage}
>
<Button
disabled={hiddenProgramStage}
onClick={() => onSave(addEventSaveTypes.COMPLETE)}
primary
>
{i18n.t('Complete')}
</Button>
</ConditionalTooltip>
<Button onClick={() => onSave(addEventSaveTypes.COMPLETE)} primary>
{i18n.t('Complete')}
</Button>
</div>
<div className={classes.button}>
<ConditionalTooltip
content={i18n.t("You can't add any more {{ programStageName }} events", {
programStageName: stageName,
interpolation: { escapeValue: false },
})}
enabled={hiddenProgramStage}
>
<Button
disabled={hiddenProgramStage}
onClick={() => onSave(addEventSaveTypes.SAVE_WITHOUT_COMPLETING)}
>
{i18n.t('Save without completing')}
</Button>
</ConditionalTooltip>
<Button onClick={() => onSave(addEventSaveTypes.SAVE_WITHOUT_COMPLETING)}>
{i18n.t('Save without completing')}
</Button>
</div>
{cancelButton}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ export type InputProps = {|
onSave: (saveType: $Keys<addEventSaveTypes>) => void,
onCancel: () => void,
id: string,
hiddenProgramStage: boolean,
stageName: string,
|};

export type Props = {|
onSave: (saveType: $Keys<addEventSaveTypes>) => void,
cancelButton: Element<any>,
hiddenProgramStage: boolean,
stageName: string,
...CssClasses,
|};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Widget } from '../../Widget';
import { DataEntry } from '../DataEntry';
import { FinishButtons } from '../FinishButtons';
import { SavingText } from '../SavingText';
import { ErrorText } from '../ErrorText';
import type { Props } from './validated.types';

const styles = () => ({
Expand All @@ -24,7 +23,6 @@ const ValidatedPlain = ({
onSave,
onCancel,
orgUnit,
hiddenProgramStage,
id,
...passOnProps
}: Props) => (
Expand All @@ -48,14 +46,8 @@ const ValidatedPlain = ({
onSave={onSave}
onCancel={onCancel}
id={id}
hiddenProgramStage={hiddenProgramStage}
stageName={stage.name}
/>
{hiddenProgramStage ? (
<ErrorText stageName={stage.name} />
) : (
<SavingText programName={programName} stageName={stage.name} orgUnitName={orgUnit.name} />
)}
<SavingText programName={programName} stageName={stage.name} orgUnitName={orgUnit.name} />
</div>
)}
</Widget>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import React, { useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useDispatch } from 'react-redux';
import { withAskToCreateNew, withSaveHandler } from '../../DataEntry';
import { useLifecycle } from './useLifecycle';
import { useClientFormattedRulesExecutionDependencies } from './useClientFormattedRulesExecutionDependencies';
Expand Down Expand Up @@ -29,11 +29,6 @@ export const Validated = ({
}: ContainerProps) => {
const dataEntryId = 'enrollmentEvent';
const itemId = 'newEvent';
const rulesEffectsHiddenProgram = useSelector(
({ rulesEffectsHiddenProgramStageDesc }) =>
rulesEffectsHiddenProgramStageDesc && rulesEffectsHiddenProgramStageDesc[`${dataEntryId}-${itemId}`],
);
const hiddenProgramStage = rulesEffectsHiddenProgram && rulesEffectsHiddenProgram[stage.id];

const rulesExecutionDependenciesClientFormatted =
useClientFormattedRulesExecutionDependencies(rulesExecutionDependencies, program);
Expand Down Expand Up @@ -132,7 +127,6 @@ export const Validated = ({
programName={program.name}
orgUnit={orgUnit}
rulesExecutionDependenciesClientFormatted={rulesExecutionDependenciesClientFormatted}
hiddenProgramStage={hiddenProgramStage}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ export type Props = {|
formRef: (formInstance: any) => void,
dataEntryFieldRef: (instance: any, id: string) => void,
rulesExecutionDependenciesClientFormatted: RulesExecutionDependenciesClientFormatted,
hiddenProgramStage: boolean,
...CssClasses,
|};
Loading