From f0e74c24f1b1befbb27e67dd2be3ff4f20179259 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 22 Mar 2023 16:08:34 +0100 Subject: [PATCH 1/2] OTC-966: make save button always visible (#11) --- src/components/ContributionForm.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ContributionForm.js b/src/components/ContributionForm.js index 9919fd1..3d53816 100644 --- a/src/components/ContributionForm.js +++ b/src/components/ContributionForm.js @@ -227,6 +227,7 @@ class ContributionForm extends Component { save={!!save ? this.confirmSave : null} update={update} onActionToConfirm={this.onActionToConfirm} + openDirty={save} /> )} From 1f4643f92c8ce81a370adb25310992fb511175d9 Mon Sep 17 00:00:00 2001 From: olewandowski1 <109145288+olewandowski1@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:50:38 +0100 Subject: [PATCH 2/2] OTC-757: Clearing pagination state if entered the ContributionsPage (#12) * OTC-757: Clearing pagination state if entered the ContributionsPage * OTC-757: Code refactor in ContributionsPage --- src/pages/ContributionsPage.js | 87 +++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 28 deletions(-) diff --git a/src/pages/ContributionsPage.js b/src/pages/ContributionsPage.js index 08dabf8..65e2e18 100644 --- a/src/pages/ContributionsPage.js +++ b/src/pages/ContributionsPage.js @@ -1,40 +1,71 @@ import React, { Component } from "react"; +import { bindActionCreators } from "redux"; import { connect } from "react-redux"; -import { injectIntl } from 'react-intl'; +import { injectIntl } from "react-intl"; + import { withTheme, withStyles } from "@material-ui/core/styles"; -import { historyPush, withModulesManager, withHistory } from "@openimis/fe-core" -import ContributionSearcher from "../components/ContributionSearcher"; +import { + historyPush, + withModulesManager, + withHistory, + clearCurrentPaginationPage, +} from "@openimis/fe-core"; +import ContributionSearcher from "../components/ContributionSearcher"; -const styles = theme => ({ - page: theme.page, - fab: theme.fab +const styles = (theme) => ({ + page: theme.page, + fab: theme.fab, }); - class ContributionsPage extends Component { + onDoubleClick = (c, newTab = false) => { + historyPush( + this.props.modulesManager, + this.props.history, + "contribution.contributionOverview", + [c.uuid], + newTab + ); + }; - onDoubleClick = (c, newTab = false) => { - historyPush(this.props.modulesManager, this.props.history, "contribution.contributionOverview", [c.uuid], newTab) - } - - render() { - const { classes } = this.props; - return ( -
- -
- ) - } + componentDidMount = () => { + const moduleName = "contribution"; + const { module } = this.props; + if (module !== moduleName) this.props.clearCurrentPaginationPage(); + }; + + render() { + const { classes } = this.props; + return ( +
+ +
+ ); + } } -const mapStateToProps = state => ({ - rights: !!state.core && !!state.core.user && !!state.core.user.i_user ? state.core.user.i_user.rights : [], -}) +const mapStateToProps = (state) => ({ + rights: + !!state.core && !!state.core.user && !!state.core.user.i_user + ? state.core.user.i_user.rights + : [], + module: state.core?.savedPagination?.module, +}); + +const mapDispatchToProps = (dispatch) => + bindActionCreators({ clearCurrentPaginationPage }, dispatch); -export default injectIntl(withModulesManager( - withHistory(connect(mapStateToProps)(withTheme(withStyles(styles)(ContributionsPage)))) -)); \ No newline at end of file +export default injectIntl( + withModulesManager( + withHistory( + connect( + mapStateToProps, + mapDispatchToProps + )(withTheme(withStyles(styles)(ContributionsPage))) + ) + ) +);