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-15685][DHIS2-18326] View an event without selecting org unit in Tracker Programs #3926

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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 @@ -22,7 +22,6 @@ class ScopeSelectorClass extends Component<Props, State> {
super(props);

this.state = {
openOrgUnitWarning: false,
openProgramWarning: null,
openCatComboWarning: false,
openStartAgainWarning: false,
Expand All @@ -32,14 +31,6 @@ class ScopeSelectorClass extends Component<Props, State> {

dontShowWarning = () => !this.props.isUserInteractionInProgress;

handleOpenOrgUnitWarning = () => {
if (this.dontShowWarning()) {
this.props.onResetOrgUnitId();
return;
}
this.setState({ openOrgUnitWarning: true });
}

handleOpenProgramWarning = (baseAction: ReduxAction<any, any>) => {
if (this.dontShowWarning()) {
this.props.onResetProgramId(baseAction);
Expand All @@ -66,18 +57,12 @@ class ScopeSelectorClass extends Component<Props, State> {

handleClose = () => {
this.setState({
openOrgUnitWarning: false,
openProgramWarning: null,
openCatComboWarning: false,
openStartAgainWarning: false,
});
}

handleAcceptOrgUnit = () => {
this.props.onResetOrgUnitId();
this.handleClose();
}

handleAcceptProgram = () => {
if (this.state.openProgramWarning) {
this.props.onResetProgramId(this.state.openProgramWarning);
Expand All @@ -96,7 +81,12 @@ class ScopeSelectorClass extends Component<Props, State> {
}

render() {
const { onSetOrgUnit, onSetProgramId, onSetCategoryOption, onResetAllCategoryOptions } = this.props;
const {
onSetOrgUnit,
onSetProgramId,
onSetCategoryOption,
onResetAllCategoryOptions,
} = this.props;

return (
<div
Expand All @@ -108,7 +98,7 @@ class ScopeSelectorClass extends Component<Props, State> {
onSetProgramId={onSetProgramId}
onSetCategoryOption={onSetCategoryOption}
onResetAllCategoryOptions={onResetAllCategoryOptions}
onResetOrgUnitId={this.handleOpenOrgUnitWarning}
onResetOrgUnitId={this.props.onResetOrgUnitId}
onResetProgramId={this.handleOpenProgramWarning}
onResetCategoryOption={this.handleOpenCatComboWarning}
onStartAgain={this.handleStartAgainWarning}
Expand All @@ -122,12 +112,6 @@ class ScopeSelectorClass extends Component<Props, State> {
>
{this.props.children}
</QuickSelector>
<DiscardDialog
onDestroy={this.handleAcceptOrgUnit}
open={this.state.openOrgUnitWarning}
onCancel={this.handleClose}
{...defaultDialogProps}
/>
Comment on lines -125 to -130
Copy link
Contributor

@simonadomnisoru simonadomnisoru Jan 13, 2025

Choose a reason for hiding this comment

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

I don't think that removing the warning displayed when deselecting an orgUnit in the ScopeSelector is possible for all the pages across the app. One example that comes to mind is the /new page when enrolling a trackedEntity. How will this case be handled? Thanks!

<DiscardDialog
onDestroy={this.handleAcceptProgram}
open={!!this.state.openProgramWarning}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { OwnProps } from './ScopeSelector.types';
import { useOrgUnitNameWithAncestors } from '../../metadataRetrieval/orgUnitName';
import { resetOrgUnitIdFromScopeSelector } from './ScopeSelector.actions';


const deriveReadiness = (lockedSelectorLoads, selectedOrgUnitId, selectedOrgUnitName, displayName, ouNameError) => {
// because we want the orgUnit to be fetched and stored
// before allowing the user to view the locked selector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export type Props = {|
|}

export type State = {|
openOrgUnitWarning: boolean;
openProgramWarning: ?Object;
openCatComboWarning: boolean;
openStartAgainWarning: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const styles = {
tooltip: { display: 'inline-flex' },
};

export const WidgetEventEditPlain = ({
const WidgetEventEditPlain = ({
eventStatus,
initialScheduleDate,
stage,
Expand All @@ -93,11 +93,13 @@ export const WidgetEventEditPlain = ({

const supportsChangelog = useFeature(FEATURES.changelogs);
const { currentPageMode } = useEnrollmentEditEventPageMode(eventStatus);
const { orgUnit, error } = useCoreOrgUnit(orgUnitId);
const [changeLogIsOpen, setChangeLogIsOpen] = useState(false);
// "Edit event"-button depends on loadedValues. Delay rendering component until loadedValues has been initialized.
const loadedValues = useSelector(({ viewEventPage }) => viewEventPage.loadedValues);

const { orgUnit: coreOrgUnit, error } = useCoreOrgUnit(orgUnitId);
const orgUnit = coreOrgUnit || loadedValues?.orgUnit;

const availableProgramStages = useAvailableProgramStages(stage, teiId, enrollmentId, programId);
if (error) {
return error.errorComponent;
Expand Down
Loading