Skip to content

Commit

Permalink
Small readability changes from feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
gjvoosten committed Nov 18, 2020
1 parent 31733c4 commit d4deb05
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
15 changes: 8 additions & 7 deletions client/src/pages/reports/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,11 @@ const ReportForm = ({
}
}

// Only an author can delete a report, and only in DRAFT.
// Only an author can delete a report, and only in DRAFT or REJECTED state.
const canDelete =
!!values.uuid &&
(Report.isDraft(values.state) || Report.isRejected(values.state)) &&
values.authors?.find(a => Person.isEqual(currentUser, a))
values.authors?.some(a => Person.isEqual(currentUser, a))
// Skip validation on save!
const action = (
<div>
Expand Down Expand Up @@ -709,7 +709,8 @@ const ReportForm = ({
})
}
onChange={value =>
setFieldValue("reportPeople", value, true)}
setFieldValue("reportPeople", value, true)
}
showDelete
/>
}
Expand Down Expand Up @@ -1362,17 +1363,17 @@ const ReportForm = ({
// reportTags contains id's instead of uuid's (as that is what the ReactTags component expects)
report.tags = values.reportTags.map(tag => ({ uuid: tag.id }))
// strip reportPeople fields not in data model
report.reportPeople = values.reportPeople.map(a => {
report.reportPeople = values.reportPeople.map(reportPerson => {
const rp = Object.without(
a,
reportPerson,
"firstName",
"lastName",
"position",
"customFields",
DEFAULT_CUSTOM_FIELDS_PARENT
)
rp.author = !!a.author
rp.attendee = !!a.attendee
rp.author = !!reportPerson.author
rp.attendee = !!reportPerson.attendee
return rp
})
// strip tasks fields not in data model
Expand Down
6 changes: 4 additions & 2 deletions client/src/pages/reports/ReportPeople.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const ReportPeople = ({ report, disabled, onChange, showDelete, onDelete }) => {
<TableBody
reportPeople={report.reportPeople}
filterCb={person =>
person.role === Person.ROLE.ADVISOR && person.attendee}
person.role === Person.ROLE.ADVISOR && person.attendee
}
handleAttendeeRow={renderAttendeeRow}
showDelete={showDelete}
/>
Expand All @@ -44,7 +45,8 @@ const ReportPeople = ({ report, disabled, onChange, showDelete, onDelete }) => {
<TableBody
reportPeople={report.reportPeople}
filterCb={person =>
person.role === Person.ROLE.PRINCIPAL && person.attendee}
person.role === Person.ROLE.PRINCIPAL && person.attendee
}
handleAttendeeRow={renderAttendeeRow}
enableDivider
showDelete={showDelete}
Expand Down
6 changes: 3 additions & 3 deletions client/tests/e2e/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,12 @@ test.serial(
"Neutral atmospherics details"
)

const $attendanceFieldsetTitle = await $(
const $reportPeopleFieldsetTitle = await $(
"#reportPeople-fieldset .title-text"
)
await assertElementText(
t,
$attendanceFieldsetTitle,
$reportPeopleFieldsetTitle,
"People involved in this engagement",
"People fieldset should have correct title for an uncancelled enagement"
)
Expand All @@ -631,7 +631,7 @@ test.serial(
)
await assertElementText(
t,
$attendanceFieldsetTitle,
$reportPeopleFieldsetTitle,
"People who will be involved in this planned engagement",
"People fieldset should have correct title for a cancelled enagement"
)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mil/dds/anet/beans/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public CompletableFuture<List<ReportPerson>> loadAttendees(
return loadReportPeople(context) // Force the load of reportPeople
.thenApply(l -> {
final List<ReportPerson> o =
l.stream().filter(p -> p.isAttendee()).collect(Collectors.toList());
l.stream().filter(ReportPerson::isAttendee).collect(Collectors.toList());
attendees = o;
return o;
});
Expand Down Expand Up @@ -360,7 +360,7 @@ public CompletableFuture<List<ReportPerson>> loadAuthors(
return loadReportPeople(context) // Force the load of reportPeople
.thenApply(l -> {
final List<ReportPerson> o =
l.stream().filter(p -> p.isAuthor()).collect(Collectors.toList());
l.stream().filter(ReportPerson::isAuthor).collect(Collectors.toList());
authors = o;
return o;
});
Expand Down

0 comments on commit d4deb05

Please sign in to comment.