Skip to content

Commit

Permalink
LIMS-1549: Disallow dispatch requests on dewars that are 'processing'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Williams committed Dec 19, 2024
1 parent 7eb2aab commit 9916b5e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 36 deletions.
8 changes: 0 additions & 8 deletions client/src/css/partials/_tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ They can be overriden by specific classes below
}

tr {
.deactivate {
display: none;
}

&.inactive td {
background: $content-inactive !important;
}
Expand All @@ -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;
}
}
}

Expand Down
58 changes: 40 additions & 18 deletions client/src/js/modules/shipment/views/dewars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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() {
Expand All @@ -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) {
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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('<td colspan="10">No dewars for this shipment</td>')
})

return GridView = Backbone.Marionette.CompositeView.extend({
tagName: "table",
tagName: 'table',
emptyView: EmptyView,
className: 'dewars reflow',
template: template,
Expand All @@ -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);
},*/

})

})
})
14 changes: 4 additions & 10 deletions client/src/js/templates/shipment/dewarlistrow.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@
<td><%-STORAGELOCATION%></td>
<td><%-CCOUNT%></td>
<td>
<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>
<a class="button deact" title="Deactivate Dewar"><i class="fa fa-power-off"></i> <span class="tw-hidden xl:tw-inline">Deactivate</span></a>
<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>
<% const container = (app.type == "xpdf") ? "Puck" : "Container" %>
<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>
<% 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` %>
<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>
<% } else { %>
<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>
<% } %>
<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>
<% } %>
<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>
<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>
<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>
</td>

0 comments on commit 9916b5e

Please sign in to comment.