@@ -56,26 +56,31 @@ define(['marionette', 'views/form',
5656 } ,
5757
5858 events : {
59- 'change input[name=DEWARS] ' : 'updateFCodes' ,
59+ 'change @ui.dewars ' : 'updateFCodes' ,
6060 'change @ui.lcret' : 'getlcdetails' ,
6161 'change select[name^=FCODES]' : 'checkFCodes' ,
6262 'change @ui.name' : 'checkFCodes' ,
6363 'click a.add_lc' : 'addLC' ,
64- 'click @ui.noexp ' : 'updateFirstExp ' ,
65- 'click @ui.dynamic' : 'updateDynamicSchedule ' ,
66- 'change select[name^=SAFETYLEVEL] ' : 'changeSafetyLevel ' ,
64+ 'change @ui.safetylevel ' : 'changeSafetyLevel ' ,
65+ 'change @ui.dynamic' : 'updateFirstExp ' ,
66+ 'change @ui.longwavelengthsel ' : 'updateLongWavelength ' ,
6767 } ,
6868
6969 ui : {
70+ dewars : 'input[name=DEWARS]' ,
7071 lcret : 'select[name=RETURNLABCONTACTID]' ,
7172 lcout : 'select[name=SENDINGLABCONTACTID]' ,
7273 first : 'select[name=FIRSTEXPERIMENTID]' ,
7374 name : 'input[name=SHIPPINGNAME]' ,
74- noexp : 'input[name=noexp]' ,
75- dynamic : 'input[name=DYNAMIC]' , // A checkbox to indicate dynamic/remote mail-in scheduling
76- comments : 'textarea[name=COMMENTS]' , // We need this so we can prefill comments to aid users
77- safetylevel : 'select[name^=SAFETYLEVEL]' ,
78- udcresponsive : '.udcresponsive' ,
75+ dynamic : 'input[name=DYNAMIC]' ,
76+ udc : '#udc' ,
77+ responsive : '#responsive' ,
78+ imaging : '#imaging' ,
79+ existing : '#existingsession' ,
80+ other : '#other' ,
81+ safetylevel : 'select[name=SAFETYLEVEL]' ,
82+ longwavelengthsel : 'select[name=LONGWAVELENGTH]' ,
83+ longwavelengthli : '.longwavelength' ,
7984 } ,
8085
8186 addLC : function ( e ) {
@@ -102,45 +107,78 @@ define(['marionette', 'views/form',
102107
103108 changeSafetyLevel : function ( ) {
104109 if ( this . ui . safetylevel . val ( ) === 'Green' ) {
105- this . ui . udcresponsive . show ( )
110+ this . ui . udc . prop ( 'disabled' , false )
111+ this . ui . responsive . prop ( 'disabled' , false )
112+ this . ui . imaging . prop ( 'disabled' , false )
113+ this . ui . other . prop ( 'disabled' , false )
106114 } else {
107- this . ui . noexp . prop ( 'checked' , false )
108- this . updateFirstExp ( )
109- this . ui . dynamic . prop ( 'checked' , false )
115+ this . ui . udc . prop ( 'disabled' , true )
116+ this . ui . udc . prop ( 'checked' , false )
117+ this . ui . responsive . prop ( 'disabled' , true )
118+ this . ui . responsive . prop ( 'checked' , false )
119+ this . ui . imaging . prop ( 'disabled' , true )
120+ this . ui . imaging . prop ( 'checked' , false )
121+ this . ui . other . prop ( 'disabled' , true )
122+ this . ui . other . prop ( 'checked' , false )
110123 this . updateDynamicSchedule ( )
111- this . ui . udcresponsive . hide ( )
112124 }
113125 } ,
114126
115127 updateFirstExp : function ( ) {
116- if ( this . ui . noexp . is ( ':checked' ) ) {
117- this . ui . first . html ( '<option value=""> - </option>' )
118- this . ui . dynamic . prop ( 'checked' , false )
119- } else {
128+ if ( this . visits . length === 0 ) {
129+ this . ui . existing . prop ( 'disabled' , true )
130+ }
131+ if ( this . ui . existing . is ( ':checked' ) ) {
132+ this . ui . first . show ( )
120133 this . ui . first . html ( '<option value="!">Please select one</option>' + this . visits . opts ( ) )
134+ } else {
135+ this . ui . first . html ( '<option value=""> - </option>' ) . change ( )
136+ this . ui . first . hide ( )
121137 }
138+ if ( this . ui . other . is ( ':checked' ) ) {
139+ this . model . validation . COMMENTS . required = true
140+ } else {
141+ this . model . validation . COMMENTS . required = false
142+ }
143+ this . updateDynamicSchedule ( )
122144 } ,
123145
124146 updateDynamicSchedule : function ( ) {
125- // Added as a fix to allow dynamic sessions
126- // An extra option for proposals with no sessions yet that are not automated
127- industrial_codes = [ 'in' , 'sw' ]
128- industrial_visit = industrial_codes . includes ( app . prop . slice ( 0 , 2 ) )
129- if ( this . ui . dynamic . is ( ':checked' ) ) {
130- this . ui . first . html ( '<option value=""> - </option>' )
131- this . ui . noexp . prop ( 'checked' , false )
132- this . $el . find ( ".remoteform" ) . show ( )
133- if ( industrial_visit ) {
134- this . model . validation . REMOTEORMAILIN . required = true
135- this . $el . find ( ".remoteormailin" ) . show ( )
136- }
147+ if ( this . ui . responsive . is ( ':checked' ) ) {
148+ this . ui . longwavelengthli . show ( )
149+ this . updateLongWavelength ( )
137150 } else {
138- this . model . validation . REMOTEORMAILIN . required = false
139- this . ui . first . html ( '<option value="!">Please select one</option>' + this . visits . opts ( ) )
140- this . $el . find ( ".remoteform" ) . hide ( )
141- if ( industrial_visit ) {
142- this . $el . find ( ".remoteormailin" ) . hide ( )
143- }
151+ this . ui . longwavelengthli . hide ( )
152+ this . hideRemoteForm ( )
153+ }
154+ } ,
155+
156+ updateLongWavelength : function ( ) {
157+ if ( this . ui . longwavelengthsel . val ( ) === 'No' ) {
158+ this . showRemoteForm ( )
159+ } else {
160+ this . hideRemoteForm ( )
161+ }
162+ } ,
163+
164+ isIndustrialProposal : function ( ) {
165+ industrial_codes = [ 'in' , 'sw' ]
166+ return industrial_codes . includes ( app . prop . slice ( 0 , 2 ) )
167+ } ,
168+
169+ showRemoteForm : function ( ) {
170+ this . $el . find ( ".remoteform" ) . show ( )
171+ if ( this . isIndustrialProposal ( ) ) {
172+ this . model . validation . REMOTEORMAILIN . required = true
173+ this . $el . find ( ".remoteormailin" ) . show ( )
174+ }
175+ } ,
176+
177+ hideRemoteForm : function ( ) {
178+ this . model . validation . REMOTEORMAILIN . required = false
179+ this . $el . find ( ".remoteform" ) . hide ( )
180+ if ( this . isIndustrialProposal ( ) ) {
181+ this . $el . find ( ".remoteormailin" ) . hide ( )
144182 }
145183 } ,
146184
@@ -206,7 +244,7 @@ define(['marionette', 'views/form',
206244 Update number of facility code inputs based on number of dewars
207245 */
208246 updateFCodes : function ( ) {
209- var d = this . $el . find ( 'input[name=DEWARS]' ) . val ( )
247+ var d = this . ui . dewars . val ( )
210248 d > 0 ? this . $el . find ( 'li.d' ) . show ( ) : this . $el . find ( 'li.d' ) . hide ( )
211249 var fcs = _ . map ( _ . range ( 1 , parseInt ( d ) + 1 ) , function ( i ) { return { id : i } } )
212250 this . fcodes . set ( fcs )
0 commit comments