Bug 31698: Fix modals for item level moves

Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Lucas Gass 2025-05-05 16:42:31 +00:00
parent 1053d0eb1e
commit c5bac26b73
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 29 additions and 29 deletions

View File

@ -1420,39 +1420,36 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div id="move_hold_item_selection">
<h3>1. Review holds to move</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Hold ID</th>
<th>Original hold</th>
<th>Problem</th>
</tr>
</thead>
<tbody> </tbody>
</table>
</div>
<hr />
<div id="move_hold_item_search" class="alert alert-danger" style="display:none;"></div>
<form id="itemSearchForm">
<div id="move_hold_item_searchform">
<h3>2. Enter the item barcode of new hold target: </h3>
<fieldset class="action">
<h3>Enter the item barcode of new hold target: </h3>
<fieldset class="action d-flex">
<input type="text" class="form-control" name="external_id" id="external_id" required />
<button type="submit" class="btn btn-default mt-3">Search</button>
<button type="submit" class="btn btn-default">Search</button>
</fieldset>
</div>
</form>
<form id="move_hold_item_form" method="post" action="request.pl">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-move_hold_item" />
<input type="hidden" name="original_biblionumber" value="[% biblio.biblionumber | html %]" />
<div id="itemResultMessage" class="mt-3"> </div>
<div id="move_hold_item_confirm" style="display:none;">
<h3>3. Confirm moving of holds:</h3>
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-move_hold_item" />
<button type="submit" class="btn btn-primary mt-3">Move selected holds</button>
<input type="hidden" name="original_biblionumber" value="[% biblio.biblionumber %]" />
<div id="move_hold_item_selection">
<h3>Review holds to move</h3>
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th>Hold ID</th>
<th>Original hold</th>
<th>Problem</th>
</tr>
</thead>
<tbody> </tbody>
</table>
</div>
<button id="move_hold_item_confirm" type="submit" class="btn btn-primary" disabled="disabled">Move selected holds</button>
</form>
</div>
<div class="modal-footer">
@ -1500,7 +1497,7 @@
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-move_hold_biblio" />
<button type="submit" class="btn btn-primary mt-3">Move selected holds</button>
<input type="hidden" name="original_biblionumber" value="[% biblio.biblionumber %]" />
<input type="hidden" name="original_biblionumber" value="[% biblio.biblionumber | html %]" />
</div>
</form>
</div>
@ -1827,6 +1824,7 @@
$(document).ready(function() {
$("#itemSearchForm").on("submit", function (event) {
event.preventDefault();
$('#move_hold_item_confirm').prop('disabled' , true );
let externalID = $("#external_id").val();
let apiUrl = `/api/v1/items?external_id=${encodeURIComponent(externalID)}`;
@ -1896,9 +1894,9 @@
$(document).on("change", 'input[name="new_itemnumber"]', function() {
$('input[name="new_itemnumber"]').not(this).prop("checked", false);
if ( $('input[name="new_itemnumber"]:checked').length ){
$('#move_hold_item_confirm').show();
$('#move_hold_item_confirm').prop( 'disabled' , false );
} else {
$('#move_hold_item_confirm').hide();
$('#move_hold_item_confirm').prop( 'disabled' , true );
}
});
@ -2013,6 +2011,7 @@
$('.move_hold_item').click(function(e) {
e.preventDefault();
$('#move_hold_item_confirm').prop('disabled' , true );
if($('.holds_table .select_hold:checked').length) {
$('#itemResultMessage').empty();
$('#move_hold_item_selection table tbody').empty();
@ -2024,9 +2023,10 @@
let item_level_hold = $(this).data('item_level_hold');
let error_message = $(this).data('item_level_hold') ? "" : _("Cannot move a waiting or record level hold");
let found_status = $(this).data('found');
$('#move_hold_item_selection table').append(`<tr><td>${reserve_id}</td><td>Biblionumber: <a target="_blank" href="/cgi-bin/koha/reserve/request.pl?biblionumber=${reserve_biblionumber}">${reserve_biblionumber}</a> Itemnumber: <a target="_blank" href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=${reserve_biblionumber}#item${reserve_itemnumber}">${reserve_itemnumber}</a></td><td>${error_message}</td></tr>`)
if ( item_level_hold ) {
$('#move_hold_item_form').append(`<input type="hidden" name="hold_id" value="${reserve_id}">`);
$('#move_hold_item_selection table').append(`<tr><td><input type="checkbox" name="move_hold_id" value="${reserve_id}" checked/></td><td>${reserve_id}</td><td>Biblionumber: <a target="_blank" href="/cgi-bin/koha/reserve/request.pl?biblionumber=${reserve_biblionumber}">${reserve_biblionumber}</a> Itemnumber: <a target="_blank" href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=${reserve_biblionumber}#item${reserve_itemnumber}">${reserve_itemnumber}</a></td><td>${error_message}</td></tr>`)
} else {
$('#move_hold_item_selection table').append(`<tr><td><input type="checkbox" name="move_hold_id" value="${reserve_id}" checked/></td><td>${reserve_id}</td><td>Biblionumber: <a target="_blank" href="/cgi-bin/koha/reserve/request.pl?biblionumber=${reserve_biblionumber}">${reserve_biblionumber}</a> Itemnumber: <a target="_blank" href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=${reserve_biblionumber}#item${reserve_itemnumber}">${reserve_itemnumber}</a></td><td>${error_message}</td></tr>`)
}
});
}

View File

@ -112,7 +112,7 @@ if ( $op eq 'cud-move' ) {
);
}
} elsif ( $op eq 'cud-move_hold_item' or $op eq 'cud-move_hold_biblio' ) {
my @hold_ids = $input->multi_param('hold_id');
my @hold_ids = $input->multi_param('move_hold_id');
my $original_biblionumber = $input->param('original_biblionumber');
my @moving_holds = Koha::Holds->search(
{ reserve_id => \@hold_ids },