From 7dcc76434520dad8271f8f5f38b129b2be38cf81 Mon Sep 17 00:00:00 2001 From: Sam Sciolla Date: Fri, 17 Feb 2023 09:59:26 -0500 Subject: [PATCH 1/2] 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) => { From a0a0bc8cd80efe967bead54a7b4586ef32dc9b78 Mon Sep 17 00:00:00 2001 From: Sam Sciolla Date: Mon, 10 Apr 2023 11:57:07 -0400 Subject: [PATCH 2/2] Make syntax consistent --- assets/js/Components/App.js | 4 ++-- assets/js/Components/ContentPage.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/Components/App.js b/assets/js/Components/App.js index 03fd049fe..b4873b5b2 100644 --- a/assets/js/Components/App.js +++ b/assets/js/Components/App.js @@ -219,13 +219,13 @@ class App extends React.Component { handleIssueSave(newIssue, newReport) { const oldReport = this.state.report; - const report = {...oldReport, ...newReport}; + const report = { ...oldReport, ...newReport }; if (report && Array.isArray(report.issues)) { // 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); + const oldIssue = oldReport.issues.find((oldReportIssue) => oldReportIssue.id === issue.id); return oldIssue !== undefined ? { ...oldIssue, ...issue } : issue; }); } diff --git a/assets/js/Components/ContentPage.js b/assets/js/Components/ContentPage.js index 410bbb43b..8c4bad469 100644 --- a/assets/js/Components/ContentPage.js +++ b/assets/js/Components/ContentPage.js @@ -103,7 +103,7 @@ class ContentPage extends React.Component { handleCloseButton = () => { const newReport = { ...this.props.report }; - newReport.issues = newReport.issues.map(issue => { + newReport.issues = newReport.issues.map((issue) => { issue.recentlyResolved = false; issue.recentlyUpdated = false; return issue;