Skip to content

Commit

Permalink
fix: remove effects of 'Prevent adding new events to stage' action fr…
Browse files Browse the repository at this point in the history
…om the form
  • Loading branch information
simonadomnisoru committed Sep 25, 2023
1 parent a153053 commit e5ac242
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 79 deletions.

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,
|};

0 comments on commit e5ac242

Please sign in to comment.