Skip to content

Commit

Permalink
fix: revert removal of back button
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Oct 30, 2024
1 parent 1a5954a commit 5869fef
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 18 deletions.
7 changes: 5 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-10-17T17:11:55.065Z\n"
"PO-Revision-Date: 2024-10-17T17:11:55.065Z\n"
"POT-Creation-Date: 2024-10-30T11:37:11.048Z\n"
"PO-Revision-Date: 2024-10-30T11:37:11.048Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -906,6 +906,9 @@ msgstr "Indicators"
msgid "Warnings"
msgstr "Warnings"

msgid "Show all events"
msgstr "Show all events"

msgid "Event could not be loaded. Are you sure it exists?"
msgstr "Event could not be loaded. Are you sure it exists?"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// @flow
import React, { Component } from 'react';
import i18n from '@dhis2/d2-i18n';
import { withStyles } from '@material-ui/core/styles';
import { spacers } from '@dhis2/ui';
import { Button, IconChevronLeft24, spacers } from '@dhis2/ui';
import { EventDetails } from '../EventDetailsSection/EventDetailsSection.container';
import { RightColumnWrapper } from '../RightColumn/RightColumnWrapper.component';
import type { ProgramStage } from '../../../../metaData';
import { DiscardDialog } from '../../../Dialogs/DiscardDialog.component';
import { defaultDialogProps } from '../../../Dialogs/DiscardDialog.constants';
import type { UserFormField } from '../../../FormFields/UserField';
import { EventBreadcrumb } from '../../../Breadcrumbs/EventBreadcrumb';
import { pageKeys } from '../../../Breadcrumbs/EventBreadcrumb/EventBreadcrumb';
Expand Down Expand Up @@ -69,6 +72,14 @@ class ViewEventPlain extends Component<Props, State> {
warningOpen: false,
};
}
handleGoBackToAllEvents = () => {
const { isUserInteractionInProgress, onBackToAllEvents } = this.props;
if (!isUserInteractionInProgress) {
onBackToAllEvents();
} else {
this.setState({ warningOpen: true });
}
}

render() {
const {
Expand Down Expand Up @@ -96,22 +107,38 @@ class ViewEventPlain extends Component<Props, State> {
onBackToViewEvent={onBackToViewEvent}
onBackToMainPage={onBackToAllEvents}
/>
<div className={classes.contentContainer}>
<EventDetails
eventAccess={eventAccess}
programStage={programStage}
onBackToAllEvents={onBackToAllEvents}
/>
<RightColumnWrapper
eventAccess={eventAccess}
programStage={programStage}
dataEntryKey={currentDataEntryKey}
assignee={assignee}
getAssignedUserSaveContext={getAssignedUserSaveContext}
onSaveAssignee={onSaveAssignee}
onSaveAssigneeError={onSaveAssigneeError}
/>
<div>
<Button
className={classes.showAllEvents}
onClick={this.handleGoBackToAllEvents}
small
icon={<IconChevronLeft24 />}
>
{i18n.t('Show all events')}
</Button>
<div className={classes.contentContainer}>
<EventDetails
eventAccess={eventAccess}
programStage={programStage}
onBackToAllEvents={onBackToAllEvents}
/>
<RightColumnWrapper
eventAccess={eventAccess}
programStage={programStage}
dataEntryKey={currentDataEntryKey}
assignee={assignee}
getAssignedUserSaveContext={getAssignedUserSaveContext}
onSaveAssignee={onSaveAssignee}
onSaveAssigneeError={onSaveAssigneeError}
/>
</div>
</div>
<DiscardDialog
{...defaultDialogProps}
onCancel={() => { this.setState({ warningOpen: false }); }}
onDestroy={() => this.props.onBackToAllEvents()}
open={this.state.warningOpen}
/>
</div>

);
Expand Down

0 comments on commit 5869fef

Please sign in to comment.