Skip to content

Commit 9b099b0

Browse files
ndg63276Mark Williams
andauthored
LIMS-1549: Disallow dispatch requests on dewars that are 'processing' (#884)
Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk>
1 parent f85c5d9 commit 9b099b0

File tree

3 files changed

+44
-36
lines changed

3 files changed

+44
-36
lines changed

client/src/css/partials/_tables.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ They can be overriden by specific classes below
165165
}
166166

167167
tr {
168-
.deactivate {
169-
display: none;
170-
}
171-
172168
&.inactive td {
173169
background: $content-inactive !important;
174170
}
@@ -179,10 +175,6 @@ They can be overriden by specific classes below
179175

180176
&.active td, &.active:nth-child(odd) td {
181177
background: $content-active;
182-
183-
.deactivate {
184-
display: inline;
185-
}
186178
}
187179
}
188180

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

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ define(['marionette', 'backbone',
1212

1313
'backbone-validation',
1414
], function(Marionette, Backbone, Visits, DewarRegistry, ValidatedRow, Editable, forms, utils, template, rowtemplate, rowtemplatenew) {
15-
16-
15+
16+
1717
var GridRow = ValidatedRow.extend(_.extend({}, forms, {
1818
getTemplate: function() {
1919
return this.model.get('new') ? rowtemplatenew : rowtemplate
@@ -33,16 +33,19 @@ define(['marionette', 'backbone',
3333
'click a.deact': 'deactivateDewar',
3434
'click a.print': utils.signHandler,
3535
},
36-
36+
3737
ui: {
3838
first: 'select[name=FIRSTEXPERIMENTID]',
3939
fc: 'select[name=FACILITYCODE]',
40+
deact: '.deact',
41+
dispatch: '.dispatch',
42+
transfer: '.transfer',
43+
ssd: '.ssdispatch',
4044
},
4145

4246
className: function() {
4347
if (this.model.get('DEWARSTATUS') == 'processing') return 'active'
4448
},
45-
4649

4750
deactivateDewar: function(e) {
4851
e.preventDefault()
@@ -52,6 +55,8 @@ define(['marionette', 'backbone',
5255
data: { did: this.model.get('DEWARID') },
5356
success: function() {
5457
self.$el.removeClass('active')
58+
self.model.set('DEWARSTATUS', 'at facility')
59+
self.showHideButtons()
5560
},
5661

5762
error: function() {
@@ -66,7 +71,7 @@ define(['marionette', 'backbone',
6671
if (this.model.get('new')) return
6772
app.trigger('shipment:showdewar', this.model.get('DEWARID'))
6873
},
69-
74+
7075
setData: function() {
7176
var data = {}
7277
_.each(['CODE', 'FACILITYCODE','FIRSTEXPERIMENTID','TRACKINGNUMBERTOSYNCHROTRON','TRACKINGNUMBERFROMSYNCHROTRON', 'WEIGHT'], function(f) {
@@ -82,11 +87,11 @@ define(['marionette', 'backbone',
8287
self.render()
8388
})
8489
},
85-
90+
8691
error: function(m,r,o) {
8792
app.message('Something went wrong creating this dewar, please try again')
8893
},
89-
94+
9095
cancelDewar: function(e) {
9196
e.preventDefault()
9297
this.model.collection.remove(this.model)
@@ -95,7 +100,7 @@ define(['marionette', 'backbone',
95100
initialize: function() {
96101
this.showDewar = _.debounce(this.showDewar, 500)
97102
},
98-
103+
99104
onRender: function() {
100105
console.log('rendering row')
101106
Backbone.Validation.unbind(this)
@@ -120,21 +125,44 @@ define(['marionette', 'backbone',
120125
})
121126

122127
this.ui.fc.html(this.getOption('regdewars').opts({ empty: true }))
128+
this.showHideButtons()
129+
},
130+
131+
showHideButtons: function() {
132+
if (this.model.get('DEWARSTATUS') === 'processing') {
133+
this.ui.deact.show()
134+
this.ui.dispatch.hide()
135+
this.ui.transfer.hide()
136+
} else {
137+
this.ui.deact.hide()
138+
this.ui.dispatch.show()
139+
this.ui.transfer.show()
140+
}
141+
if (this.model.get('STORAGELOCATION') === 'stores-out') {
142+
this.ui.dispatch.hide()
143+
this.ui.transfer.hide()
144+
}
145+
if (app.options.get('shipping_service_app_url') && this.model.get('EXTERNALSHIPPINGIDFROMSYNCHROTRON')) {
146+
let link = app.options.get('shipping_service_app_url')+'/shipment-requests/'+this.model.get('EXTERNALSHIPPINGIDFROMSYNCHROTRON')+'/outgoing'
147+
this.ui.ssd.attr('href', link)
148+
} else {
149+
this.ui.ssd.hide()
150+
}
123151
},
124152

125153
modelEvents: {
126154
sync: 'render'
127155
}
128156
}))
129-
157+
130158

131159
var EmptyView = Marionette.ItemView.extend({
132160
tagName: 'tr',
133161
template: _.template('<td colspan="10">No dewars for this shipment</td>')
134162
})
135-
163+
136164
return GridView = Backbone.Marionette.CompositeView.extend({
137-
tagName: "table",
165+
tagName: 'table',
138166
emptyView: EmptyView,
139167
className: 'dewars reflow',
140168
template: template,
@@ -154,12 +182,6 @@ define(['marionette', 'backbone',
154182
this.regdewars.state.pageSize = 9999
155183
this.regdewars.fetch()
156184
},
157-
158-
// This magically works, which is worrying...
159-
/*appendHtml: function(collectionView, itemView){
160-
collectionView.$("tbody").append(itemView.el);
161-
},*/
162-
163185
})
164186

165-
})
187+
})

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@
1010
<td><%-STORAGELOCATION%></td>
1111
<td><%-CCOUNT%></td>
1212
<td>
13-
<span class="deactivate"><a class="button deact" title="Deactivate Dewar"><i class="fa fa-power-off"></i> <span class="tw-hidden xl:tw-inline">Deactivate</span></a></span>
13+
<a class="button deact" title="Deactivate Dewar"><i class="fa fa-power-off"></i> <span class="tw-hidden xl:tw-inline">Deactivate</span></a>
1414
<a class="button print" title="Click to print dewar contents" href="<%-APIURL%>/pdf/container/did/<%-DEWARID%>/prop/<%-PROP%>"><i class="fa fa-print"></i> <span class="tw-hidden xl:tw-inline">Print Report</span></a>
1515
<% const container = (app.type == "xpdf") ? "Puck" : "Container" %>
1616
<a class="button add add-container-small" data-testid="shipment-add-container" title="Click to Add a <%-container%>" href="/containers/add/did/<%-DEWARID%>"><i class="fa fa-plus"></i> <span class="add-container-text tw-hidden xl:tw-inline">Add <%-container%></span></a>
17-
<% if (STORAGELOCATION != 'stores-out') { %>
18-
<% if (app.options.get("shipping_service_app_url") && EXTERNALSHIPPINGIDFROMSYNCHROTRON) { %>
19-
<% const link = `${app.options.get("shipping_service_app_url")}/shipment-requests/${EXTERNALSHIPPINGIDFROMSYNCHROTRON}/outgoing` %>
20-
<a class="button" title="Click to view dispatch information" href="<%-link%>"><i class="fa fa-home"></i> <span class="tw-hidden xl:tw-inline">Dispatch</span></a>
21-
<% } else { %>
22-
<a class="button" title="Click to dispatch dewar back to your lab" href="/dewars/dispatch/<%-DEWARID%>"><i class="fa fa-home"></i> <span class="tw-hidden xl:tw-inline">Dispatch</span></a>
23-
<% } %>
24-
<a class="button" title="Click to transfer dewar to another beamline" href="/dewars/transfer/<%-DEWARID%>"><i class="fa fa-arrows-h"></i> <span class="tw-hidden xl:tw-inline">Transfer</span></a>
25-
<% } %>
17+
<a class="button ssdispatch" title="Click to view dispatch information" href=""><i class="fa fa-home"></i> <span class="tw-hidden xl:tw-inline">View Dispatch Request</span></a>
18+
<a class="button dispatch" title="Click to dispatch dewar back to your lab" href="/dewars/dispatch/<%-DEWARID%>"><i class="fa fa-home"></i> <span class="tw-hidden xl:tw-inline">Dispatch</span></a>
19+
<a class="button transfer" title="Click to transfer dewar to another beamline" href="/dewars/transfer/<%-DEWARID%>"><i class="fa fa-arrows-h"></i> <span class="tw-hidden xl:tw-inline">Transfer</span></a>
2620
</td>
2721

0 commit comments

Comments
 (0)