@@ -5,13 +5,15 @@ import './style.scss';
5
5
import trapIcon from '../../../../assets/icons/trap.png' ;
6
6
import cleridsIcon from '../../../../assets/icons/clerids.png' ;
7
7
import endobrevIcon from '../../../../assets/icons/endobrev.png' ;
8
+ import { ChoiceInput } from '../../../../components/input-components' ;
8
9
9
10
const PlayWithModelInputs = ( props ) => {
10
11
const {
11
12
modelInputs,
12
13
runModel,
13
14
updateModelInputs,
14
15
year,
16
+ defaultModelVersion,
15
17
} = props ;
16
18
17
19
const createValueSetter = ( fieldName ) => ( newValue ) => {
@@ -22,7 +24,7 @@ const PlayWithModelInputs = (props) => {
22
24
23
25
const INPUT_INFORMATION = {
24
26
SPOTST2 : {
25
- text : 'Enter a number for spots in {YEAR-2} (whole year) ' ,
27
+ text : 'Enter number of spots two years ago ' ,
26
28
icon : trapIcon ,
27
29
iconAlt : 'number of spots icon' ,
28
30
iconId : 'trap-icon' ,
@@ -31,7 +33,7 @@ const PlayWithModelInputs = (props) => {
31
33
trueFalseSelection : false ,
32
34
} ,
33
35
SPOTST1 : {
34
- text : 'Enter a number for spots in {YEAR-1} (whole year) ' ,
36
+ text : 'Enter number of spots in previous year' ,
35
37
icon : trapIcon ,
36
38
iconAlt : 'number of spots icon' ,
37
39
iconId : 'trap-icon' ,
@@ -40,7 +42,7 @@ const PlayWithModelInputs = (props) => {
40
42
trueFalseSelection : false ,
41
43
} ,
42
44
CLERIDST1 : {
43
- text : 'Enter a number for clerids per 2 weeks in Spring, {YEAR-1} ' ,
45
+ text : 'Enter number of clerids / 2 weeks / trap this spring (leave blank if unknown) ' ,
44
46
icon : cleridsIcon ,
45
47
iconAlt : 'number of clerids icon' ,
46
48
iconId : 'clerids-icon' ,
@@ -49,7 +51,7 @@ const PlayWithModelInputs = (props) => {
49
51
trueFalseSelection : false ,
50
52
} ,
51
53
SPB : {
52
- text : 'Enter a number for SPB per 2 weeks in Spring, {YEAR} ' ,
54
+ text : 'Enter number of SPB / 2 weeks / trap this spring ' ,
53
55
icon : trapIcon ,
54
56
iconAlt : 'number of SPB icon' ,
55
57
iconId : 'spb-icon' ,
@@ -58,7 +60,7 @@ const PlayWithModelInputs = (props) => {
58
60
trueFalseSelection : false ,
59
61
} ,
60
62
ENDOBREV : {
61
- text : 'Was endo-brevicomin used in Spring, {YEAR}? ' ,
63
+ text : 'Toggle this switch to “No” if endo-brevicomin was not used ' ,
62
64
icon : endobrevIcon ,
63
65
iconAlt : 'endo-brevicomin icon' ,
64
66
iconId : 'endobrev-icon' ,
@@ -68,6 +70,21 @@ const PlayWithModelInputs = (props) => {
68
70
} ,
69
71
} ;
70
72
73
+ const MODEL_VERSION_INPUTS = {
74
+ 2018 : [ 'SPOTST2' , 'SPOTST1' , 'CLERIDST1' , 'SPB' , 'ENDOBREV' ] ,
75
+ 2024 : [ 'SPOTST1' , 'SPB' , 'ENDOBREV' ] ,
76
+ } ;
77
+
78
+ const filterModelVersionInputs = ( modelVersion ) => {
79
+ const filteredInputsInformation = Object . entries ( INPUT_INFORMATION ) . filter ( ( entry ) => {
80
+ return MODEL_VERSION_INPUTS [ modelVersion || defaultModelVersion ] . includes ( entry [ 0 ] ) ;
81
+ } ) ;
82
+
83
+ return Object . fromEntries ( filteredInputsInformation ) ;
84
+ } ;
85
+
86
+ const inputInformation = filterModelVersionInputs ( modelInputs . modelVersion ) ;
87
+
71
88
const selectionInput = ( isTrueFalseSelection , value , setValue ) => {
72
89
if ( ! isTrueFalseSelection ) {
73
90
return (
@@ -119,7 +136,7 @@ const PlayWithModelInputs = (props) => {
119
136
< span className = "input-description" > Change numbers in any of the fields below to gauge effect on predicted risks at right</ span >
120
137
< span className = "required-text" > * required</ span >
121
138
</ div >
122
- { Object . entries ( INPUT_INFORMATION ) . map ( ( [ key , inputInfo ] ) => {
139
+ { Object . entries ( inputInformation ) . map ( ( [ key , inputInfo ] ) => {
123
140
const {
124
141
text,
125
142
icon,
@@ -154,9 +171,21 @@ const PlayWithModelInputs = (props) => {
154
171
) ;
155
172
} ) }
156
173
</ div >
157
- < button className = "animated-button" id = "run-button" type = "button" onClick = { runModel } >
158
- Run
159
- </ button >
174
+ < div className = "actions-container" >
175
+ < div className = "pick-model-input" >
176
+ < span > Pick model version</ span >
177
+ < ChoiceInput
178
+ id = "modelVersion"
179
+ options = { [ 2018 , 2024 ] }
180
+ value = { modelInputs . modelVersion }
181
+ setValue = { createValueSetter ( 'modelVersion' ) }
182
+ firstOptionText = "Year"
183
+ />
184
+ </ div >
185
+ < button className = "animated-button" id = "run-button" type = "button" onClick = { runModel } >
186
+ Run
187
+ </ button >
188
+ </ div >
160
189
</ div >
161
190
) ;
162
191
} ;
0 commit comments