Skip to content

Commit d805e2e

Browse files
committed
Update valid values in output variables table
1 parent 67f3d09 commit d805e2e

3 files changed

Lines changed: 35 additions & 50 deletions

File tree

app/src/components/tables/VariableTable.js

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -185,48 +185,34 @@ const VariableTable = function({ config, caption, rows, groups, actions }) {
185185
}
186186
}
187187

188-
const getValid = (row, field, label) => {
189-
const value = filterField(config, row[field])
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+
}
190201

191-
if (typeof value === 'object') {
192-
if (Object.keys(value).length > 1) {
193-
return <>
194-
<p><strong>{label}</strong></p>
195-
<ul>
196-
{
197-
Object.keys(value).map((sector, index) => {
198-
return (
199-
<li key={index}>
200-
<em className="sector">{sector}:</em>{' '}{value[sector]}
201-
{
202-
(row.units != 1) && <>{' '}<span>{row.units}</span></>
203-
}
204-
</li>
205-
)
206-
})
207-
}
208-
</ul>
209-
</>
210-
} else {
211-
return (
212-
<p>
213-
<strong>{label}</strong>{' '}<span>{Object.values(value)[0]}</span>
214-
{
215-
(row.units && row.units != 1) && <>{' '}<span>{row.units}</span></>
216-
}
217-
</p>
218-
)
219-
}
220-
} else {
221-
return (
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>
222211
<p>
223-
<strong>{label}</strong>{' '}<span>{value}</span>
224-
{
225-
(row.units && row.units != 1) && <>{' '}<span>{row.units}</span></>
226-
}
212+
{valid_min} - {valid_max}
227213
</p>
228-
)
229-
}
214+
</>
215+
)
230216
}
231217

232218
return (
@@ -269,7 +255,8 @@ const VariableTable = function({ config, caption, rows, groups, actions }) {
269255
<td>{row.long_name}</td>
270256
<td>{getSpecifier(row)}</td>
271257
<td>
272-
<p>{row.units}</p>
258+
{getUnit(row)}
259+
{getValid(row)}
273260
</td>
274261
<td>
275262
<ul className="resolution-list">
@@ -284,8 +271,6 @@ const VariableTable = function({ config, caption, rows, groups, actions }) {
284271
<Sectors config={config} sectors={row.sectors} />
285272
</p>
286273
{getDimensions(row)}
287-
{getValid(row, 'valid_min', 'Minimum valid value:')}
288-
{getValid(row, 'valid_max', 'Maximum valid value:')}
289274
{getComment(row)}
290275
</td>
291276
</tr>

assets/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,12 @@ td.nowrap > div {
402402
margin-bottom: 0;
403403
}
404404

405+
div.separator {
406+
border-top: 1px solid #dee2e6;
407+
margin-top: 0.75rem;
408+
padding-top: 0.75rem;
409+
}
410+
405411
@media print {
406412
body {
407413
/* fix colors in printing */

definitions/variable/hydrological.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,8 @@
376376
- peat
377377
- permafrost
378378
- water_global
379-
valid_max:
380-
other: 1000.0
381-
lakes_local: 5.0
382-
lakes_global: 5.0
383-
valid_min:
384-
other: 0.0
385-
lakes_local: 0.0
386-
lakes_global: 0.0
379+
valid_max: 1000.0
380+
valid_min: 0.0
387381

388382
- specifier: snm
389383
long_name: Snow Melt

0 commit comments

Comments
 (0)