From dc83a2ecdd2770fd045d9e9002ac2545c6d453b2 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 4 Feb 2025 20:39:51 +0000 Subject: [PATCH] Bug 36135: Report errors to a modal --- .../modals/batch_modify_hold_errors.inc | 17 +++++++++++++++++ .../en/modules/tools/batch_modify_holds.tt | 18 +++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/modals/batch_modify_hold_errors.inc diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/batch_modify_hold_errors.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/batch_modify_hold_errors.inc new file mode 100644 index 00000000000..ed9d1526228 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/batch_modify_hold_errors.inc @@ -0,0 +1,17 @@ + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt index f8829ca8c55..e90921785b9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt @@ -16,6 +16,7 @@ [% WRAPPER 'header.inc' %] [% INCLUDE 'cat-search.inc' %] + [% INCLUDE modals/batch_modify_hold_errors.inc %] [% END %] [% WRAPPER 'sub-header.inc' %] @@ -251,7 +252,6 @@ - [% MACRO jsinclude BLOCK %] [% Asset.js("js/tools-menu.js") | $raw %] [% INCLUDE 'calendar.inc' %] @@ -286,6 +286,7 @@ })); $("#process").on('submit', function(e) { + var errors = []; var reserve_ids = $("input[type=checkbox][name='hold_id']:checked"); var new_pickup_loc = $("#new_pickup_loc").val(); @@ -294,7 +295,7 @@ if ( reserve_ids.length == 0 ) { e.preventDefault(); - alert(_("Please select at least one hold to process.")); + errors.push(_("Please select at least one hold to process.")); return false; } if( new_pickup_loc || new_suspend_status ){ @@ -302,10 +303,10 @@ if($(this).parents("tr").children(".found_status").data("found") != ""){ e.preventDefault(); if( new_suspend_status ){ - alert(_("One or more holds have found status and can't be suspended.")); + errors.push(_("One or more holds have found status and can't be suspended.")); } if( new_pickup_loc ){ - alert(_("One or more holds have found status and their pick up location can't be changed.")); + errors.push(_("One or more holds have found status and their pick up location can't be changed.")); } return false; } @@ -313,7 +314,14 @@ } if( ( !new_suspend_status || new_suspend_status == "not_suspended") && new_suspend_date ){ e.preventDefault(); - alert(_("You have to suspend holds if new suspend until date is set.")); + errors.push(_("You have to suspend holds if new suspend until date is set.")); + return false; + } + + if (errors.length > 0) { + e.preventDefault(); + $("#errorList").html(errors.map(error => `
  • ${error}
  • `).join("")); + $("#errorModal").modal('show'); return false; } -- 2.39.5