Skip to content

Commit

Permalink
Merge pull request #892 from ssciolla/issue-887-keep-recent-in-modal
Browse files Browse the repository at this point in the history
Keep recently changed issues in `UFixitModal` (#887)
  • Loading branch information
dmols authored Jul 25, 2024
2 parents 0839145 + a0a0bc8 commit e62f3a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
14 changes: 10 additions & 4 deletions assets/js/Components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,20 @@ class App extends React.Component {
}

handleIssueSave(newIssue, newReport) {
let { report } = this.state
report = {...report, ...newReport}
const oldReport = this.state.report;

const report = { ...oldReport, ...newReport };

if (report && Array.isArray(report.issues)) {
report.issues = report.issues.map(issue => (issue.id == newIssue.id) ? newIssue : issue)
// Combine backend issues with frontend issue state
report.issues = report.issues.map((issue) => {
if (issue.id === newIssue.id) return newIssue;
const oldIssue = oldReport.issues.find((oldReportIssue) => oldReportIssue.id === issue.id);
return oldIssue !== undefined ? { ...oldIssue, ...issue } : issue;
});
}

this.setState({ report })
this.setState({ report });
}

handleFileSave(newFile, newReport) {
Expand Down
10 changes: 9 additions & 1 deletion assets/js/Components/ContentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,17 @@ class ContentPage extends React.Component {
}

handleCloseButton = () => {
const newReport = { ...this.props.report };
newReport.issues = newReport.issues.map((issue) => {
issue.recentlyResolved = false;
issue.recentlyUpdated = false;
return issue;
});

this.setState({
report: newReport,
modalOpen: false
})
});
}

handleTrayToggle = (e, val) => {
Expand Down

0 comments on commit e62f3a2

Please sign in to comment.