Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIMS-1287: Improve workflow for responsive scheduling #889

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions api/src/Page/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Shipment extends Page
//'FIRSTEXPERIMENTID' => '\w+\d+-\d+',

// Fields for responsive remote questions:
'DYNAMIC' => '1?|Yes|No',
'DYNAMIC' => '\w+',
'REMOTEORMAILIN' => '.*',
'SESSIONLENGTH' => '\w+',
'ENERGY' => '.*',
Expand All @@ -101,6 +101,7 @@ class Shipment extends Page
'MULTIAXISGONIOMETRY' => '1?|Yes|No',
'ENCLOSEDHARDDRIVE' => '1?|Yes|No',
'ENCLOSEDTOOLS' => '1?|Yes|No',
'LONGWAVELENGTH' => '1?|Yes|No',

'COMMENTS' => '.*',

Expand Down Expand Up @@ -164,7 +165,8 @@ class Shipment extends Page
'EXTRASUPPORTREQUIREMENT',
'MULTIAXISGONIOMETRY',
'ENCLOSEDHARDDRIVE',
'ENCLOSEDTOOLS'
'ENCLOSEDTOOLS',
'LONGWAVELENGTH',
);

public static $dispatch = array(
Expand Down Expand Up @@ -2856,7 +2858,7 @@ function _add_shipment()

$dynamic = null;
if ($this->has_arg('DYNAMIC')) {
$dynamic = $this->arg("DYNAMIC") ? "Yes" : "No";
$dynamic = $this->arg("DYNAMIC");
}

$extra_array = array(
Expand All @@ -2866,6 +2868,7 @@ function _add_shipment()
);

if ($dynamic) {
$long_wavelength = $this->has_arg('LONGWAVELENGTH') ? $this->arg('LONGWAVELENGTH') : '';
$remote_or_mailin = $this->has_arg('REMOTEORMAILIN') ? $this->arg('REMOTEORMAILIN') : '';
$session_length = $this->has_arg('SESSIONLENGTH') ? $this->arg('SESSIONLENGTH') : '';
$energy_requirements = $this->has_arg('ENERGY') ? $this->arg('ENERGY') : '';
Expand All @@ -2888,6 +2891,7 @@ function _add_shipment()
$multi_axis_goniometry = $this->arg('MULTIAXISGONIOMETRY') ? "Yes" : "No";
}
$dynamic_options = array(
"LONGWAVELENGTH" => $long_wavelength,
"REMOTEORMAILIN" => $remote_or_mailin,
"SESSIONLENGTH" => $session_length,
"ENERGY" => $energy_requirements,
Expand Down
8 changes: 8 additions & 0 deletions client/src/js/models/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ define(['backbone'], function (Backbone) {
pattern: 'fcode',
},

DYNAMIC: {
required: true,
},

FIRSTEXPERIMENTID: {
required: false,
pattern: 'number',
Expand All @@ -27,6 +31,10 @@ define(['backbone'], function (Backbone) {
required: false,
},

COMMENTS: {
required: false,
},

SESSIONLENGTH: {
required: false,
pattern: 'number',
Expand Down
20 changes: 17 additions & 3 deletions client/src/js/modules/shipment/views/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ define(['marionette',

ui: {
add_dewar: '#add_dewar',
longwavelength: '.longwavelength',
},


Expand Down Expand Up @@ -178,13 +179,19 @@ define(['marionette',
if (!dynamicSelectedValues.includes(dynamic)) {
this.$el.find(".remoteormailin").hide()
this.$el.find(".remoteform").hide()
this.ui.longwavelength.hide()
} else {
industrial_codes = ['in', 'sw']
industrial_visit = industrial_codes.includes(app.prop.slice(0,2))
if (industrial_visit) {
this.$el.find(".remoteormailin").show()
}
this.$el.find(".remoteform").show()
this.ui.longwavelength.show()
if (this.model.get('LONGWAVELENGTH') === 'Yes') {
this.$el.find(".remoteform").hide()
} else {
this.$el.find(".remoteform").show()
}
}
},

Expand Down Expand Up @@ -214,7 +221,13 @@ define(['marionette',

edit.create("ENCLOSEDHARDDRIVE", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
edit.create("ENCLOSEDTOOLS", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
edit.create("DYNAMIC", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
edit.create("DYNAMIC", 'select', { data: {
'No': 'I have a session already scheduled',
'UDC': 'I am sending pucks for Unattended Data Collection',
'Imaging': 'I am sending plates for imaging',
'Yes': 'I would like a session to be scheduled',
'Other': 'Something else',
}})
industrial_codes = ['in', 'sw']
industrial_visit = industrial_codes.includes(app.prop.slice(0,2))
if (!industrial_visit) {
Expand All @@ -223,6 +236,7 @@ define(['marionette',
edit.create("REMOTEORMAILIN", 'select', { data: {'Remote': 'Remote', 'Mail-in': 'Mail-in', 'Other': 'Other'}})
}

edit.create("LONGWAVELENGTH", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
edit.create("SESSIONLENGTH", 'text')
edit.create("ENERGY", 'text')
edit.create("MICROFOCUSBEAM", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
Expand All @@ -233,7 +247,7 @@ define(['marionette',
edit.create("MULTIAXISGONIOMETRY", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})

this.updateDynamic()
this.listenTo(this.model, "change:DYNAMIC", this.updateDynamic)
this.listenTo(this.model, "change", this.updateDynamic)

var self = this
this.contacts = new LabContacts(null, { state: { pageSize: 9999 } })
Expand Down
112 changes: 75 additions & 37 deletions client/src/js/modules/shipment/views/shipmentadd.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,31 @@ define(['marionette', 'views/form',
},

events: {
'change input[name=DEWARS]': 'updateFCodes',
'change @ui.dewars': 'updateFCodes',
'change @ui.lcret': 'getlcdetails',
'change select[name^=FCODES]': 'checkFCodes',
'change @ui.name': 'checkFCodes',
'click a.add_lc': 'addLC',
'click @ui.noexp': 'updateFirstExp',
'click @ui.dynamic': 'updateDynamicSchedule',
'change select[name^=SAFETYLEVEL]': 'changeSafetyLevel',
'change @ui.safetylevel': 'changeSafetyLevel',
'change @ui.dynamic': 'updateFirstExp',
'change @ui.longwavelengthsel': 'updateLongWavelength',
},

ui: {
dewars: 'input[name=DEWARS]',
lcret: 'select[name=RETURNLABCONTACTID]',
lcout: 'select[name=SENDINGLABCONTACTID]',
first: 'select[name=FIRSTEXPERIMENTID]',
name: 'input[name=SHIPPINGNAME]',
noexp: 'input[name=noexp]',
dynamic: 'input[name=DYNAMIC]', // A checkbox to indicate dynamic/remote mail-in scheduling
comments: 'textarea[name=COMMENTS]', // We need this so we can prefill comments to aid users
safetylevel: 'select[name^=SAFETYLEVEL]',
udcresponsive: '.udcresponsive',
dynamic: 'input[name=DYNAMIC]',
udc: '#udc',
responsive: '#responsive',
imaging: '#imaging',
existing: '#existingsession',
other: '#other',
safetylevel: 'select[name=SAFETYLEVEL]',
longwavelengthsel: 'select[name=LONGWAVELENGTH]',
longwavelengthli: '.longwavelength',
},

addLC: function(e) {
Expand All @@ -102,45 +107,78 @@ define(['marionette', 'views/form',

changeSafetyLevel: function() {
if (this.ui.safetylevel.val() === 'Green') {
this.ui.udcresponsive.show()
this.ui.udc.prop('disabled', false)
this.ui.responsive.prop('disabled', false)
this.ui.imaging.prop('disabled', false)
this.ui.other.prop('disabled', false)
} else {
this.ui.noexp.prop('checked', false)
this.updateFirstExp()
this.ui.dynamic.prop('checked', false)
this.ui.udc.prop('disabled', true)
this.ui.udc.prop('checked', false)
this.ui.responsive.prop('disabled', true)
this.ui.responsive.prop('checked', false)
this.ui.imaging.prop('disabled', true)
this.ui.imaging.prop('checked', false)
this.ui.other.prop('disabled', true)
this.ui.other.prop('checked', false)
this.updateDynamicSchedule()
this.ui.udcresponsive.hide()
}
},

updateFirstExp: function() {
if (this.ui.noexp.is(':checked')) {
this.ui.first.html('<option value=""> - </option>')
this.ui.dynamic.prop('checked', false)
} else {
if (this.visits.length === 0) {
this.ui.existing.prop('disabled', true)
}
if (this.ui.existing.is(':checked')) {
this.ui.first.show()
this.ui.first.html('<option value="!">Please select one</option>'+this.visits.opts())
} else {
this.ui.first.html('<option value=""> - </option>').change()
this.ui.first.hide()
}
if (this.ui.other.is(':checked')) {
this.model.validation.COMMENTS.required = true
} else {
this.model.validation.COMMENTS.required = false
}
this.updateDynamicSchedule()
},

updateDynamicSchedule: function() {
// Added as a fix to allow dynamic sessions
// An extra option for proposals with no sessions yet that are not automated
industrial_codes = ['in', 'sw']
industrial_visit = industrial_codes.includes(app.prop.slice(0,2))
if (this.ui.dynamic.is(':checked')) {
this.ui.first.html('<option value=""> - </option>')
this.ui.noexp.prop('checked', false)
this.$el.find(".remoteform").show()
if (industrial_visit) {
this.model.validation.REMOTEORMAILIN.required = true
this.$el.find(".remoteormailin").show()
}
if (this.ui.responsive.is(':checked')) {
this.ui.longwavelengthli.show()
this.updateLongWavelength()
} else {
this.model.validation.REMOTEORMAILIN.required = false
this.ui.first.html('<option value="!">Please select one</option>'+this.visits.opts())
this.$el.find(".remoteform").hide()
if (industrial_visit) {
this.$el.find(".remoteormailin").hide()
}
this.ui.longwavelengthli.hide()
this.hideRemoteForm()
}
},

updateLongWavelength: function() {
if (this.ui.longwavelengthsel.val() === 'No') {
this.showRemoteForm()
} else {
this.hideRemoteForm()
}
},

isIndustrialProposal: function() {
industrial_codes = ['in', 'sw']
return industrial_codes.includes(app.prop.slice(0,2))
},

showRemoteForm: function() {
this.$el.find(".remoteform").show()
if (this.isIndustrialProposal()) {
this.model.validation.REMOTEORMAILIN.required = true
this.$el.find(".remoteormailin").show()
}
},

hideRemoteForm: function() {
this.model.validation.REMOTEORMAILIN.required = false
this.$el.find(".remoteform").hide()
if (this.isIndustrialProposal()) {
this.$el.find(".remoteormailin").hide()
}
},

Expand Down Expand Up @@ -206,7 +244,7 @@ define(['marionette', 'views/form',
Update number of facility code inputs based on number of dewars
*/
updateFCodes: function() {
var d = this.$el.find('input[name=DEWARS]').val()
var d = this.ui.dewars.val()
d > 0 ? this.$el.find('li.d').show() : this.$el.find('li.d').hide()
var fcs = _.map(_.range(1,parseInt(d)+1), function(i) { return { id: i } })
this.fcodes.set(fcs)
Expand Down
29 changes: 26 additions & 3 deletions client/src/js/templates/shipment/shipment.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,26 @@ <h1 data-testid="shipment-header">Shipment: <span class="SHIPPINGNAME"><%-SHIPPI
<span class="DELIVERYAGENT_DELIVERYDATE"><%-DELIVERYAGENT_DELIVERYDATE%></span>
</li>
<%
DYNAMIC=(typeof DYNAMIC !== 'undefined')? DYNAMIC : 'No';
switch(DYNAMIC) {
case 'No':
DYNAMIC = 'I have a session already scheduled';
break;
case 'UDC':
DYNAMIC = 'I am sending pucks for Unattended Data Collection';
break;
case 'Imaging':
DYNAMIC = 'I am sending plates for imaging';
break;
case 'Yes':
DYNAMIC = 'I would like a session to be scheduled';
break;
case 'Other':
DYNAMIC = 'Something else';
break;
default:
DYNAMIC = '';
break;
};
REMOTEORMAILIN=(typeof REMOTEORMAILIN !== 'undefined')? REMOTEORMAILIN : null;
SESSIONLENGTH=(typeof SESSIONLENGTH !== 'undefined')? SESSIONLENGTH : null;
ENERGY=(typeof ENERGY !== 'undefined')? ENERGY : null;
Expand All @@ -139,6 +158,7 @@ <h1 data-testid="shipment-header">Shipment: <span class="SHIPPINGNAME"><%-SHIPPI
ENCLOSEDTOOLS=(typeof ENCLOSEDTOOLS !== 'undefined')? ENCLOSEDTOOLS : null;
EXTRASUPPORTREQUIREMENT=(typeof EXTRASUPPORTREQUIREMENT !== 'undefined')? EXTRASUPPORTREQUIREMENT : null;
MULTIAXISGONIOMETRY=(typeof MULTIAXISGONIOMETRY !== 'undefined')? MULTIAXISGONIOMETRY : null;
LONGWAVELENGTH=(typeof LONGWAVELENGTH !== 'undefined')? LONGWAVELENGTH : null;
%>
<li>
<span class="label">Hard drive enclosed</span>
Expand All @@ -151,11 +171,14 @@ <h1 data-testid="shipment-header">Shipment: <span class="SHIPPINGNAME"><%-SHIPPI
</li>

<li>
<span class="label">Responsive</span>
<span class="label">Scheduling</span>
<span class="DYNAMIC"><%-DYNAMIC %></span>
</li>


<li class="longwavelength">
<span class="label">Long wavelength</span>
<span class="LONGWAVELENGTH"><%-LONGWAVELENGTH %></span>
</li>

<li class="remoteormailin">
<span class="label">Remote or mail in</span>
Expand Down
Loading
Loading