From e57a038f9e662ba8a4c1752405d2b08b15f895c2 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 24 Oct 2025 13:26:24 +0000 Subject: [PATCH] Bug 41111: Add an yellow state to ILLAutoBackendPriority Originally, AutoILLBackendPriority only considered 2 states: green or red. This patch introduces a yellow state. Yellow means the Staff UI can pick that backend, but Koha will only suggest that as the goto backend if no other 'green' backends exist. If both green and yellow backends are returned, Koha will suggest the top green in priority. OPAC will never consider 'yellow' backends. Functionality there stays the same: Pick first 'green' backend in priority or default to Standard. Test plan: 1) Enable ILLModule 2) Install this dummy backend plugin designed for testing purposes only: https://github.com/openfifth/koha-ill-backend-plugin/releases/tag/v2.0.7 3) Enable AutoILLBackendPriority by ticking "PluginBackend" 4) Create a new ILL request, visit: /cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard 5) If you put 'red' as title, the backend will return unavailable. If you put 'green' on title the backend will return available. If you put 'yellow' on the backend it'll return the new 'yellow' stage. If title doesnt match that it'll return one of the 3 at random. --- .../intranet-tmpl/prog/js/ill-autobackend.js | 40 ++++++++++++++++--- .../opac-tmpl/bootstrap/js/ill-autobackend.js | 18 ++++++++- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-autobackend.js b/koha-tmpl/intranet-tmpl/prog/js/ill-autobackend.js index 2670daf1632..3fa275b7711 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-autobackend.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-autobackend.js @@ -24,8 +24,13 @@ $(document).ready(function () { auto_backend.available = 0; }, success: function (data) { - _addSuccessMessage(auto_backend.name, data); - auto_backend.available = 1; + if (data.success !== undefined && data.success !== null) { + _addSuccessMessage(auto_backend.name, data); + auto_backend.available = 1; + } else if (data.warning) { + _addWarningMessage(auto_backend.name, data); + auto_backend.available = 0; + } }, error: function (request, textstatus) { if (textstatus === "timeout") { @@ -81,6 +86,20 @@ $(document).ready(function () { _addBackendOption("Standard"); } + function _addWarningMessage(auto_backend_name, data) { + _removeVerifyingMessage(auto_backend_name); + $( + auto_ill_el + " > #backend-" + auto_backend_name + " #backendcol" + ).append( + '
' + + "" + + __("Warning.") + + "
" + + data.warning + + "
" + ); + } + function _addSuccessMessage(auto_backend_name, data) { _removeVerifyingMessage(auto_backend_name); $( @@ -189,10 +208,19 @@ $(document).ready(function () { "background-color": "", border: "", }); - $(this).closest(".list-group-item").css({ - "background-color": "rgba(0, 128, 0, 0.1)", - border: "1px solid rgba(0, 128, 0, 0.7)", - }); + if ($(this).parent().siblings().find(".text-success").length > 0) { + $(this).closest(".list-group-item").css({ + "background-color": "rgba(0, 128, 0, 0.1)", + border: "1px solid rgba(0, 128, 0, 0.7)", + }); + } else if ( + $(this).parent().siblings().find(".text-warning").length > 0 + ) { + $(this).closest(".list-group-item").css({ + "background-color": "rgba(255, 228, 0, 0.1)", + border: "1px solid rgba(255, 228, 0, 0.7)", + }); + } } ); diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/ill-autobackend.js b/koha-tmpl/opac-tmpl/bootstrap/js/ill-autobackend.js index 7c59e3d185e..e9e7a356fd1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/ill-autobackend.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/ill-autobackend.js @@ -24,8 +24,13 @@ $(document).ready(function () { auto_backend.available = 0; }, success: function (data) { - _addSuccessMessage(auto_backend.name); - auto_backend.available = 1; + if (data.success) { + _addSuccessMessage(auto_backend.name, data); + auto_backend.available = 1; + } else if (data.warning) { + _addWarningMessage(auto_backend.name, data); + auto_backend.available = 0; + } }, error: function (request, textstatus) { if (textstatus === "timeout") { @@ -80,6 +85,15 @@ $(document).ready(function () { _addBackendOption("Standard"); } + function _addWarningMessage(auto_backend_name, data) { + _removeVerifyingMessage(auto_backend_name); + $(auto_ill_el + " > #backend-" + auto_backend_name).append( + ' ' + + __("Warning.").format(auto_backend_name) + + "" + ); + } + function _addSuccessMessage(auto_backend_name) { _removeVerifyingMessage(auto_backend_name); $(auto_ill_el + " > #backend-" + auto_backend_name).append( -- 2.39.5