Skip to content

Commit ce200fe

Browse files
ndg63276Mark Williams
andauthored
LIMS-1287: Improve workflow for responsive scheduling (#889)
* LIMS-1287: Improve workflow for responsive scheduling * LIMS-1287: Dont allow 'Other' for red/yellow shipments --------- Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk>
1 parent 9b099b0 commit ce200fe

File tree

6 files changed

+183
-66
lines changed

6 files changed

+183
-66
lines changed

api/src/Page/Shipment.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Shipment extends Page
8989
//'FIRSTEXPERIMENTID' => '\w+\d+-\d+',
9090

9191
// Fields for responsive remote questions:
92-
'DYNAMIC' => '1?|Yes|No',
92+
'DYNAMIC' => '\w+',
9393
'REMOTEORMAILIN' => '.*',
9494
'SESSIONLENGTH' => '\w+',
9595
'ENERGY' => '.*',
@@ -101,6 +101,7 @@ class Shipment extends Page
101101
'MULTIAXISGONIOMETRY' => '1?|Yes|No',
102102
'ENCLOSEDHARDDRIVE' => '1?|Yes|No',
103103
'ENCLOSEDTOOLS' => '1?|Yes|No',
104+
'LONGWAVELENGTH' => '1?|Yes|No',
104105

105106
'COMMENTS' => '.*',
106107

@@ -165,7 +166,8 @@ class Shipment extends Page
165166
'EXTRASUPPORTREQUIREMENT',
166167
'MULTIAXISGONIOMETRY',
167168
'ENCLOSEDHARDDRIVE',
168-
'ENCLOSEDTOOLS'
169+
'ENCLOSEDTOOLS',
170+
'LONGWAVELENGTH',
169171
);
170172

171173
public static $dispatch = array(
@@ -2933,7 +2935,7 @@ function _add_shipment()
29332935

29342936
$dynamic = null;
29352937
if ($this->has_arg('DYNAMIC')) {
2936-
$dynamic = $this->arg("DYNAMIC") ? "Yes" : "No";
2938+
$dynamic = $this->arg("DYNAMIC");
29372939
}
29382940

29392941
$extra_array = array(
@@ -2943,6 +2945,7 @@ function _add_shipment()
29432945
);
29442946

29452947
if ($dynamic) {
2948+
$long_wavelength = $this->has_arg('LONGWAVELENGTH') ? $this->arg('LONGWAVELENGTH') : '';
29462949
$remote_or_mailin = $this->has_arg('REMOTEORMAILIN') ? $this->arg('REMOTEORMAILIN') : '';
29472950
$session_length = $this->has_arg('SESSIONLENGTH') ? $this->arg('SESSIONLENGTH') : '';
29482951
$energy_requirements = $this->has_arg('ENERGY') ? $this->arg('ENERGY') : '';
@@ -2965,6 +2968,7 @@ function _add_shipment()
29652968
$multi_axis_goniometry = $this->arg('MULTIAXISGONIOMETRY') ? "Yes" : "No";
29662969
}
29672970
$dynamic_options = array(
2971+
"LONGWAVELENGTH" => $long_wavelength,
29682972
"REMOTEORMAILIN" => $remote_or_mailin,
29692973
"SESSIONLENGTH" => $session_length,
29702974
"ENERGY" => $energy_requirements,

client/src/js/models/shipment.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ define(['backbone'], function (Backbone) {
1818
pattern: 'fcode',
1919
},
2020

21+
DYNAMIC: {
22+
required: true,
23+
},
24+
2125
FIRSTEXPERIMENTID: {
2226
required: false,
2327
pattern: 'number',
@@ -27,6 +31,10 @@ define(['backbone'], function (Backbone) {
2731
required: false,
2832
},
2933

34+
COMMENTS: {
35+
required: false,
36+
},
37+
3038
SESSIONLENGTH: {
3139
required: false,
3240
pattern: 'number',

client/src/js/modules/shipment/views/shipment.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ define(['marionette',
5858

5959
ui: {
6060
add_dewar: '#add_dewar',
61+
longwavelength: '.longwavelength',
6162
},
6263

6364

@@ -178,13 +179,19 @@ define(['marionette',
178179
if (!dynamicSelectedValues.includes(dynamic)) {
179180
this.$el.find(".remoteormailin").hide()
180181
this.$el.find(".remoteform").hide()
182+
this.ui.longwavelength.hide()
181183
} else {
182184
industrial_codes = ['in', 'sw']
183185
industrial_visit = industrial_codes.includes(app.prop.slice(0,2))
184186
if (industrial_visit) {
185187
this.$el.find(".remoteormailin").show()
186188
}
187-
this.$el.find(".remoteform").show()
189+
this.ui.longwavelength.show()
190+
if (this.model.get('LONGWAVELENGTH') === 'Yes') {
191+
this.$el.find(".remoteform").hide()
192+
} else {
193+
this.$el.find(".remoteform").show()
194+
}
188195
}
189196
},
190197

@@ -214,7 +221,13 @@ define(['marionette',
214221

215222
edit.create("ENCLOSEDHARDDRIVE", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
216223
edit.create("ENCLOSEDTOOLS", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
217-
edit.create("DYNAMIC", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
224+
edit.create("DYNAMIC", 'select', { data: {
225+
'No': 'I have a session already scheduled',
226+
'UDC': 'I am sending pucks for Unattended Data Collection',
227+
'Imaging': 'I am sending plates for imaging',
228+
'Yes': 'I would like a session to be scheduled',
229+
'Other': 'Something else',
230+
}})
218231
industrial_codes = ['in', 'sw']
219232
industrial_visit = industrial_codes.includes(app.prop.slice(0,2))
220233
if (!industrial_visit) {
@@ -223,6 +236,7 @@ define(['marionette',
223236
edit.create("REMOTEORMAILIN", 'select', { data: {'Remote': 'Remote', 'Mail-in': 'Mail-in', 'Other': 'Other'}})
224237
}
225238

239+
edit.create("LONGWAVELENGTH", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
226240
edit.create("SESSIONLENGTH", 'text')
227241
edit.create("ENERGY", 'text')
228242
edit.create("MICROFOCUSBEAM", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
@@ -233,7 +247,7 @@ define(['marionette',
233247
edit.create("MULTIAXISGONIOMETRY", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
234248

235249
this.updateDynamic()
236-
this.listenTo(this.model, "change:DYNAMIC", this.updateDynamic)
250+
this.listenTo(this.model, "change", this.updateDynamic)
237251

238252
var self = this
239253
this.contacts = new LabContacts(null, { state: { pageSize: 9999 } })

client/src/js/modules/shipment/views/shipmentadd.js

Lines changed: 75 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

client/src/js/templates/shipment/shipment.html

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,26 @@ <h1 data-testid="shipment-header">Shipment: <span class="SHIPPINGNAME"><%-SHIPPI
129129
</li>
130130
<% } %>
131131
<%
132-
DYNAMIC=(typeof DYNAMIC !== 'undefined')? DYNAMIC : 'No';
132+
switch(DYNAMIC) {
133+
case 'No':
134+
DYNAMIC = 'I have a session already scheduled';
135+
break;
136+
case 'UDC':
137+
DYNAMIC = 'I am sending pucks for Unattended Data Collection';
138+
break;
139+
case 'Imaging':
140+
DYNAMIC = 'I am sending plates for imaging';
141+
break;
142+
case 'Yes':
143+
DYNAMIC = 'I would like a session to be scheduled';
144+
break;
145+
case 'Other':
146+
DYNAMIC = 'Something else';
147+
break;
148+
default:
149+
DYNAMIC = '';
150+
break;
151+
};
133152
REMOTEORMAILIN=(typeof REMOTEORMAILIN !== 'undefined')? REMOTEORMAILIN : null;
134153
SESSIONLENGTH=(typeof SESSIONLENGTH !== 'undefined')? SESSIONLENGTH : null;
135154
ENERGY=(typeof ENERGY !== 'undefined')? ENERGY : null;
@@ -141,6 +160,7 @@ <h1 data-testid="shipment-header">Shipment: <span class="SHIPPINGNAME"><%-SHIPPI
141160
ENCLOSEDTOOLS=(typeof ENCLOSEDTOOLS !== 'undefined')? ENCLOSEDTOOLS : null;
142161
EXTRASUPPORTREQUIREMENT=(typeof EXTRASUPPORTREQUIREMENT !== 'undefined')? EXTRASUPPORTREQUIREMENT : null;
143162
MULTIAXISGONIOMETRY=(typeof MULTIAXISGONIOMETRY !== 'undefined')? MULTIAXISGONIOMETRY : null;
163+
LONGWAVELENGTH=(typeof LONGWAVELENGTH !== 'undefined')? LONGWAVELENGTH : null;
144164
%>
145165
<li>
146166
<span class="label">Hard drive enclosed</span>
@@ -153,11 +173,14 @@ <h1 data-testid="shipment-header">Shipment: <span class="SHIPPINGNAME"><%-SHIPPI
153173
</li>
154174

155175
<li>
156-
<span class="label">Responsive</span>
176+
<span class="label">Scheduling</span>
157177
<span class="DYNAMIC"><%-DYNAMIC %></span>
158178
</li>
159179

160-
180+
<li class="longwavelength">
181+
<span class="label">Long wavelength</span>
182+
<span class="LONGWAVELENGTH"><%-LONGWAVELENGTH %></span>
183+
</li>
161184

162185
<li class="remoteormailin">
163186
<span class="label">Remote or mail in</span>

0 commit comments

Comments
 (0)