From ed873b999119a857ef604605f0ce0eb4ccd693c9 Mon Sep 17 00:00:00 2001 From: Matthew Pritchard <46708056+MattPrit@users.noreply.github.com> Date: Thu, 23 Feb 2023 15:29:13 +0000 Subject: [PATCH] [LIMS-413]Improvement: Make dynamic editable (#473) * LIMS-413: Make 'dynamic' editable on shipment page * LIMS-413: Fix conversion of DYNAMIC to Yes/No --- api/src/Page/Shipment.php | 7 +- .../src/js/modules/shipment/views/shipment.js | 20 +++++ .../src/js/templates/shipment/shipment.html | 87 +++++++++++-------- 3 files changed, 74 insertions(+), 40 deletions(-) diff --git a/api/src/Page/Shipment.php b/api/src/Page/Shipment.php index db259272b..8e18b7da5 100644 --- a/api/src/Page/Shipment.php +++ b/api/src/Page/Shipment.php @@ -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' => '.*', @@ -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, diff --git a/client/src/js/modules/shipment/views/shipment.js b/client/src/js/modules/shipment/views/shipment.js index 19564ee71..425c769c6 100644 --- a/client/src/js/modules/shipment/views/shipment.js +++ b/client/src/js/modules/shipment/views/shipment.js @@ -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() @@ -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) { @@ -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 } }) diff --git a/client/src/js/templates/shipment/shipment.html b/client/src/js/templates/shipment/shipment.html index 1d9dee677..9b0022d36 100644 --- a/client/src/js/templates/shipment/shipment.html +++ b/client/src/js/templates/shipment/shipment.html @@ -135,46 +135,57 @@