Skip to content

Commit

Permalink
Merge pull request #88 from openimis/develop
Browse files Browse the repository at this point in the history
release
  • Loading branch information
delcroip authored Apr 12, 2024
2 parents e66bfec + b1dc948 commit a3c05ec
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/HealthFacilitiesSearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { IconButton } from "@material-ui/core";
import { RIGHT_HEALTH_FACILITY_DELETE } from "../constants";

class HealthFacilitiesSearcher extends Component {
state = { reset: 0, confirmedAction: null };

constructor(props) {
super(props);
this.rowsPerPageOptions = props.modulesManager.getConf(
Expand All @@ -33,6 +35,7 @@ class HealthFacilitiesSearcher extends Component {
componentDidUpdate(prevProps, prevState, snapshot) {
if (prevProps.submittingMutation && !this.props.submittingMutation) {
this.props.journalize(this.props.mutation);
this.setState((prevState) => ({ ...prevState, reset: prevState.reset + 1 }));
} else if (prevProps.confirmed !== this.props.confirmed && !!this.props.confirmed && !!this.state.confirmedAction) {
this.state.confirmedAction();
}
Expand Down Expand Up @@ -110,8 +113,8 @@ class HealthFacilitiesSearcher extends Component {
];
if (this.props.rights.includes(RIGHT_HEALTH_FACILITY_DELETE)) {
formatters.push((hf) =>
!!hf.validityTo ? null : (
<IconButton onClick={(e) => this.onDelete(hf)}>
hf.validityTo ? null : (
<IconButton disabled={!!hf.clientMutationId} onClick={(e) => this.onDelete(hf)}>
<DeleteIcon />
</IconButton>
),
Expand All @@ -120,7 +123,7 @@ class HealthFacilitiesSearcher extends Component {
return formatters;
};

rowDisabled = (selection, i) => !!i.validityTo;
rowDisabled = (selection, hf) => hf.clientMutationId;

onDelete = (hf) => {
let confirm = (e) =>
Expand All @@ -139,7 +142,7 @@ class HealthFacilitiesSearcher extends Component {
this.setState({ confirmedAction }, confirm);
};

rowLocked = (selection, hf) => !!hf.clientMutationId;
rowLocked = (selection, hf) => hf.clientMutationId;

render() {
const {
Expand All @@ -159,6 +162,7 @@ class HealthFacilitiesSearcher extends Component {
rowsPerPageOptions={this.rowsPerPageOptions}
defaultPageSize={this.defaultPageSize}
fetch={this.props.fetchHealthFacilitySummaries}
reset={this.state.reset}
cacheFiltersKey="locationHealthFacilitiesSearcher"
items={healthFacilities}
rowIdentifier={this.rowIdentifier}
Expand Down

0 comments on commit a3c05ec

Please sign in to comment.