11import React , { Component } from 'react'
22import ReactMarkdown from 'react-markdown'
33import PropTypes from 'prop-types'
4+ import { isUndefined } from 'lodash'
45
56import Sectors from '../badges/Sectors'
67import { GroupToggleLink , filterGroups , filterField , toggleGroups } from '../../utils'
@@ -184,6 +185,36 @@ const VariableTable = function({ config, caption, rows, groups, actions }) {
184185 }
185186 }
186187
188+ const getUnit = ( row ) => {
189+ const unit = filterField ( config , row . units )
190+ return ! isUndefined ( unit ) && (
191+ < >
192+ < p className = "mb-1" >
193+ < strong > Unit:</ strong >
194+ </ p >
195+ < p >
196+ { unit }
197+ </ p >
198+ </ >
199+ )
200+ }
201+
202+ const getValid = ( row ) => {
203+ const valid_min = filterField ( config , row . valid_min )
204+ const valid_max = filterField ( config , row . valid_max )
205+ return ! isUndefined ( valid_min ) && ! isUndefined ( valid_max ) && (
206+ < >
207+ < div className = "separator" > </ div >
208+ < p className = "mb-1" >
209+ < strong > Valid range:</ strong >
210+ </ p >
211+ < p >
212+ { valid_min } - { valid_max }
213+ </ p >
214+ </ >
215+ )
216+ }
217+
187218 return (
188219 < div className = "w-100" >
189220 < table className = "table table-bordered table-fixed" >
@@ -194,7 +225,7 @@ const VariableTable = function({ config, caption, rows, groups, actions }) {
194225 < tr >
195226 < th style = { { width : '20%' } } > Variable long name</ th >
196227 < th style = { { width : '15%' } } > Variable specifier</ th >
197- < th style = { { width : '15%' } } > Unit</ th >
228+ < th style = { { width : '15%' } } > Unit / Valid range </ th >
198229 < th style = { { width : '15%' } } > Resolution</ th >
199230 < th style = { { width : '35%' } } >
200231 Comments
@@ -223,7 +254,10 @@ const VariableTable = function({ config, caption, rows, groups, actions }) {
223254 < tr key = { index } >
224255 < td > { row . long_name } </ td >
225256 < td > { getSpecifier ( row ) } </ td >
226- < td > { row . units } </ td >
257+ < td >
258+ { getUnit ( row ) }
259+ { getValid ( row ) }
260+ </ td >
227261 < td >
228262 < ul className = "resolution-list" >
229263 { getResolution ( row ) }
0 commit comments