Skip to content

Commit

Permalink
Add changes from other PR
Browse files Browse the repository at this point in the history
  • Loading branch information
ssciolla committed Feb 17, 2023
1 parent d15538d commit 7dcc764
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 @@ -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) {
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 @@ -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) => {
Expand Down

0 comments on commit 7dcc764

Please sign in to comment.