Skip to content

Commit 6825052

Browse files
ndg63276Mark Williams
andauthored
LIMS-1699: Show confirmation dialog if a user creates a plate that is not full (#924)
Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk>
1 parent 719d2a5 commit 6825052

File tree

3 files changed

+56
-18
lines changed

3 files changed

+56
-18
lines changed

api/src/Page/Shipment.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class Shipment extends Page
218218
// TODO: Need to have a separate method for handling queueing and unqueueing of containers
219219
array('/containers/queue(/:cid)', 'patch', '_queue_container'),
220220
array('/containers/queue(/:cid)', 'get', '_queue_container'),
221-
array('/containers/barcode/:BARCODE', 'get', '_check_container'),
221+
array('/containers/barcode/(:BARCODE)', 'get', '_check_container'),
222222

223223

224224
array('/containers/registry(/:CONTAINERREGISTRYID)', 'get', '_container_registry'),
@@ -2068,16 +2068,20 @@ function _accept_terms()
20682068
# Check if a barcode exists
20692069
function _check_container()
20702070
{
2071-
$cont = $this->db->pq("SELECT CONCAT(p.proposalcode, p.proposalnumber) as prop, c.barcode
2072-
FROM container c
2073-
INNER JOIN dewar d ON d.dewarid = c.dewarid
2074-
INNER JOIN shipping s ON s.shippingid = d.shippingid
2075-
INNER JOIN proposal p ON p.proposalid = s.proposalid
2076-
WHERE c.barcode=:1", array($this->arg('BARCODE')));
2071+
if ($this->has_arg('BARCODE')) {
2072+
$cont = $this->db->pq("SELECT CONCAT(p.proposalcode, p.proposalnumber) as prop, c.barcode
2073+
FROM container c
2074+
INNER JOIN dewar d ON d.dewarid = c.dewarid
2075+
INNER JOIN shipping s ON s.shippingid = d.shippingid
2076+
INNER JOIN proposal p ON p.proposalid = s.proposalid
2077+
WHERE c.barcode=:1", array($this->arg('BARCODE')));
20772078

2078-
if (!sizeof($cont))
2079-
$this->_error('Barcode not used');
2080-
$this->_output($cont[0]);
2079+
if (!sizeof($cont)) {
2080+
$this->_output('Barcode not used');
2081+
} else {
2082+
$this->_output($cont[0]);
2083+
}
2084+
}
20812085
}
20822086

20832087
function _get_all_containers()

client/src/js/modules/types/mx/shipment/views/mx-container-add.vue

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,30 @@
381381
</template>
382382
</custom-dialog-box>
383383
</portal>
384+
385+
<portal to="dialog">
386+
<custom-dialog-box
387+
v-if="displayConfirmationModal"
388+
@perform-modal-action="addContainer"
389+
@close-modal-action="closeModalAction"
390+
>
391+
<template>
392+
<div class="tw-bg-modal-header-background tw-py-1 tw-pl-4 tw-pr-2 tw-rounded-sm tw-flex tw-w-full tw-justify-between tw-items-center tw-relative">
393+
<p>Create Container?</p>
394+
<button
395+
class="tw-flex tw-items-center tw-border tw-rounded-sm tw-border-content-border tw-bg-white tw-text-content-page-color tw-p-1"
396+
@click="closeModalAction"
397+
>
398+
<i class="fa fa-times" />
399+
</button>
400+
</div>
401+
<div class="tw-py-3 tw-px-4">
402+
Are you sure? You have only defined {{ sampleCount }} sample(s).
403+
</div>
404+
</template>
405+
</custom-dialog-box>
406+
</portal>
407+
384408
</div>
385409
</template>
386410

@@ -477,7 +501,9 @@ export default {
477501
proteinSelection: null,
478502
selectedSample: null,
479503
sampleLocation: 0,
504+
sampleCount: 0,
480505
displayImagerScheduleModal: false,
506+
displayConfirmationModal: false,
481507
selectedSchedule: null,
482508
selectedScreen: null,
483509
schedulingComponentHeader: [
@@ -610,9 +636,16 @@ export default {
610636
611637
if (!validated) return
612638
613-
this.addContainer()
639+
this.sampleCount = this.samples.filter(s => +s.PROTEINID > 0 && s.NAME !== '').length;
640+
641+
if (this.plateType === 'plate' && this.sampleCount < this.containerType.CAPACITY) {
642+
this.displayConfirmationModal = true
643+
} else {
644+
this.addContainer()
645+
}
614646
},
615647
addContainer() {
648+
this.displayConfirmationModal = false
616649
let containerAttributes = {
617650
NAME: this.NAME,
618651
DEWARID: this.DEWARID,
@@ -753,18 +786,19 @@ export default {
753786
},
754787
closeModalAction() {
755788
this.displayImagerScheduleModal = false
789+
this.displayConfirmationModal = false
756790
},
757791
async checkContainerBarcode() {
758-
try {
759-
const response = await this.$store.dispatch('fetchDataFromApi', {
760-
url: `/shipment/containers/barcode/${this.BARCODE}`,
761-
requestType: 'fetching barcode status'
762-
})
792+
const response = await this.$store.dispatch('fetchDataFromApi', {
793+
url: `/shipment/containers/barcode/${this.BARCODE}`,
794+
requestType: 'fetching barcode status'
795+
})
763796
797+
if (response.PROP) {
764798
const { PROP } = response
765799
this.BARCODECHECK = 0
766800
this.barcodeMessage = `This barcode is already registered to ${PROP}`
767-
} catch (error) {
801+
} else {
768802
this.BARCODECHECK = 1
769803
this.barcodeMessage = ''
770804
}

client/src/js/modules/types/mx/shipment/views/mx-container-view.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ export default {
322322
cancel: 'closeModal',
323323
confirm: 'unQueueContainer'
324324
},
325-
message: `<p>Are you sure you want to remove this container from the queue? You will loose your current place</p>`
325+
message: `<p>Are you sure you want to remove this container from the queue? You will lose your current place</p>`
326326
}
327327
},
328328
currentModal: 'queueContainer',

0 commit comments

Comments
 (0)