Skip to content

Commit

Permalink
fix: Don't show option to hide categoryId and notes from reports
Browse files Browse the repository at this point in the history
These fields do not show in the report anyway
  • Loading branch information
gmaclennan committed Oct 7, 2019
1 parent 1957010 commit 79d1fa4
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/ReportView/ReportView.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ type Props = {
...$Exact<ReportViewContentProps>
}

const hiddenTags = {
categoryId: true,
notes: true,
note: true
}

const ReportView = ({
observations,
onUpdateObservation,
Expand All @@ -35,15 +41,23 @@ const ReportView = ({

const [fieldState, setFieldState] = useState(() => {
// Lazy initial state to avoid this being calculated on every render
return Object.keys(stats).map(key => {
const fieldKey = JSON.parse(key)
const label = fieldKeyToLabel(fieldKey)
return {
id: key,
hidden: false,
label: Array.isArray(label) ? label.join('.') : label
}
})
return Object.keys(stats)
.filter(key => {
// Hacky: don't include categoryId and notes in options of fields you can hide
const fieldKey = JSON.parse(key)
const fieldKeyString = Array.isArray(fieldKey) ? fieldKey[0] : fieldKey
if (hiddenTags[fieldKeyString]) return false
return true
})
.map(key => {
const fieldKey = JSON.parse(key)
const label = fieldKeyToLabel(fieldKey)
return {
id: key,
hidden: false,
label: Array.isArray(label) ? label.join('.') : label
}
})
})

useLayoutEffect(() => {
Expand Down

0 comments on commit 79d1fa4

Please sign in to comment.