Skip to content

Commit 034b244

Browse files
ndg63276Mark Williams
andauthored
LIMS-2022: Don't hide shipment buttons (#1025)
Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk>
1 parent 41cbbc3 commit 034b244

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

client/src/js/models/shipment.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@ define(['backbone'], function (Backbone) {
1111
SHIPPINGNAME: {
1212
required: true,
1313
pattern: 'wwsdash',
14+
msg: 'The Shipment Name is required',
1415
},
1516

1617
'FCODES[]': {
1718
required: false,
1819
pattern: 'fcode',
1920
},
2021

22+
SAFETYLEVEL: {
23+
required: true,
24+
msg: 'The Safety Level field is required',
25+
},
26+
2127
DYNAMIC: {
2228
required: true,
29+
msg: 'The Scheduling field is required',
2330
},
2431

2532
FIRSTEXPERIMENTID: {
@@ -50,10 +57,11 @@ define(['backbone'], function (Backbone) {
5057

5158
SENDINGLABCONTACTID: {
5259
required: true,
60+
msg: 'The Outgoing Lab Contact field is required',
5361
},
5462

5563
RETURNLABCONTACTID: {
56-
required: true,
64+
required: false,
5765
},
5866

5967
DELIVERYAGENT_AGENTCODE: {

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

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ define(['marionette',
4949
'click #add_dewar': 'addDewar',
5050
'click a.send': 'sendShipment',
5151
'click a.pdf': utils.signHandler,
52+
'click a.labels': 'printLabels',
53+
'click a.awb': 'createAWB',
5254
'click a.cancel_pickup': 'cancelPickup',
5355
'click a.ready': 'markAsReady',
5456
},
@@ -61,7 +63,6 @@ define(['marionette',
6163
sent: '.sent',
6264
booking: '.booking',
6365
dhlmessage: '.dhlmessage',
64-
buttons: '.buttons',
6566
},
6667

6768

@@ -102,13 +103,31 @@ define(['marionette',
102103
})
103104
},
104105

106+
printLabels: function(e) {
107+
e.preventDefault()
108+
const errors = this.model.validate(this.model.attributes)
109+
if (errors) {
110+
app.alert({ message: 'Cannot print labels: ' + Object.values(errors)[0] })
111+
} else {
112+
utils.signHandler(e)
113+
}
114+
},
115+
116+
createAWB: function(e) {
117+
const errors = this.model.validate(this.model.attributes)
118+
if (errors) {
119+
e.preventDefault()
120+
app.alert({ message: 'Cannot create air waybill: ' + Object.values(errors)[0] })
121+
}
122+
},
123+
105124
sendShipment: function(e) {
106125
e.preventDefault()
107126
var self = this
108127
Backbone.ajax({
109128
url: app.apiurl+'/shipment/send/'+this.model.get('SHIPPINGID'),
110129
success: function() {
111-
self.model.set({ SHIPPINGSTATUS: 'send to DLS' })
130+
self.model.set({ SHIPPINGSTATUS: 'sent to facility' })
112131
app.alert({ className: 'message notify', message: 'Shipment successfully marked as sent' })
113132
self.render()
114133
},
@@ -209,11 +228,6 @@ define(['marionette',
209228
},
210229

211230
showButtons: function() {
212-
if (this.model.get('LCOUT') && this.model.get('SAFETYLEVEL')) {
213-
this.ui.buttons.show()
214-
} else {
215-
this.ui.buttons.hide()
216-
}
217231
const status = this.model.get('SHIPPINGSTATUS')
218232
const proc = this.model.get('PROCESSING')
219233
if ((status === 'opened' || status === 'awb created' || status === 'pickup booked') && proc == 0) {
@@ -242,7 +256,7 @@ define(['marionette',
242256
this.ui.booking.html('<a class="button" href="#"><i class="fa fa-credit-card"></i> Create Air Waybill - Disabled</a>')
243257
} else if (externalid && ss_url) {
244258
const link = ss_url+'/shipment-requests/'+externalid+'/incoming'
245-
this.ui.booking.html('<a class="button shipping-service" href="'+link+'"><i class="fa fa-print"></i> Manage shipment booking</a>')
259+
this.ui.booking.html('<a class="button shipping-service" href="'+link+'"><i class="fa fa-print"></i> Manage Shipment Booking</a>')
246260
} else {
247261
this.ui.booking.html('<a class="button awb" href="/shipments/awb/sid/'+shippingid+'"><i class="fa fa-credit-card"></i> Create DHL Air Waybill</a>')
248262
}
@@ -257,13 +271,12 @@ define(['marionette',
257271
const safetylevel = this.model.get('SAFETYLEVEL')
258272
const country = this.model.get('COUNTRY')
259273
const courier = this.model.get('DELIVERYAGENT_AGENTNAME')
260-
const lcout = this.model.get('LCOUT')
261274
const fac_country_nde = app.options.get('facility_courier_countries_nde')
262275
const fac_country_link = app.options.get('facility_courier_countries_link')
263276
const fac_country = app.options.get('facility_courier_countries')
264-
if (!lcout || !safetylevel) {
265-
this.ui.dhlmessage.html('<p class="message notify">Set an Outgoing Lab Contact and Safety Level in order to manage shipping.</p>')
266-
} else if (label == '1') {
277+
const ss_url = app.options.get("shipping_service_app_url_incoming")
278+
const externalid = this.model.get('EXTERNALSHIPPINGIDTOSYNCHROTRON')
279+
if (label == '1') {
267280
this.ui.dhlmessage.html('<p class="message notify">You can print your Air Waybill by clicking &quot;Print Air Waybill&quot; below.</p>')
268281
} else if (safetylevel && safetylevel == "Red") {
269282
this.ui.dhlmessage.html('<p class="message alert">Shipping of red samples is not available through this application.</p>')
@@ -273,6 +286,8 @@ define(['marionette',
273286
this.ui.dhlmessage.html('<p class="message alert">International shipping is not available through this application. If you&apos;re arranging your own shipping, enter your tracking numbers below after booking and include printed return labels in the dewar case.</p>')
274287
} else if (courier && courier.toLowerCase().trim() != 'dhl') {
275288
this.ui.dhlmessage.html('<p class="message alert">Shipping through this application is only available using DHL.</p>')
289+
} else if (externalid && ss_url) {
290+
this.ui.dhlmessage.html('<p class="message notify">You can now manage your shipment with DHL using &quot;Manage Shipment Booking&quot; below.</p>')
276291
} else {
277292
this.ui.dhlmessage.html('<p class="message notify">You can now book your shipment with DHL using &quot;Create Air Waybill&quot; below.</p>')
278293
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ <h1 data-testid="shipment-header">Shipment: <span class="SHIPPINGNAME"><%-SHIPPI
1010

1111
<span class="booking"></span>
1212

13-
<a href="<%-APIURL%>/pdf/sid/<%-SHIPPINGID%>/prop/<%-PROP%>" class="label button pdf" title="Print Shipment Labels"><i class="fa fa-print"></i> Print Shipment Labels</a>
13+
<a href="<%-APIURL%>/pdf/sid/<%-SHIPPINGID%>/prop/<%-PROP%>" class="button labels" title="Print Shipment Labels"><i class="fa fa-print"></i> Print Shipment Labels</a>
1414

15-
<a href="<%-APIURL%>/pdf/container/sid/<%-SHIPPINGID%>/prop/<%-PROP%>" class="label button pdf" title="Print Shipment Contents"><i class="fa fa-print"></i> Print Contents</a>
15+
<a href="<%-APIURL%>/pdf/container/sid/<%-SHIPPINGID%>/prop/<%-PROP%>" class="button pdf" title="Print Shipment Contents"><i class="fa fa-print"></i> Print Contents</a>
1616
</div>
1717

1818
<div class="form">

0 commit comments

Comments
 (0)