From 5f2ce88ce31b1f9ada9040c17e8bfcf08d99ce01 Mon Sep 17 00:00:00 2001 From: henrikmv Date: Thu, 2 Jan 2025 15:59:48 +0100 Subject: [PATCH 1/6] fix: view event without org unit --- .../components/WidgetEventEdit/WidgetEventEdit.container.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js b/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js index 21b2e372ea..cf76889103 100644 --- a/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js +++ b/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js @@ -69,7 +69,7 @@ const styles = { tooltip: { display: 'inline-flex' }, }; -export const WidgetEventEditPlain = ({ +const WidgetEventEditPlain = ({ eventStatus, initialScheduleDate, stage, @@ -93,10 +93,12 @@ 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) { From c0ea70e21f75756e690b4af0474d5d9c557b6f9b Mon Sep 17 00:00:00 2001 From: henrikmv Date: Fri, 3 Jan 2025 16:54:09 +0100 Subject: [PATCH 2/6] fix: trailing space --- .../components/WidgetEventEdit/WidgetEventEdit.container.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js b/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js index cf76889103..809ac15002 100644 --- a/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js +++ b/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js @@ -96,7 +96,7 @@ const WidgetEventEditPlain = ({ 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; From 9ae2b0808c5b34129b015506d31cda3604a0bdca Mon Sep 17 00:00:00 2001 From: henrikmv Date: Wed, 8 Jan 2025 13:02:57 +0100 Subject: [PATCH 3/6] fix: temp --- .../Pages/ViewEvent/TopBar.container.js | 2 +- .../ScopeSelector/ScopeSelector.component.js | 23 +++---------------- .../ScopeSelector/ScopeSelector.container.js | 10 ++------ .../ScopeSelector/ScopeSelector.types.js | 1 - 4 files changed, 6 insertions(+), 30 deletions(-) diff --git a/src/core_modules/capture-core/components/Pages/ViewEvent/TopBar.container.js b/src/core_modules/capture-core/components/Pages/ViewEvent/TopBar.container.js index 4aeef7fbcb..3cd25b2101 100644 --- a/src/core_modules/capture-core/components/Pages/ViewEvent/TopBar.container.js +++ b/src/core_modules/capture-core/components/Pages/ViewEvent/TopBar.container.js @@ -56,7 +56,7 @@ export const TopBar = ({ selectedOrgUnitId={orgUnitId} selectedCategories={selectedCategories} onResetProgramId={() => resetViewEventId('/', { orgUnitId })} - onResetOrgUnitId={() => resetViewEventId('/', { programId })} + onResetOrgUnitId={() => resetViewEventId('/')} onSetCategoryOption={dispatchOnSetCategoryOption} onResetAllCategoryOptions={dispatchOnResetAllCategoryOptions} onResetCategoryOption={dispatchOnResetCategoryOption} diff --git a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js index 6cce3cefa5..f1e029dc9f 100644 --- a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js +++ b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js @@ -22,7 +22,6 @@ class ScopeSelectorClass extends Component { super(props); this.state = { - openOrgUnitWarning: false, openProgramWarning: null, openCatComboWarning: false, openStartAgainWarning: false, @@ -32,12 +31,8 @@ class ScopeSelectorClass extends Component { dontShowWarning = () => !this.props.isUserInteractionInProgress; - handleOpenOrgUnitWarning = () => { - if (this.dontShowWarning()) { - this.props.onResetOrgUnitId(); - return; - } - this.setState({ openOrgUnitWarning: true }); + handleOrgUnitReset = () => { + this.props.onResetOrgUnitId(); } handleOpenProgramWarning = (baseAction: ReduxAction) => { @@ -66,18 +61,12 @@ class ScopeSelectorClass extends Component { 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); @@ -108,7 +97,7 @@ class ScopeSelectorClass extends Component { onSetProgramId={onSetProgramId} onSetCategoryOption={onSetCategoryOption} onResetAllCategoryOptions={onResetAllCategoryOptions} - onResetOrgUnitId={this.handleOpenOrgUnitWarning} + onResetOrgUnitId={this.handleOrgUnitReset} onResetProgramId={this.handleOpenProgramWarning} onResetCategoryOption={this.handleOpenCatComboWarning} onStartAgain={this.handleStartAgainWarning} @@ -122,12 +111,6 @@ class ScopeSelectorClass extends Component { > {this.props.children} - { // because we want the orgUnit to be fetched and stored @@ -32,7 +30,6 @@ export const ScopeSelector: ComponentType = ({ formIsOpen = false, children, }) => { - const dispatch = useDispatch(); const [selectedOrgUnit, setSelectedOrgUnit] = useState({ name: undefined, id: selectedOrgUnitId }); const { displayName, error: ouNameError } = useOrgUnitNameWithAncestors(selectedOrgUnit.id); @@ -64,10 +61,7 @@ export const ScopeSelector: ComponentType = ({ return ( { - selectedOrgUnit && dispatch(resetOrgUnitIdFromScopeSelector(selectedOrgUnit?.id)); - return onResetOrgUnitId(); - }} + onResetOrgUnitId={onResetOrgUnitId} onResetAllCategoryOptions={onResetAllCategoryOptions} onResetCategoryOption={onResetCategoryOption} onSetCategoryOption={onSetCategoryOption} diff --git a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.types.js b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.types.js index 09faa0ece8..c802a05dc1 100644 --- a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.types.js +++ b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.types.js @@ -34,7 +34,6 @@ export type Props = {| |} export type State = {| - openOrgUnitWarning: boolean; openProgramWarning: ?Object; openCatComboWarning: boolean; openStartAgainWarning: boolean; From 9ff07c3bb2710931e9430bd6e55f99495a855bb2 Mon Sep 17 00:00:00 2001 From: henrikmv Date: Wed, 8 Jan 2025 13:17:47 +0100 Subject: [PATCH 4/6] fix: remove warning for org unit --- .../ScopeSelector/ScopeSelector.component.js | 13 +++++++------ .../ScopeSelector/ScopeSelector.container.js | 9 +++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js index f1e029dc9f..417c4ccb13 100644 --- a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js +++ b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js @@ -31,10 +31,6 @@ class ScopeSelectorClass extends Component { dontShowWarning = () => !this.props.isUserInteractionInProgress; - handleOrgUnitReset = () => { - this.props.onResetOrgUnitId(); - } - handleOpenProgramWarning = (baseAction: ReduxAction) => { if (this.dontShowWarning()) { this.props.onResetProgramId(baseAction); @@ -85,7 +81,12 @@ class ScopeSelectorClass extends Component { } render() { - const { onSetOrgUnit, onSetProgramId, onSetCategoryOption, onResetAllCategoryOptions } = this.props; + const { + onSetOrgUnit, + onSetProgramId, + onSetCategoryOption, + onResetAllCategoryOptions, + } = this.props; return (
{ onSetProgramId={onSetProgramId} onSetCategoryOption={onSetCategoryOption} onResetAllCategoryOptions={onResetAllCategoryOptions} - onResetOrgUnitId={this.handleOrgUnitReset} + onResetOrgUnitId={this.props.onResetOrgUnitId} onResetProgramId={this.handleOpenProgramWarning} onResetCategoryOption={this.handleOpenCatComboWarning} onStartAgain={this.handleStartAgainWarning} diff --git a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.container.js b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.container.js index d33b613544..dd32042503 100644 --- a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.container.js +++ b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.container.js @@ -1,9 +1,10 @@ // @flow import React, { type ComponentType, useEffect, useState } from 'react'; -import { useSelector } from 'react-redux'; +import { useDispatch, useSelector } from 'react-redux'; import { ScopeSelectorComponent } from './ScopeSelector.component'; 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 @@ -30,6 +31,7 @@ export const ScopeSelector: ComponentType = ({ formIsOpen = false, children, }) => { + const dispatch = useDispatch(); const [selectedOrgUnit, setSelectedOrgUnit] = useState({ name: undefined, id: selectedOrgUnitId }); const { displayName, error: ouNameError } = useOrgUnitNameWithAncestors(selectedOrgUnit.id); @@ -61,7 +63,10 @@ export const ScopeSelector: ComponentType = ({ return ( { + selectedOrgUnit && dispatch(resetOrgUnitIdFromScopeSelector(selectedOrgUnit?.id)); + return onResetOrgUnitId(); + }} onResetAllCategoryOptions={onResetAllCategoryOptions} onResetCategoryOption={onResetCategoryOption} onSetCategoryOption={onSetCategoryOption} From 9048ff53bd240b31d601f6de68d9306fb2d92093 Mon Sep 17 00:00:00 2001 From: henrikmv Date: Sun, 12 Jan 2025 15:57:56 +0100 Subject: [PATCH 5/6] fix: view event without org unit tracker programs --- .../capture-core/components/Pages/ViewEvent/TopBar.container.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core_modules/capture-core/components/Pages/ViewEvent/TopBar.container.js b/src/core_modules/capture-core/components/Pages/ViewEvent/TopBar.container.js index 3cd25b2101..4aeef7fbcb 100644 --- a/src/core_modules/capture-core/components/Pages/ViewEvent/TopBar.container.js +++ b/src/core_modules/capture-core/components/Pages/ViewEvent/TopBar.container.js @@ -56,7 +56,7 @@ export const TopBar = ({ selectedOrgUnitId={orgUnitId} selectedCategories={selectedCategories} onResetProgramId={() => resetViewEventId('/', { orgUnitId })} - onResetOrgUnitId={() => resetViewEventId('/')} + onResetOrgUnitId={() => resetViewEventId('/', { programId })} onSetCategoryOption={dispatchOnSetCategoryOption} onResetAllCategoryOptions={dispatchOnResetAllCategoryOptions} onResetCategoryOption={dispatchOnResetCategoryOption} From b0bdad6cd1abf3e98ff5713ea2889028f6462552 Mon Sep 17 00:00:00 2001 From: henrikmv Date: Thu, 16 Jan 2025 12:56:18 +0100 Subject: [PATCH 6/6] fix: revert changes warning --- .../ScopeSelector/ScopeSelector.component.js | 23 ++++++++++++++++++- .../ScopeSelector/ScopeSelector.types.js | 1 + .../WidgetEventEdit.container.js | 1 - 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js index 417c4ccb13..a15878b2fb 100644 --- a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js +++ b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js @@ -22,6 +22,7 @@ class ScopeSelectorClass extends Component { super(props); this.state = { + openOrgUnitWarning: false, openProgramWarning: null, openCatComboWarning: false, openStartAgainWarning: false, @@ -31,6 +32,14 @@ class ScopeSelectorClass extends Component { dontShowWarning = () => !this.props.isUserInteractionInProgress; + handleOpenOrgUnitWarning = () => { + if (this.dontShowWarning()) { + this.props.onResetOrgUnitId(); + return; + } + this.setState({ openOrgUnitWarning: true }); + } + handleOpenProgramWarning = (baseAction: ReduxAction) => { if (this.dontShowWarning()) { this.props.onResetProgramId(baseAction); @@ -57,12 +66,18 @@ class ScopeSelectorClass extends Component { 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); @@ -98,7 +113,7 @@ class ScopeSelectorClass extends Component { onSetProgramId={onSetProgramId} onSetCategoryOption={onSetCategoryOption} onResetAllCategoryOptions={onResetAllCategoryOptions} - onResetOrgUnitId={this.props.onResetOrgUnitId} + onResetOrgUnitId={this.handleOpenOrgUnitWarning} onResetProgramId={this.handleOpenProgramWarning} onResetCategoryOption={this.handleOpenCatComboWarning} onStartAgain={this.handleStartAgainWarning} @@ -112,6 +127,12 @@ class ScopeSelectorClass extends Component { > {this.props.children} + viewEventPage.loadedValues); - const { orgUnit: coreOrgUnit, error } = useCoreOrgUnit(orgUnitId); const orgUnit = coreOrgUnit || loadedValues?.orgUnit;