From 7dcc76434520dad8271f8f5f38b129b2be38cf81 Mon Sep 17 00:00:00 2001 From: Sam Sciolla Date: Fri, 17 Feb 2023 09:59:26 -0500 Subject: [PATCH] Add changes from other PR --- assets/js/Components/App.js | 14 ++++++++++---- assets/js/Components/ContentPage.js | 10 +++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/assets/js/Components/App.js b/assets/js/Components/App.js index 6985d55b8..03fd049fe 100644 --- a/assets/js/Components/App.js +++ b/assets/js/Components/App.js @@ -217,14 +217,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) { diff --git a/assets/js/Components/ContentPage.js b/assets/js/Components/ContentPage.js index 38b4d5cfc..410bbb43b 100644 --- a/assets/js/Components/ContentPage.js +++ b/assets/js/Components/ContentPage.js @@ -102,9 +102,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) => {