From a4b26aead280bd8fb2636898a6071939c4d558b5 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 18 Dec 2023 16:42:15 -0100 Subject: [PATCH] Bug 35604: New 'ill-backends' syspref type UI rendering of sortable ILL backends Signed-off-by: David Nind --- admin/preferences.pl | 24 +++++++++++++++++++ .../prog/en/modules/admin/preferences.tt | 22 +++++++++++++++++ .../prog/js/pages/preferences.js | 8 +++++++ 3 files changed, 54 insertions(+) diff --git a/admin/preferences.pl b/admin/preferences.pl index d00672b1ae..86203cb9c4 100755 --- a/admin/preferences.pl +++ b/admin/preferences.pl @@ -29,6 +29,7 @@ use C4::Output qw( output_html_with_http_headers output_and_exit_if_error ); use C4::Templates; use Koha::Acquisition::Currencies; use Koha::Database::Columns; +use Koha::ILL::Backends; use IO::File; use YAML::XS; use Encode; @@ -79,6 +80,29 @@ sub _get_chunk { $chunk->{'input_type'} = 'email'; } elsif ( $options{'class'} && $options{'class'} eq 'date' ) { $chunk->{'dateinput'} = 1; + } elsif ( $options{'type'} && $options{'type'} eq 'ill-backends' ) { + my @priority_enabled_backends = split ",", C4::Context->preference('AutoILLBackendPriority'); + my @sys_pref_backends = map( { name => $_, enabled => 1 }, @priority_enabled_backends ); + + my $installed_backends = Koha::ILL::Backends->installed_backends; + foreach my $installed_backend ( @{$installed_backends} ) { + if ( not grep { $installed_backend eq $_->{name} } @sys_pref_backends ) { + my $backend = Koha::ILL::Request->new->load_backend($installed_backend); + push( + @sys_pref_backends, + { + name => $installed_backend, + enabled => 0, + !$backend->_backend_capability('provides_backend_availability_check') + ? ( unable => 1 ) + : () + } + ); + } + } + + $chunk->{'ill_backends'} = \@sys_pref_backends; + $chunk->{'type'} = 'ill_backends'; } elsif ( $options{'type'} && ( $options{'type'} eq 'opac-languages' || $options{'type'} eq 'staff-languages' ) ) { my $current_languages = { map { +$_, 1 } split( /\s*,\s*/, $value ) }; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt index 1df62540f1..4a392f7884 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt @@ -173,6 +173,28 @@ [% END %] + [% ELSIF ( CHUNK.type_ill_backends ) %] + [% IF ( !CHUNK.ill_backends.empty ) %] + + [% ELSE %] +

No available backends

+ [% END # IF ( CHUNK.ill_backends ) %] [% ELSIF ( CHUNK.type_languages ) %]