Open wopsononock opened 4 years ago
here's the validation script from validate.ctp
<script type="text/javascript"> new Vue({ el: '#app', data: { input_amount:"", input_tray:"", book_amount: 0 }, methods: { goNext: function(e) { var tray = "<?php echo $tray->tray_barcode?>"; if (this.input_tray && this.input_tray == tray) { this.book_amount = parseInt(<?php echo $amount;?>); if (this.book_amount == this.input_amount) { this.$refs.form.submit(); } else { if (confirm("The number of the books doesn't match the number in database, do you want to restart this tray from scratch?")) { this.$refs.form.submit(); } } } else { alert("The tray_barcode doesn't match."); } } } }) </script>
main logic for this condition is in TraysController.php at line 287
do we delete the tray id on line 288 and then try to redirect based on it at 294?
The redirect fails because the book/scan
method expects the tray id as a URI path component:
https://github.com/ulsdevteam/lcsu/blob/17d7ecb38726db7a58cdb14e24b9dc070d78dda7/src/Controller/BooksController.php#L52
But the redirect is sending it as a querystring value: https://github.com/ulsdevteam/lcsu/blob/17d7ecb38726db7a58cdb14e24b9dc070d78dda7/src/Controller/TraysController.php#L292-L296
This should read like:
https://github.com/ulsdevteam/lcsu/blob/17d7ecb38726db7a58cdb14e24b9dc070d78dda7/src/Controller/TraysController.php#L179-L183
(where the $tray_id
is passed directly).
Also same bug on https://github.com/ulsdevteam/lcsu/blob/17d7ecb38726db7a58cdb14e24b9dc070d78dda7/src/Controller/TraysController.php#L262-L267
Requested review of change by LCSU staff.
A tray is scanned and sent for validation. If the validator counts the books and enters a number that doesn't match the original, we generate an alert that asks if the user wants to 'restart this tray from scratch?' if you click yes, cake shows an error.