Skip to content

Commit d95389c

Browse files
committed
Refactor experiments table to hide/show sensitivity experiments on demand
1 parent 6d0e50a commit d95389c

File tree

10 files changed

+325
-194
lines changed

10 files changed

+325
-194
lines changed

app/src/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const initConfig = () => {
2525
const defaultConfig = {
2626
simulation_round: 'ISIMIP3a',
2727
sectors: [],
28+
experiments: [],
2829
groups: [],
2930
group3: false
3031
}

app/src/components/tables/ExperimentsTable.js

Lines changed: 244 additions & 189 deletions
Large diffs are not rendered by default.

app/src/store.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ const actions = {
55
changeSector: function(value) {
66
return { type: 'changeSector', value }
77
},
8+
toggleExperiments: function(value) {
9+
return { type: 'toggleExperiments', value }
10+
},
811
toggleGroup: function(value) {
912
return { type: 'toggleGroup', value }
1013
},
@@ -31,11 +34,24 @@ function reducer(state, action) {
3134
}
3235
}
3336
}
37+
case 'toggleExperiments': {
38+
if (state.config.experiments.find((value) => value === action.value)) {
39+
return {
40+
...state,
41+
config: { ...state.config, experiments: state.config.experiments.filter((value) => value !== action.value) }
42+
}
43+
} else {
44+
return {
45+
...state,
46+
config: { ...state.config, experiments: [...state.config.experiments, action.value] }
47+
}
48+
}
49+
}
3450
case 'toggleGroup': {
35-
if (state.config.groups.find((group) => group === action.value)) {
51+
if (state.config.groups.find((value) => value === action.value)) {
3652
return {
3753
...state,
38-
config: { ...state.config, groups: state.config.groups.filter((group) => group !== action.value) }
54+
config: { ...state.config, groups: state.config.groups.filter((value) => value !== action.value) }
3955
}
4056
} else {
4157
return {

app/src/utils/ls.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ const getConfig = () => {
1515
config.sectors = sectors
1616
}
1717

18+
const experiments = ls.get('experiments') ? JSON.parse(ls.get('experiments')) : []
19+
if (definitions.experiments.some((experiment) => experiments.includes(experiment.specifier))) {
20+
config.experiments = experiments
21+
}
22+
1823
const groups = ls.get('groups') ? JSON.parse(ls.get('groups')) : []
1924
if (definitions.group.some((group) => groups.includes(group.specifier))) {
2025
config.groups = groups
@@ -28,6 +33,7 @@ const getConfig = () => {
2833
const updateConfig = (config) => {
2934
ls.set('simulation_round', config.simulation_round)
3035
ls.set('sectors', JSON.stringify(config.sectors))
36+
ls.set('experiments', JSON.stringify(config.experiments))
3137
ls.set('groups', JSON.stringify(config.groups))
3238
ls.set('group3', JSON.stringify(config.group3))
3339
}

assets/style.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ a.toggle-group {
9191
display: block;
9292
float: right;
9393
}
94+
.experiments-toggle a.toggle-group {
95+
float: none;
96+
}
9497
a.toggle-group {
9598
position: relative;
9699
margin-right: 15px;
@@ -125,6 +128,14 @@ button.toggle-table {
125128
button.toggle-table:focus {
126129
outline: 0;
127130
}
131+
tr.separator td {
132+
padding: 1px 0 0 0;
133+
background-color: #dee2e6;
134+
}
135+
tr.sens-title td {
136+
padding-top: 0.25rem;
137+
padding-bottom: 0.25rem;
138+
}
128139
td :last-child {
129140
margin-bottom: 0;
130141
}
@@ -144,6 +155,9 @@ td > ul > li > ul > li {
144155
td p {
145156
margin-bottom: 0.5rem;
146157
}
158+
td.background {
159+
background-color: #efefef;
160+
}
147161
td.extra-border-bottom {
148162
border-bottom-width: 3px;
149163
}

definitions/experiments/ISIMIP3a.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@
183183
- forestry
184184

185185
- specifier: obsclim_histsoc_1901co2
186+
parent: obsclim_histsoc_default
186187
title: CO₂ sensitivity
187188
subtitles:
188189
- obsclim_histsoc_1901co2
@@ -210,6 +211,7 @@
210211
- water_regional
211212

212213
- specifier: obsclim_2015soc_1901co2
214+
parent: obsclim_2015soc_default
213215
title: CO₂ sensitivity
214216
subtitles:
215217
- obsclim_2015soc_1901co2
@@ -236,6 +238,7 @@
236238
- water_regional
237239

238240
- specifier: obsclim_1901soc_1901co2
241+
parent: obsclim_1901soc_default
239242
title: CO₂ sensitivity
240243
subtitles:
241244
- obsclim_1901soc_1901co2
@@ -255,6 +258,7 @@
255258
- water_global
256259

257260
- specifier: obsclim_histsoc_nowatermgt
261+
parent: obsclim_histsoc_default
258262
title: Water management sensitivity
259263
subtitles:
260264
- obsclim_histsoc_nowatermgt
@@ -271,6 +275,7 @@
271275
- water_regional
272276

273277
- specifier: obsclim_2015soc_nowatermgt
278+
parent: obsclim_2015soc_default
274279
title: Water management sensitivity
275280
subtitles:
276281
- obsclim_2015soc_nowatermgt
@@ -287,6 +292,7 @@
287292
- water_regional
288293

289294
- specifier: obsclim_histsoc_1901irr
295+
parent: obsclim_histsoc_default
290296
title: Irrigation sensitivity
291297
subtitles:
292298
- obsclim_histsoc_1901irr
@@ -302,6 +308,7 @@
302308
- water_regional
303309

304310
- specifier: obsclim_histsoc_nofire
311+
parent: obsclim_histsoc_default
305312
title: No-fire sensitivity
306313
subtitles:
307314
- obsclim_histsoc_nofire
@@ -319,6 +326,7 @@
319326
- permafrost
320327

321328
- specifier: counterclim_histsoc_obsco2
329+
parent: obsclim_histsoc_default
322330
title: Counterfactual climate and CO₂ sensitivity
323331
subtitles:
324332
- counterclim_histsoc_obsco2
@@ -334,6 +342,7 @@
334342
- forestry
335343

336344
- specifier: obsclim_histsoc_30arcsec
345+
parent: obsclim_histsoc_default
337346
title: High-resolution sensitivity 1km
338347
subtitles:
339348
- obsclim_histsoc_30arcsec
@@ -355,6 +364,7 @@
355364
- water_regional
356365

357366
- specifier: obsclim_histsoc_90arcsec
367+
parent: obsclim_histsoc_default
358368
title: High-resolution sensitivity 3km
359369
subtitles:
360370
- obsclim_histsoc_90arcsec
@@ -376,6 +386,7 @@
376386
- water_regional
377387

378388
- specifier: obsclim_histsoc_300arcsec
389+
parent: obsclim_histsoc_default
379390
title: High-resolution sensitivity 10km
380391
subtitles:
381392
- obsclim_histsoc_300arcsec
@@ -399,6 +410,7 @@
399410
- water_regional
400411

401412
- specifier: obsclim_histsoc_1800arcsec
413+
parent: obsclim_histsoc_default
402414
title: High-resolution sensitivity 60km
403415
subtitles:
404416
- obsclim_histsoc_1800arcsec
@@ -436,6 +448,7 @@
436448
- marine-fishery_regional
437449

438450
- specifier: obsclim_histsoc_1955-riverine-input
451+
parent: obsclim_histsoc_default
439452
title: Riverine influx sensitivity
440453
subtitles:
441454
- obsclim_histsoc_1955-riverine-input
@@ -451,6 +464,7 @@
451464
- marine-fishery_regional
452465

453466
- specifier: fishmip-nat-fixed-river-nutrients
467+
parent: obsclim_nat_default_fishmip
454468
title: Riverine influx sensitivity
455469
subtitles:
456470
- fishmip-nat-fixed-river-nutrients
@@ -466,6 +480,7 @@
466480
- marine-fishery_regional
467481

468482
- specifier: obsclim_histsoc_60arcmin
483+
parent: obsclim_histsoc_default
469484
title: Resolution sensitivity
470485
subtitles:
471486
- obsclim_histsoc_60arcmin
@@ -481,6 +496,7 @@
481496
- marine-fishery_regional
482497

483498
- specifier: obsclim_nat_60arcmin
499+
parent: obsclim_nat_default_fishmip
484500
title: Resolution sensitivity
485501
subtitles:
486502
- obsclim_nat_60arcmin
@@ -496,6 +512,7 @@
496512
- marine-fishery_regional
497513

498514
- specifier: obsclim_histsoc_1955-riverine-input+60arcmin
515+
parent: obsclim_histsoc_default
499516
title: Riverine influx and resolution sensitivity
500517
subtitles:
501518
- obsclim_histsoc_1955-riverine-input+60arcmin
@@ -511,6 +528,7 @@
511528
- marine-fishery_regional
512529

513530
- specifier: obsclim_nat_1955-riverine-input+60arcmin
531+
parent: obsclim_nat_default_fishmip
514532
title: Riverine influx and resolution sensitivity
515533
subtitles:
516534
- obsclim_nat_1955-riverine-input+60arcmin
@@ -526,6 +544,7 @@
526544
- marine-fishery_regional
527545

528546
- specifier: obsclim_nat_1901co2
547+
parent: obsclim_nat_default
529548
historical:
530549
climate: obsclim
531550
climate_sens: 1901co2
@@ -538,6 +557,7 @@
538557
- biomes
539558

540559
- specifier: obsclim_nat_nofire
560+
parent: obsclim_nat_default
541561
historical:
542562
climate: obsclim
543563
soc: nat
@@ -550,6 +570,7 @@
550570
- biomes
551571

552572
- specifier: counterclim_nat_obsco2
573+
parent: counterclim_nat_default
553574
historical:
554575
climate: counterclim
555576
climate_sens: obsco2

0 commit comments

Comments
 (0)