Skip to content

Commit

Permalink
feat: Don't show notes or categoryId in additional detail
Browse files Browse the repository at this point in the history
Since these tags are used to define the preset and are already shown.
  • Loading branch information
gmaclennan committed Oct 6, 2019
1 parent d64312d commit dba51e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/ReportView/ReportPageContent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import React from 'react'
import { makeStyles } from '@material-ui/styles'
import Typography from '@material-ui/core/Typography'
import FeatureHeader from '../internal/FeatureHeader'
import Image from '../internal/Image'
import DetailsTable from './DetailsTable'
Expand All @@ -12,8 +13,11 @@ const useStyles = makeStyles({
imageWrapper: {
width: '100%',
height: '12cm',
borderTop: '1px solid rgb(224, 224, 224)',
borderBottom: '1px solid rgb(224, 224, 224)'
borderTop: '1px solid rgb(224, 224, 224)'
},
notes: {
borderBottom: '1px solid rgb(224, 224, 224)',
paddingBottom: 16
}
})

Expand All @@ -40,7 +44,8 @@ const ReportPageContent = ({
tags,
paperSize
}: Props) => {
const classes = useStyles()
const cx = useStyles()
const notes = tags && (tags.note || tags.notes)

return (
<>
Expand All @@ -52,10 +57,11 @@ const ReportPageContent = ({
createdAt={createdAt}
/>
{imageSrc && (
<div className={classes.imageWrapper}>
<div className={cx.imageWrapper}>
<Image style={{ width: '100%', height: '12cm' }} src={imageSrc} />
</div>
)}
{notes && <Typography className={cx.notes}>{notes}</Typography>}
{tags && (
<DetailsTable
fields={fields}
Expand Down
16 changes: 15 additions & 1 deletion src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export function getLastImage(observation: Observation): Attachment | void {
return imageAttachments[imageAttachments.length - 1]
}

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

export function defaultGetPreset(
observation: Observation,
stats?: Statistics
Expand All @@ -37,7 +43,15 @@ export function defaultGetPreset(
name: (observation.tags && observation.tags.name) || '',
tags: {},
fields: [],
additionalFields: getFieldsFromTags(observation.tags, stats)
additionalFields: getFieldsFromTags(observation.tags, stats).filter(
field => {
// Hacky - change. Hide categoryId and notes fields.
const fieldKey = Array.isArray(field.key) ? field.key[0] : field.key
console.log('string key', fieldKey)
if (hiddenTags[fieldKey]) return false
return true
}
)
}
}

Expand Down

0 comments on commit dba51e7

Please sign in to comment.