Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIMS-1549: Disallow dispatch requests on dewars that are 'processing' #884

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>

Loading