Skip to content

Commit

Permalink
[LIMS-413]Improvement: Make dynamic editable (#473)
Browse files Browse the repository at this point in the history
* LIMS-413: Make 'dynamic' editable on shipment page

* LIMS-413: Fix conversion of DYNAMIC to Yes/No
  • Loading branch information
MattPrit authored and NKatti2011 committed Feb 23, 2023
1 parent b131f4e commit ed873b9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 40 deletions.
7 changes: 5 additions & 2 deletions api/src/Page/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Shipment extends Page
//'FIRSTEXPERIMENTID' => '\w+\d+-\d+',

// Fields for responsive remote questions:
'DYNAMIC' => '1?',
'DYNAMIC' => '1?|Yes|No',
'REMOTEORMAILIN' => '.*',
'SESSIONLENGTH' => '\w+',
'ENERGY' => '.*',
Expand Down Expand Up @@ -2221,7 +2221,10 @@ function _add_shipment() {
$tools_enclosed = $this->arg('ENCLOSEDTOOLS') ? "Yes" : "No";
}

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

$extra_array = array(
"ENCLOSEDHARDDRIVE"=> $hard_drive_enclosed,
Expand Down
20 changes: 20 additions & 0 deletions client/src/js/modules/shipment/views/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,22 @@ define(['marionette',
refreshDewar: function() {
this.fetchDewars(true)
},

updateDynamic: function(){
dynamic = this.model.get('DYNAMIC')
dynamicSelectedValues = [true, 'Yes', 'yes', 'Y', 'y']
if (!dynamicSelectedValues.includes(dynamic)) {
this.$el.find(".remoteormailin").hide()
this.$el.find(".remoteform").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()
}
},

onRender: function() {
if (app.proposal && app.proposal.get('ACTIVE') != '1') this.ui.add_dewar.hide()
Expand Down Expand Up @@ -198,6 +214,7 @@ 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'}})
industrial_codes = ['in', 'sw']
industrial_visit = industrial_codes.includes(app.prop.slice(0,2))
if (!industrial_visit) {
Expand All @@ -212,6 +229,9 @@ define(['marionette',
edit.create("SCHEDULINGRESTRICTIONS", 'text')
edit.create("LASTMINUTEBEAMTIME", 'select', { data: {'Yes': 'Yes', 'No': 'No'}})
edit.create("DEWARGROUPING", 'select', { data: {'Yes': 'Yes', 'No': 'No', 'Don\'t mind': 'Don\'t mind'}})

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

var self = this
this.contacts = new LabContacts(null, { state: { pageSize: 9999 } })
Expand Down
87 changes: 49 additions & 38 deletions client/src/js/templates/shipment/shipment.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,46 +135,57 @@ <h1>Shipment: <span class="SHIPPINGNAME"><%-SHIPPINGNAME%></span></h1>
<span class="ENCLOSEDTOOLS"><%-ENCLOSEDTOOLS %></span>
</li>
<% } %>


<% if (DYNAMIC) {%>
<% if (REMOTEORMAILIN) {%>
<li class="remoteormailin">
<span class="label">Remote or mail in</span>
<span class="REMOTEORMAILIN"><%-REMOTEORMAILIN %></span>
</li>
<% } %>

<li>
<span class="label">Session length</span>
<span class="SESSIONLENGTH"><%-SESSIONLENGTH %></span>
</li>

<li>
<span class="label">Energy/wavelength requirements</span>
<span class="ENERGY"><%-ENERGY %></span>
</li>

<li>
<span class="label">Microfocus beam requested</span>
<span class="MICROFOCUSBEAM"><%-MICROFOCUSBEAM %></span>
</li>

<li>
<span class="label">Scheduling restrictions</span>
<span class="SCHEDULINGRESTRICTIONS"><%-SCHEDULINGRESTRICTIONS %></span>
</li>

<li>
<span class="label">Consider for last-minute beamtime</span>
<span class="LASTMINUTEBEAMTIME"><%-LASTMINUTEBEAMTIME %></span>
</li>

<li>
<span class="label">Group Dewars</span>
<span class="DEWARGROUPING"><%-DEWARGROUPING %></span>
</li>
<% } %>
<span class="label">Responsive Remote</span>
<span class="DYNAMIC"><%-DYNAMIC %></span>
</li>

<%
DYNAMIC=(typeof DYNAMIC !== 'undefined')? DYNAMIC : 'No';
REMOTEORMAILIN=(typeof REMOTEORMAILIN !== 'undefined')? REMOTEORMAILIN : null;
SESSIONLENGTH=(typeof SESSIONLENGTH !== 'undefined')? SESSIONLENGTH : null;
ENERGY=(typeof ENERGY !== 'undefined')? ENERGY : null;
MICROFOCUSBEAM=(typeof MICROFOCUSBEAM !== 'undefined')? MICROFOCUSBEAM : null;
SCHEDULINGRESTRICTIONS=(typeof SCHEDULINGRESTRICTIONS !== 'undefined')? SCHEDULINGRESTRICTIONS : null;
LASTMINUTEBEAMTIME=(typeof LASTMINUTEBEAMTIME !== 'undefined')? LASTMINUTEBEAMTIME : null;
DEWARGROUPING=(typeof DEWARGROUPING !== 'undefined')? DEWARGROUPING : null;
%>

<li class="remoteormailin">
<span class="label">Remote or mail in</span>
<span class="REMOTEORMAILIN"><%-REMOTEORMAILIN %></span>
</li>

<li class="remoteform">
<span class="label">Session length</span>
<span class="SESSIONLENGTH"><%-SESSIONLENGTH %></span>
</li>

<li class="remoteform">
<span class="label">Energy/wavelength requirements</span>
<span class="ENERGY"><%-ENERGY %></span>
</li>

<li class="remoteform">
<span class="label">Microfocus beam requested</span>
<span class="MICROFOCUSBEAM"><%-MICROFOCUSBEAM %></span>
</li>

<li class="remoteform">
<span class="label">Scheduling restrictions</span>
<span class="SCHEDULINGRESTRICTIONS"><%-SCHEDULINGRESTRICTIONS %></span>
</li>

<li class="remoteform">
<span class="label">Consider for last-minute beamtime</span>
<span class="LASTMINUTEBEAMTIME"><%-LASTMINUTEBEAMTIME %></span>
</li>

<li class="remoteform">
<span class="label">Group Dewars</span>
<span class="DEWARGROUPING"><%-DEWARGROUPING %></span>
</li>

<li>
<span class="label">Comments</span>
Expand Down

0 comments on commit ed873b9

Please sign in to comment.