From 9916b5e90873b717df218625c8bdd02cc0e80044 Mon Sep 17 00:00:00 2001 From: Mark Williams Date: Thu, 19 Dec 2024 14:23:18 +0000 Subject: [PATCH] LIMS-1549: Disallow dispatch requests on dewars that are 'processing' --- client/src/css/partials/_tables.scss | 8 --- .../src/js/modules/shipment/views/dewars.js | 58 +++++++++++++------ .../js/templates/shipment/dewarlistrow.html | 14 ++--- 3 files changed, 44 insertions(+), 36 deletions(-) diff --git a/client/src/css/partials/_tables.scss b/client/src/css/partials/_tables.scss index 17b58992d..fb5f184ad 100644 --- a/client/src/css/partials/_tables.scss +++ b/client/src/css/partials/_tables.scss @@ -165,10 +165,6 @@ They can be overriden by specific classes below } tr { - .deactivate { - display: none; - } - &.inactive td { background: $content-inactive !important; } @@ -179,10 +175,6 @@ They can be overriden by specific classes below &.active td, &.active:nth-child(odd) td { background: $content-active; - - .deactivate { - display: inline; - } } } diff --git a/client/src/js/modules/shipment/views/dewars.js b/client/src/js/modules/shipment/views/dewars.js index cbe44ec7c..c853b3a4e 100644 --- a/client/src/js/modules/shipment/views/dewars.js +++ b/client/src/js/modules/shipment/views/dewars.js @@ -12,8 +12,8 @@ define(['marionette', 'backbone', 'backbone-validation', ], function(Marionette, Backbone, Visits, DewarRegistry, ValidatedRow, Editable, forms, utils, template, rowtemplate, rowtemplatenew) { - - + + var GridRow = ValidatedRow.extend(_.extend({}, forms, { getTemplate: function() { return this.model.get('new') ? rowtemplatenew : rowtemplate @@ -33,16 +33,19 @@ define(['marionette', 'backbone', 'click a.deact': 'deactivateDewar', 'click a.print': utils.signHandler, }, - + ui: { first: 'select[name=FIRSTEXPERIMENTID]', fc: 'select[name=FACILITYCODE]', + deact: '.deact', + dispatch: '.dispatch', + transfer: '.transfer', + ssd: '.ssdispatch', }, className: function() { if (this.model.get('DEWARSTATUS') == 'processing') return 'active' }, - deactivateDewar: function(e) { e.preventDefault() @@ -52,6 +55,8 @@ define(['marionette', 'backbone', data: { did: this.model.get('DEWARID') }, success: function() { self.$el.removeClass('active') + self.model.set('DEWARSTATUS', 'at facility') + self.showHideButtons() }, error: function() { @@ -66,7 +71,7 @@ define(['marionette', 'backbone', if (this.model.get('new')) return app.trigger('shipment:showdewar', this.model.get('DEWARID')) }, - + setData: function() { var data = {} _.each(['CODE', 'FACILITYCODE','FIRSTEXPERIMENTID','TRACKINGNUMBERTOSYNCHROTRON','TRACKINGNUMBERFROMSYNCHROTRON', 'WEIGHT'], function(f) { @@ -82,11 +87,11 @@ define(['marionette', 'backbone', self.render() }) }, - + error: function(m,r,o) { app.message('Something went wrong creating this dewar, please try again') }, - + cancelDewar: function(e) { e.preventDefault() this.model.collection.remove(this.model) @@ -95,7 +100,7 @@ define(['marionette', 'backbone', initialize: function() { this.showDewar = _.debounce(this.showDewar, 500) }, - + onRender: function() { console.log('rendering row') Backbone.Validation.unbind(this) @@ -120,21 +125,44 @@ define(['marionette', 'backbone', }) this.ui.fc.html(this.getOption('regdewars').opts({ empty: true })) + this.showHideButtons() + }, + + showHideButtons: function() { + if (this.model.get('DEWARSTATUS') === 'processing') { + this.ui.deact.show() + this.ui.dispatch.hide() + this.ui.transfer.hide() + } else { + this.ui.deact.hide() + this.ui.dispatch.show() + this.ui.transfer.show() + } + if (this.model.get('STORAGELOCATION') === 'stores-out') { + this.ui.dispatch.hide() + this.ui.transfer.hide() + } + if (app.options.get('shipping_service_app_url') && this.model.get('EXTERNALSHIPPINGIDFROMSYNCHROTRON')) { + let link = app.options.get('shipping_service_app_url')+'/shipment-requests/'+this.model.get('EXTERNALSHIPPINGIDFROMSYNCHROTRON')+'/outgoing' + this.ui.ssd.attr('href', link) + } else { + this.ui.ssd.hide() + } }, modelEvents: { sync: 'render' } })) - + var EmptyView = Marionette.ItemView.extend({ tagName: 'tr', template: _.template('No dewars for this shipment') }) - + return GridView = Backbone.Marionette.CompositeView.extend({ - tagName: "table", + tagName: 'table', emptyView: EmptyView, className: 'dewars reflow', template: template, @@ -154,12 +182,6 @@ define(['marionette', 'backbone', this.regdewars.state.pageSize = 9999 this.regdewars.fetch() }, - - // This magically works, which is worrying... - /*appendHtml: function(collectionView, itemView){ - collectionView.$("tbody").append(itemView.el); - },*/ - }) -}) \ No newline at end of file +}) diff --git a/client/src/js/templates/shipment/dewarlistrow.html b/client/src/js/templates/shipment/dewarlistrow.html index 9b1f8ac4f..5a7ed300f 100644 --- a/client/src/js/templates/shipment/dewarlistrow.html +++ b/client/src/js/templates/shipment/dewarlistrow.html @@ -10,18 +10,12 @@ <%-STORAGELOCATION%> <%-CCOUNT%> - Deactivate + Deactivate Print Report <% const container = (app.type == "xpdf") ? "Puck" : "Container" %> Add <%-container%> - <% if (STORAGELOCATION != 'stores-out') { %> - <% if (app.options.get("shipping_service_app_url") && EXTERNALSHIPPINGIDFROMSYNCHROTRON) { %> - <% const link = `${app.options.get("shipping_service_app_url")}/shipment-requests/${EXTERNALSHIPPINGIDFROMSYNCHROTRON}/outgoing` %> - Dispatch - <% } else { %> - Dispatch - <% } %> - Transfer - <% } %> + View Dispatch Request + Dispatch + Transfer