Skip to content

Commit

Permalink
AB#670: Show attendees without assessments in report summary
Browse files Browse the repository at this point in the history
  • Loading branch information
anilsonmez-simsoft committed Jan 17, 2023
1 parent f184dd4 commit 39bc993
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,58 @@ const InstantAssessmentsContainerField = ({
formikProps,
canRead,
canWrite,
readonly
readonly,
showEntitiesWithoutAssessments
}) => {
const { values } = formikProps
function sortEntries(e1, e2) {
let e1HasAssessments = false
const e1entityInstantAssessments = e1.getInstantAssessments()
e1entityInstantAssessments.forEach(([ak, ac]) => {
const filteredAssessment = Model.filterAssessmentConfig(
ac,
e1,
relatedObject
)
if (
!_isEmpty(filteredAssessment.questions) ||
!_isEmpty(filteredAssessment.questionSets)
) {
e1HasAssessments = true
}
})
if (e1HasAssessments) {
return 1
}
return -1
}
function getEntitiesWithAssessments(entity) {
const entityInstantAssessments = entity.getInstantAssessments()
let hasAssessments = false
entityInstantAssessments.forEach(([ak, ac]) => {
const filteredAssessment = Model.filterAssessmentConfig(
ac,
entity,
relatedObject
)
if (
!_isEmpty(filteredAssessment.questions) ||
!_isEmpty(filteredAssessment.questionSets)
) {
hasAssessments = true
}
})
return hasAssessments
}
// Sort entities to display the ones without any assessment at the end
const filteredEntities = showEntitiesWithoutAssessments
? entities.sort(sortEntries)
: entities.filter(getEntitiesWithAssessments)
return (
<Table>
<tbody>
{entities.map(entity => {
{filteredEntities.map(entity => {
const entityInstantAssessments = entity.getInstantAssessments()
let hasAssessments = false
entityInstantAssessments.forEach(([ak, ac]) => {
const filteredAssessment = Model.filterAssessmentConfig(
ac,
entity,
relatedObject
)
if (
!_isEmpty(filteredAssessment.questions) ||
!_isEmpty(filteredAssessment.questionSets)
) {
hasAssessments = true
}
})
if (!hasAssessments) {
return null
}

return (
<React.Fragment key={`assessment-${values.uuid}-${entity.uuid}`}>
Expand Down Expand Up @@ -172,7 +199,8 @@ InstantAssessmentsContainerField.propTypes = {
}),
canRead: PropTypes.bool,
canWrite: PropTypes.bool,
readonly: PropTypes.bool
readonly: PropTypes.bool,
showEntitiesWithoutAssessments: PropTypes.bool
}
InstantAssessmentsContainerField.defaultProps = {
entities: [],
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/reports/Compact.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ const CompactReportView = ({ pageDispatchers }) => {
}}
canRead={canReadAssessments}
readonly
showEntitiesWithoutAssessments
/>
) : (
attendees.map(attendee => (
Expand Down

0 comments on commit 39bc993

Please sign in to comment.