From 81f85c3e392e69e60c21e892e33a3a27f25632c8 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. --- .../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..445930ebe57 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) { + _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