Skip to content

Commit 31d3c7d

Browse files
author
Mark Williams
committed
LIMS-1785: Make sample assign page look for containers on the beamline, not dewars
1 parent 41aaecd commit 31d3c7d

File tree

2 files changed

+42
-23
lines changed

2 files changed

+42
-23
lines changed

api/src/Page/Sample.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ function _samples()
11531153
}
11541154

11551155
if ($this->has_arg('unassigned')) {
1156-
$where .= " AND b.isinsamplechanger is null AND d.storagelocation=:" . (sizeof($args) + 1);
1156+
$where .= " AND b.isinsamplechanger is null AND c.beamlinelocation=:" . (sizeof($args) + 1);
11571157
array_push($args, $this->arg('unassigned'));
11581158
}
11591159

client/src/js/modules/assign/views/assign.js

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ define(['marionette', 'backbone', 'views/pages',
55
'collections/samples',
66
'models/shipment',
77
'models/dewar',
8+
'models/container',
89
'modules/assign/collections/pucknames',
910

1011
'utils',
@@ -19,6 +20,7 @@ define(['marionette', 'backbone', 'views/pages',
1920
Samples,
2021
Shipment,
2122
Dewar,
23+
Container,
2224
PuckNames,
2325

2426
utils,
@@ -271,8 +273,8 @@ define(['marionette', 'backbone', 'views/pages',
271273
var shipments = _.uniq(options.shipments.pluck('SHIPPINGID'))
272274
if (shipments.indexOf(this.model.get('SHIPPINGID')) > -1) {
273275
var s = options.shipments.findWhere({ SHIPPINGID: this.model.get('SHIPPINGID') })
274-
var d = s.get('DEWARS').findWhere({ DEWARID: this.model.get('DEWARID') })
275-
d.get('CONTAINERS').add(this.model)
276+
var d = s.get('DEWARS').findWhere({ CONTAINERID: this.model.get('CONTAINERID') })
277+
if (d) d.get('CONTAINERS').add(this.model)
276278
console.log('add sample to dewar')
277279
}
278280
},
@@ -599,28 +601,44 @@ define(['marionette', 'backbone', 'views/pages',
599601

600602
generateShipments: function() {
601603
console.log('generate shipments')
602-
var sids = _.uniq(this.containers.pluck('SHIPPINGID'))
603-
var shipments = []
604+
let sids = _.uniq(this.containers.pluck('SHIPPINGID'))
605+
let shipments = []
604606
_.each(sids, function(sid) {
605-
var conts = new Containers(this.containers.where({ SHIPPINGID: sid }))
606-
607-
var dids = _.uniq(conts.pluck('DEWARID'))
608-
var dewars = new Dewars()
609-
_.each(dids, function(did) {
610-
var d = conts.findWhere({ DEWARID: did })
611-
var dewar = new Dewar({
612-
DEWARID: did,
613-
CODE: d.get('DEWAR'),
614-
DEWARSTATUS: d.get('DEWARSTATUS'),
615-
CONTAINERS: new Containers(conts.where({ DEWARID: did }))
616-
})
617-
dewars.add(dewar)
618-
}, this)
607+
let conts, items;
608+
609+
if (this.pucks > 0) {
610+
conts = new Containers(this.containers.where({ SHIPPINGID: sid }))
611+
let dids = _.uniq(conts.pluck('DEWARID'))
612+
items = new Dewars()
613+
_.each(dids, function(did) {
614+
let d = conts.findWhere({ DEWARID: did })
615+
let dewar = new Dewar({
616+
DEWARID: did,
617+
CODE: d.get('DEWAR'),
618+
DEWARSTATUS: d.get('DEWARSTATUS'),
619+
CONTAINERS: new Containers(conts.where({ DEWARID: did }))
620+
})
621+
items.add(dewar)
622+
}, this)
623+
} else {
624+
conts = new Samples(this.containers.where({ SHIPPINGID: sid }))
625+
let cids = _.uniq(conts.pluck('CONTAINERID'))
626+
items = new Containers()
627+
_.each(cids, function(cid) {
628+
let c = conts.findWhere({ CONTAINERID: cid })
629+
let container = new Container({
630+
CONTAINERID: cid,
631+
CODE: c.get('CONTAINER'),
632+
CONTAINERS: new Samples(conts.where({ CONTAINERID: cid }))
633+
})
634+
items.add(container)
635+
}, this)
636+
}
619637

620-
var shipment = new Shipment({
638+
let shipment = new Shipment({
621639
SHIPPINGID: sid,
622640
SHIPPINGNAME: conts.at(0).get('SHIPMENT'),
623-
DEWARS: dewars,
641+
DEWARS: items,
624642
})
625643
shipments.push(shipment)
626644
}, this)
@@ -629,9 +647,10 @@ define(['marionette', 'backbone', 'views/pages',
629647
// This means that there is no ability to unassign containers. Fix: add a dummy shipment here.
630648
// Dragging a container to a shipment does not associate the container with that shipment - it will still be in the original shipment.
631649
if (shipments.length == 0) {
632-
var unassignShipment = new Shipment({
650+
let unassignText = this.pucks > 0 ? 'Drag a container here to unassign' : 'Drag a sample here to unassign'
651+
let unassignShipment = new Shipment({
633652
SHIPPINGID: 0,
634-
SHIPPINGNAME: 'Drag Container here to unassign',
653+
SHIPPINGNAME: unassignText,
635654
})
636655
shipments.push(unassignShipment)
637656
}

0 commit comments

Comments
 (0)